assert cleanups (#957)
This commit is contained in:
@@ -42,7 +42,7 @@ export function compactToU8a (_value: BN | BigInt | number): Uint8Array {
|
||||
length--;
|
||||
}
|
||||
|
||||
assert(length >= 4, 'Previous tests match anyting less than 2^30; qed');
|
||||
assert(length >= 4, 'Invalid length, previous checks match anything less than 2^30');
|
||||
|
||||
return u8aConcat(
|
||||
// subtract 4 as minimum (also catered for in decoding)
|
||||
|
||||
@@ -25,7 +25,7 @@ export function hexToU8a (_value?: string | null, bitLength = -1): Uint8Array {
|
||||
return new Uint8Array();
|
||||
}
|
||||
|
||||
assert(isHex(_value), `Expected hex value to convert, found '${_value}'`);
|
||||
assert(isHex(_value), () => `Expected hex value to convert, found '${_value}'`);
|
||||
|
||||
const value = hexStripPrefix(_value);
|
||||
const valLength = value.length / 2;
|
||||
|
||||
@@ -35,7 +35,7 @@ export function u8aToU8a (value?: number[] | Buffer | Uint8Array | string | null
|
||||
return new Uint8Array(value);
|
||||
}
|
||||
|
||||
assert(isU8a(value), `Unable to convert ${value.toString()} (typeof ${typeof value}) to a Uint8Array`);
|
||||
assert(isU8a(value), () => `Unable to convert ${value.toString()} (typeof ${typeof value}) to a Uint8Array`);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ function getPath (pathOrFn?: FnString | string | false): string {
|
||||
* @summary Checks that a specific package is only imported once
|
||||
*/
|
||||
export function detectPackage ({ name, version }: PackageJson, pathOrFn?: FnString | string | false, deps: PackageJson[] = []): void {
|
||||
assert(name.startsWith('@polkadot'), `Invalid package descriptor ${name}`);
|
||||
assert(name.startsWith('@polkadot'), () => `Invalid package descriptor ${name}`);
|
||||
|
||||
const entry = getEntry(name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user