From 7833915696107059071fd67d8f68a0b9d5db0591 Mon Sep 17 00:00:00 2001 From: Daniel Byrne Date: Tue, 28 Aug 2018 18:31:02 -0700 Subject: [PATCH] adds typings for the 'scrypt-js' package --- types/scrypt-js/index.d.ts | 22 ++++++++++++++++++++++ types/scrypt-js/scrypt-js-tests.ts | 7 +++++++ types/scrypt-js/tsconfig.json | 19 +++++++++++++++++++ types/scrypt-js/tslint.json | 3 +++ 4 files changed, 51 insertions(+) create mode 100644 types/scrypt-js/index.d.ts create mode 100644 types/scrypt-js/scrypt-js-tests.ts create mode 100644 types/scrypt-js/tsconfig.json create mode 100644 types/scrypt-js/tslint.json diff --git a/types/scrypt-js/index.d.ts b/types/scrypt-js/index.d.ts new file mode 100644 index 0000000000..fde3c0a444 --- /dev/null +++ b/types/scrypt-js/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for scrypt-js 2.0 +// Project: https://github.com/ricmoo/scrypt-js +// Definitions by: Daniel Byrne +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare function scrypt( + password: Buffer, + salt: Buffer, + N: number, + r: number, + p: number, + dklen: number, + callback: ( + error: Error | undefined | null, + progress: number, + key?: ReadonlyArray, + ) => void +): void; + +export = scrypt; diff --git a/types/scrypt-js/scrypt-js-tests.ts b/types/scrypt-js/scrypt-js-tests.ts new file mode 100644 index 0000000000..21c77fb16c --- /dev/null +++ b/types/scrypt-js/scrypt-js-tests.ts @@ -0,0 +1,7 @@ +import scrypt = require('scrypt-js'); + +const testBuffer = Buffer.from('test'); +const testCB = (err: Error | undefined | null, progress: number) => {}; + +// $ExpectType void +scrypt(testBuffer, testBuffer, 1, 1, 1, 1, testCB); diff --git a/types/scrypt-js/tsconfig.json b/types/scrypt-js/tsconfig.json new file mode 100644 index 0000000000..8c6c60e736 --- /dev/null +++ b/types/scrypt-js/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "scrypt-js-tests.ts" + ] +} diff --git a/types/scrypt-js/tslint.json b/types/scrypt-js/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/scrypt-js/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}