Split hex into separate components (#7)

This commit is contained in:
Jaco Greeff
2017-11-19 22:48:39 +01:00
committed by GitHub
parent 14234649af
commit 805d7d5fdd
11 changed files with 67 additions and 53 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
// @flow
const isHex = require('../is/hex');
const { stripHexPrefix } = require('../hex');
const hexStripPrefix = require('../hex/stripPrefix');
const EMPTY_BUFFER = Buffer.from([]);
@@ -15,5 +15,5 @@ module.exports = function fromHex (value?: string): Buffer {
throw new Error(`Cannot convert non-hex value '${value}' to Buffer`);
}
return Buffer.from(stripHexPrefix(value), 'hex');
return Buffer.from(hexStripPrefix(value), 'hex');
};
+2 -2
View File
@@ -2,7 +2,7 @@
// @flow
const isBuffer = require('../is/buffer');
const { addHexPrefix } = require('../hex');
const hexAddPrefix = require('../hex/addPrefix');
const ZERO_HEX = '0x';
@@ -15,7 +15,7 @@ module.exports = function toHex (value?: Buffer): string {
throw new Error(`Cannot convert non-buffer to hex`);
}
return addHexPrefix(
return hexAddPrefix(
value.toString('hex')
);
};