@polkadot/util
Advanced tools
Comparing version 0.19.5 to 0.19.6
@@ -12,3 +12,3 @@ 'use strict'; | ||
@name isHex | ||
@signature isHex (value: string, bitLength: number = -1): boolean | ||
@signature isHex (value: mixed, bitLength: number = -1): boolean | ||
@summary Tests for a hex string. | ||
@@ -26,5 +26,7 @@ @description | ||
// $FlowFixMe for the regex we have a string | ||
var isValidHex = value === '0x' || isString(value) && HEX_REGEX.test(value); | ||
if (isValidHex && bitLength !== -1) { | ||
// $FlowFixMe type is a string as checked above | ||
return value.length === 2 + bitLength / 4; | ||
@@ -31,0 +33,0 @@ } |
{ | ||
"name": "@polkadot/util", | ||
"version": "0.19.5", | ||
"version": "0.19.6", | ||
"description": "A collection of useful utilities for @polkadot", | ||
@@ -32,3 +32,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@polkadot/api-jsonrpc": "^0.9.15" | ||
"@polkadot/api-jsonrpc": "^0.10.2" | ||
}, | ||
@@ -35,0 +35,0 @@ "dependencies": { |
@@ -23,2 +23,3 @@ "use strict"; | ||
var bitLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1; | ||
var atStart = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
@@ -37,5 +38,9 @@ var byteLength = Math.ceil(bitLength / 8); | ||
result.set(value, byteLength - value.length); | ||
if (atStart) { | ||
result.set(value, 0); | ||
} else { | ||
result.set(value, byteLength - value.length); | ||
} | ||
return result; | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
154517
1477