From d456db2407756f74cf937576829d209cf2e90845 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 26 Nov 2024 14:04:21 -0800 Subject: [PATCH] Use template literals for error messages. --- src/lib/blake2b.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/lib/blake2b.ts b/src/lib/blake2b.ts index 3f040ec..8bec5dc 100644 --- a/src/lib/blake2b.ts +++ b/src/lib/blake2b.ts @@ -230,7 +230,7 @@ function Blake2b (outlen: number, key?: Uint8Array, salt?: Uint8Array, personal? Blake2b.prototype.update = function (input: Uint8Array) { if (!(input instanceof Uint8Array)) - throw new TypeError('input must be Uint8Array or Buffer') + throw new TypeError(`input must be Uint8Array or Buffer`) blake2bUpdate(this, input) return this } @@ -238,9 +238,9 @@ Blake2b.prototype.update = function (input: Uint8Array) { Blake2b.prototype.digest = function (out?: 'binary' | 'hex' | Uint8Array) { var buf = (!out || out === 'binary' || out === 'hex') ? new Uint8Array(this.outlen) : out if (!(buf instanceof Uint8Array)) - throw new TypeError('out must be "binary", "hex", Uint8Array, or Buffer') + throw new TypeError(`out must be "binary", "hex", Uint8Array, or Buffer`) if (buf.length < this.outlen) - throw new RangeError('out must have at least outlen bytes of space') + throw new RangeError(`out must have at least outlen bytes of space`) blake2bFinal(this, buf) if (out === 'hex') return hexSlice(buf) return buf @@ -296,28 +296,28 @@ var Proto = Blake2b export default function createHash (outlen: number, key?: Uint8Array, salt?: Uint8Array, personal?: Uint8Array, noAssert?: boolean) { if (noAssert !== true) { if (outlen < BYTES_MIN) - throw new RangeError('outlen must be at least ' + BYTES_MIN + ', was given ' + outlen) + throw new RangeError(`outlen must be at least ${BYTES_MIN}, was given ${outlen}`) if (outlen > BYTES_MAX) - throw new RangeError('outlen must be at most ' + BYTES_MAX + ', was given ' + outlen) + throw new RangeError(`outlen must be at most ${BYTES_MAX}, was given ${outlen}`) if (key != null) { if (!(key instanceof Uint8Array)) - throw new TypeError('key must be Uint8Array or Buffer') + throw new TypeError(`key must be Uint8Array or Buffer`) if (key.length < KEYBYTES_MIN) - throw new RangeError('key must be at least ' + KEYBYTES_MIN + ', was given ' + key.length) + throw new RangeError(`key must be at least ${KEYBYTES_MIN}, was given ${key.length}`) if (key.length > KEYBYTES_MAX) - throw new RangeError('key must be at most ' + KEYBYTES_MAX + ', was given ' + key.length) + throw new RangeError(`key must be at most ${KEYBYTES_MAX}, was given ${key.length}`) } if (salt != null) { if (!(salt instanceof Uint8Array)) - throw new TypeError('salt must be Uint8Array or Buffer') + throw new TypeError(`salt must be Uint8Array or Buffer`) if (salt.length !== SALTBYTES) - throw new RangeError('salt must be exactly ' + SALTBYTES + ', was given ' + salt.length) + throw new RangeError(`salt must be exactly ${SALTBYTES}, was given ${salt.length}`) } if (personal != null) { if (!(personal instanceof Uint8Array)) - throw new TypeError('personal must be Uint8Array or Buffer') + throw new TypeError(`personal must be Uint8Array or Buffer`) if (personal.length !== PERSONALBYTES) - throw new RangeError('personal must be exactly ' + PERSONALBYTES + ', was given ' + personal.length) + throw new RangeError(`personal must be exactly ${PERSONALBYTES}, was given ${personal.length}`) } } -- 2.34.1