Use @polkadot/dev for common tasks (#8)
* Link to docs in README * Use @polkadot/dev for common tasks * 0.5.0 since docs added
This commit is contained in:
+12
-1
@@ -6,7 +6,18 @@ const hexStripPrefix = require('../hex/stripPrefix');
|
||||
|
||||
const EMPTY_BUFFER = Buffer.from([]);
|
||||
|
||||
module.exports = function fromHex (value?: string): Buffer {
|
||||
/**
|
||||
@name bufferFromHex
|
||||
@signature bufferFromHex (value?: string): Buffer
|
||||
@summary Creates a Buffer object from a hex string.
|
||||
@description
|
||||
`null` inputs returns an empty `Buffer` result. Hex input values return the actual bytes value converted to a Buffer. Anything that is not a hex string (including the `0x` prefix) throws an error.
|
||||
@example
|
||||
import { bufferFromHex } from '@polkadot/util';
|
||||
|
||||
console.log('Buffer object', bufferFromHex('0x123480001f'));
|
||||
*/
|
||||
module.exports = function bufferFromHex (value?: string): Buffer {
|
||||
if (!value) {
|
||||
return EMPTY_BUFFER;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user