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:
Jaco Greeff
2017-11-20 23:04:33 +01:00
committed by GitHub
parent 4ec391e81d
commit 1216968145
38 changed files with 2472 additions and 350 deletions
+12 -1
View File
@@ -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;
}
+3
View File
@@ -4,6 +4,9 @@
const bufferFromHex = require('./fromHex');
const bufferToHex = require('./toHex');
/**
@summary Utility methods to convert to and from `Buffer` objects
*/
module.exports = {
bufferFromHex,
bufferToHex
+12 -1
View File
@@ -6,7 +6,18 @@ const hexAddPrefix = require('../hex/addPrefix');
const ZERO_HEX = '0x';
module.exports = function toHex (value?: Buffer): string {
/**
@name bufferToHex
@signature bufferToHex (value?: Buffer): string
@summary Creates a hex value from a Buffer object.
@description
`null` inputs returns a `0x` result, `Buffer` values return the actual value as a `0x` prefixed hex value. Anything that is not a `Buffer` object throws an error.
@example
import { bufferToHex } from '@polkadot/util';
console.log('Hex value', bufferToHex(Buffer.from([1, 2, 3]));
*/
module.exports = function bufferToHex (value?: Buffer): string {
if (!value) {
return ZERO_HEX;
}