scrypt-js: change types of password and salt to accept Array and Uint8Array (#35171)

This commit is contained in:
Romain Delamare 2019-05-13 19:09:38 +02:00 committed by Nathan Shively-Sanders
parent 129ec7b668
commit 02daed3e94
2 changed files with 8 additions and 4 deletions

View File

@ -1,13 +1,14 @@
// Type definitions for scrypt-js 2.0
// Project: https://github.com/ricmoo/scrypt-js
// Definitions by: Daniel Byrne <https://github.com/danwbyrne>
// Romain Delamare <https://github.com/alightgoesout>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types= "node" />
declare function scrypt(
password: Buffer,
salt: Buffer,
password: Buffer | ReadonlyArray<number> | Uint8Array,
salt: Buffer | ReadonlyArray<number> | Uint8Array,
N: number,
r: number,
p: number,

View File

@ -1,7 +1,10 @@
import scrypt = require('scrypt-js');
const testBuffer = Buffer.from('test');
const testArray = [74, 65, 73, 74];
const testUint8Array = Uint8Array.from(testArray);
const testCB = (err: Error | undefined | null, progress: number, key?: ReadonlyArray<number>) => {};
// $ExpectType void
scrypt(testBuffer, testBuffer, 1, 1, 1, 1, testCB);
scrypt(testBuffer, testBuffer, 1, 1, 1, 1, testCB); // $ExpectType void
scrypt(testArray, testArray, 1, 1, 1, 1, testCB); // $ExpectType void
scrypt(testUint8Array, testUint8Array, 1, 1, 1, 1, testCB); // $ExpectType void