User template string type for isHex (#1020)

* User template string type for isHex

* isHex/isString combo checks
This commit is contained in:
Jaco
2021-06-22 16:05:14 +02:00
committed by GitHub
parent 7d09f0892a
commit 0ef761e899
5 changed files with 16 additions and 22 deletions
+3 -3
View File
@@ -27,10 +27,10 @@ import { stringToU8a } from '../string/toU8a';
export function u8aToU8a (value?: number[] | Buffer | Uint8Array | string | null): Uint8Array {
if (!value) {
return new Uint8Array();
} else if (isHex(value)) {
return hexToU8a(value);
} else if (isString(value)) {
return isHex(value)
? hexToU8a(value)
: stringToU8a(value);
return stringToU8a(value);
} else if (Array.isArray(value) || isBuffer(value)) {
return new Uint8Array(value);
}