Raw slice with from (like subarray) (#2879)

* Raw slice with from (like subarray)

* Dep bumps

* 2.8.2

* re-use toU8a()

* Uint8Array.from

* slice on derived comment
This commit is contained in:
Jaco Greeff
2020-11-28 12:00:29 +01:00
committed by GitHub
parent a1a73cbf01
commit d65eb7a27f
12 changed files with 95 additions and 84 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"sideEffects": false,
@@ -17,8 +17,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/api": "2.8.2-3",
"@polkadot/types": "2.8.2-3",
"@polkadot/api": "2.8.2",
"@polkadot/types": "2.8.2",
"@polkadot/util": "^4.2.1",
"bn.js": "^4.11.9",
"rxjs": "^6.6.3"
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"sideEffects": false,
@@ -18,9 +18,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/api": "2.8.2-3",
"@polkadot/rpc-core": "2.8.2-3",
"@polkadot/types": "2.8.2-3",
"@polkadot/api": "2.8.2",
"@polkadot/rpc-core": "2.8.2",
"@polkadot/types": "2.8.2",
"@polkadot/util": "^4.2.1",
"@polkadot/util-crypto": "^4.2.1",
"bn.js": "^4.11.9",
@@ -29,6 +29,6 @@
},
"devDependencies": {
"@polkadot/keyring": "^4.2.1",
"@polkadot/rpc-provider": "2.8.2-3"
"@polkadot/rpc-provider": "2.8.2"
}
}
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"sideEffects": false,
@@ -17,13 +17,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/api-derive": "2.8.2-3",
"@polkadot/api-derive": "2.8.2",
"@polkadot/keyring": "^4.2.1",
"@polkadot/metadata": "2.8.2-3",
"@polkadot/rpc-core": "2.8.2-3",
"@polkadot/rpc-provider": "2.8.2-3",
"@polkadot/types": "2.8.2-3",
"@polkadot/types-known": "2.8.2-3",
"@polkadot/metadata": "2.8.2",
"@polkadot/rpc-core": "2.8.2",
"@polkadot/rpc-provider": "2.8.2",
"@polkadot/types": "2.8.2",
"@polkadot/types-known": "2.8.2",
"@polkadot/util": "^4.2.1",
"@polkadot/util-crypto": "^4.2.1",
"bn.js": "^4.11.9",
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/metadata",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
"sideEffects": false,
@@ -16,8 +16,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/types": "2.8.2-3",
"@polkadot/types-known": "2.8.2-3",
"@polkadot/types": "2.8.2",
"@polkadot/types-known": "2.8.2",
"@polkadot/util": "^4.2.1",
"@polkadot/util-crypto": "^4.2.1",
"bn.js": "^4.11.9"
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"sideEffects": false,
@@ -17,9 +17,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/metadata": "2.8.2-3",
"@polkadot/rpc-provider": "2.8.2-3",
"@polkadot/types": "2.8.2-3",
"@polkadot/metadata": "2.8.2",
"@polkadot/rpc-provider": "2.8.2",
"@polkadot/types": "2.8.2",
"@polkadot/util": "^4.2.1",
"memoizee": "^0.4.14",
"rxjs": "^6.6.3"
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Transport providers for the API",
"main": "index.js",
"sideEffects": false,
@@ -17,7 +17,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/types": "2.8.2-3",
"@polkadot/types": "2.8.2",
"@polkadot/util": "^4.2.1",
"@polkadot/util-crypto": "^4.2.1",
"@polkadot/x-fetch": "^4.2.1",
@@ -27,7 +27,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^4.2.1",
"@polkadot/metadata": "2.8.2-3",
"@polkadot/metadata": "2.8.2",
"mock-socket": "^9.0.3",
"nock": "^13.0.5"
}
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Type generation scripts",
"main": "index.js",
"sideEffects": false,
@@ -26,10 +26,10 @@
"@babel/core": "^7.12.8",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.5",
"@polkadot/api": "2.8.2-3",
"@polkadot/metadata": "2.8.2-3",
"@polkadot/rpc-provider": "2.8.2-3",
"@polkadot/types": "2.8.2-3",
"@polkadot/api": "2.8.2",
"@polkadot/metadata": "2.8.2",
"@polkadot/rpc-provider": "2.8.2",
"@polkadot/types": "2.8.2",
"@polkadot/util": "^4.2.1",
"handlebars": "^4.7.6",
"websocket": "^1.0.32",
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"sideEffects": false,
@@ -17,7 +17,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/types": "2.8.2-3",
"@polkadot/types": "2.8.2",
"@polkadot/util": "^4.2.1",
"bn.js": "^4.11.9"
},
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "2.8.2-3",
"version": "2.8.2",
"description": "Implementation of the Parity codec",
"main": "index.js",
"sideEffects": false,
@@ -17,7 +17,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/metadata": "2.8.2-3",
"@polkadot/metadata": "2.8.2",
"@polkadot/util": "^4.2.1",
"@polkadot/util-crypto": "^4.2.1",
"@types/bn.js": "^4.11.6",
+12 -1
View File
@@ -95,12 +95,23 @@ export class Raw extends Uint8Array implements IU8a {
return this.eq(decodeU8a(other));
}
/**
* @description Create a new slice from the actual buffer. (compat)
* @param start The position to start at
* @param end The position to end at
*/
public slice (start?: number, end?: number): Uint8Array {
// Like subarray below, we have to follow this approach since we are extending the TypeArray.
// This happens especially when it comes to further extensions, the length may be an override
return Uint8Array.from(this).slice(start, end);
}
/**
* @description Create a new subarray from the actual buffer. (compat)
* @param begin The position to start at
* @param end The position to end at
*/
public subarray (begin: number, end?: number): Uint8Array {
public subarray (begin?: number, end?: number): Uint8Array {
return Uint8Array.from(this).subarray(begin, end);
}