Hex <-> Uint8Array utils (#69)

This commit is contained in:
Jaco Greeff
2018-01-30 12:36:01 +01:00
committed by GitHub
parent 1ce557fa4a
commit 19e365e2c8
10 changed files with 138 additions and 3 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ const u8aFromBuffer = require('../buffer/toU8a');
/**
@name u8aFromBuffer
@signature u8aFromBuffer (value?: Buffer): number
@signature u8aFromBuffer (value?: Buffer): Uint8Array
@summary Creates a Uint8Array value from a Buffer object.
@alias buffer/toU8a
*/
+14
View File
@@ -0,0 +1,14 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
const u8aFromHex = require('../hex/toU8a');
/**
@name u8aFromHex
@signature u8aFromHex (value?: string): Uint8Array
@summary Creates a Uint8Array value from a hex string.
@alias hex/toU8a
*/
module.exports = u8aFromHex;
+15
View File
@@ -0,0 +1,15 @@
// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
const isFunction = require('../is/function');
const { u8aFromHex } = require('./index');
describe('u8aFromHex', () => {
it('exists as a function', () => {
expect(
isFunction(u8aFromHex)
).toEqual(true);
});
});
+2
View File
@@ -4,6 +4,7 @@
// @flow
const u8aFromBuffer = require('./fromBuffer');
const u8aFromHex = require('./fromHex');
const u8aFromUtf8 = require('./fromUtf8');
const u8aToBuffer = require('./toBuffer');
const u8aToUtf8 = require('./toUtf8');
@@ -13,6 +14,7 @@ const u8aToUtf8 = require('./toUtf8');
*/
module.exports = {
u8aFromBuffer,
u8aFromHex,
u8aFromUtf8,
u8aToBuffer,
u8aToUtf8