diff --git a/lerna.json b/lerna.json index e8fe4409c..4318c0319 100644 --- a/lerna.json +++ b/lerna.json @@ -10,5 +10,5 @@ "packages": [ "packages/*" ], - "version": "0.19.1" + "version": "0.19.2" } diff --git a/package.json b/package.json index 3fe6b36eb..c79a67bd1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.19.1", + "version": "0.19.2", "private": true, "workspaces": [ "packages/*" diff --git a/packages/util-crypto/package.json b/packages/util-crypto/package.json index d7ee464f8..acb45eab1 100644 --- a/packages/util-crypto/package.json +++ b/packages/util-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-crypto", - "version": "0.19.1", + "version": "0.19.2", "description": "A collection of useful crypto utilities for @polkadot", "main": "index.js", "keywords": [ diff --git a/packages/util-keyring/package.json b/packages/util-keyring/package.json index 714c55bf7..58522643a 100644 --- a/packages/util-keyring/package.json +++ b/packages/util-keyring/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-keyring", - "version": "0.19.1", + "version": "0.19.2", "description": "Keyring management", "main": "index.js", "engines": { @@ -31,8 +31,8 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/util": "^0.19.1", - "@polkadot/util-crypto": "^0.19.1", + "@polkadot/util": "^0.19.2", + "@polkadot/util-crypto": "^0.19.2", "babel-runtime": "^6.26.0" } } diff --git a/packages/util-rlp/package.json b/packages/util-rlp/package.json index 361b30076..fbba737eb 100644 --- a/packages/util-rlp/package.json +++ b/packages/util-rlp/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-rlp", - "version": "0.19.1", + "version": "0.19.2", "description": "RLP encoding and decoding", "main": "index.js", "keywords": [ @@ -29,7 +29,7 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/util": "^0.19.1", + "@polkadot/util": "^0.19.2", "babel-runtime": "^6.26.0" }, "devDependencies": { diff --git a/packages/util-triehash/package.json b/packages/util-triehash/package.json index 03616b508..60eebc757 100644 --- a/packages/util-triehash/package.json +++ b/packages/util-triehash/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-triehash", - "version": "0.19.1", + "version": "0.19.2", "description": "Creation of triehash values", "main": "index.js", "keywords": [ @@ -29,9 +29,9 @@ "test": "echo \"Tests only available from root wrapper\"" }, "dependencies": { - "@polkadot/util": "^0.19.1", - "@polkadot/util-crypto": "^0.19.1", - "@polkadot/util-rlp": "^0.19.1", + "@polkadot/util": "^0.19.2", + "@polkadot/util-crypto": "^0.19.2", + "@polkadot/util-rlp": "^0.19.2", "babel-runtime": "^6.26.0" } } diff --git a/packages/util/docs/u8a.md b/packages/util/docs/u8a.md index 012ee90e4..8c64959d3 100644 --- a/packages/util/docs/u8a.md +++ b/packages/util/docs/u8a.md @@ -12,6 +12,7 @@ Utility methods to convert to and from `Uint8Array` objects - [u8aToBn](#u8atobn) Creates a BN from a Uint8Array object. - [u8aToBuffer](#u8atobuffer) Creates a Buffer object from a hex string. - [u8aToHex](#u8atohex) Creates a hex string from a Uint8Array object. +- [u8aToHexShort](#u8atohexshort) Creates a hex string from a Uint8Array object with max characters. - [u8aToString](#u8atostring) Creates a string from a Uint8Array object. - [u8aToU8a](#u8atou8a) Creates a Uint8Array value from a Uint8Array bignumber or hex input. - [u8aToUtf8](#u8atoutf8) Creates a utf-8 string from a Uint8Array object. @@ -176,6 +177,23 @@ import { u8aToHex } from '@polkadot/util'; u8aToHex(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0xf])); // 0x68656c0f ``` +## u8aToHexShort + +Creates a hex string from a Uint8Array object with max characters. + +```js +u8aToHexShort (value?: UInt8Array, max: number = 16): string +``` + + +`UInt8Array` input values return the actual hex string shortened to the specified characters. `null` or `undefined` values returns an `0x` string. + +```js +import { u8aToHexShort } from '@polkadot/util'; + +u8aToHexShort(new Uint8Array([0x68, 0x65, 0x6c, 0x6c, 0xf]), 4); // 0x68...0f +``` + ## u8aToString Creates a string from a Uint8Array object. diff --git a/packages/util/package.json b/packages/util/package.json index 5fc9777c4..424d774c3 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util", - "version": "0.19.1", + "version": "0.19.2", "description": "A collection of useful utilities for @polkadot", "main": "index.js", "keywords": [