Add bitLength to hexToU8a (#83)

This commit is contained in:
Jaco Greeff
2018-02-12 15:25:54 +01:00
committed by GitHub
parent b0807ced3d
commit c451a85797
3 changed files with 23 additions and 7 deletions
+3 -2
View File
@@ -176,7 +176,7 @@ hexToNumber('0x1234'); // => 0x1234
Creates a Buffer object from a hex string.
```js
hexToU8a (value?: string): Uint8Array
hexToU8a (value?: string, bitLength: number = -1): Uint8Array
```
@@ -185,5 +185,6 @@ hexToU8a (value?: string): Uint8Array
```js
import { hexToU8a } from '@polkadot/util';
hexToU8a('0x123480001f'); // Uint8Array([0x12, 0x34, 0x80, 0x00, 0x1f])
hexToU8a('0x80001f'); // Uint8Array([0x80, 0x00, 0x1f])
hexToU8a('0x80001f', 32); // Uint8Array([0x00, 0x80, 0x00, 0x1f])
```