diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d3bd86c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[{*.json,*.yml}] +indent_style = space diff --git a/README.md b/README.md index d6d33ea..e3f0ff1 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,5 @@ In general, updates here should have corrsponding PRs on the DefinitelyTyped rep This following libraries are currently included. Where possible add the relevant DT PRs as there are included - may not be applicable initially if definitions are not expansive enough or fully tested internally. +- [blakejs](https://github.com/dcposch/blakejs) - [bn.js](https://github.com/indutny/bn.js/) [@types PR #26717](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26717) diff --git a/blakejs/blakejs-tests.ts b/blakejs/blakejs-tests.ts new file mode 100644 index 0000000..493cb20 --- /dev/null +++ b/blakejs/blakejs-tests.ts @@ -0,0 +1,4 @@ +import blake = require('blakejs'); + +blake.blake2bHex(new Uint8Array([1, 2, 3, 4, 5])); +blake.blake2sHex(Buffer.from([1, 2, 3, 4, 5])); diff --git a/blakejs/index.d.ts b/blakejs/index.d.ts new file mode 100644 index 0000000..3ecc9b4 --- /dev/null +++ b/blakejs/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for blakejs 1.1.0 +// Project: https://github.com/dcposch/blakejs +// Definitions by: Jaco Greeff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +type BlakeJsContext = { + b: Uint8Array, + h: Uint32Array, + t: number, + c: number, + outlen: number +}; + +type blakejs = { + blake2b: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => Uint8Array, + blake2bFinal: (context: BlakeJsContext) => Uint8Array, + blake2bHex: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => string, + blake2bInit: (outlen?: number, key?: Uint8Array) => BlakeJsContext, + blake2bUpdate: (context: BlakeJsContext, data: Buffer | Uint8Array | string) => void, + blake2s: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => Uint8Array, + blake2sFinal: (context: BlakeJsContext) => Uint8Array, + blake2sHex: (data: Buffer | Uint8Array | string, key?: Uint8Array | null, outlen?: number) => string, + blake2sInit: (outlen?: number, key?: Uint8Array) => BlakeJsContext, + blake2sUpdate: (context: BlakeJsContext, data: Buffer | Uint8Array | string) => void +}; + +export = blakejs; diff --git a/blakejs/tsconfig.json b/blakejs/tsconfig.json new file mode 100644 index 0000000..932e246 --- /dev/null +++ b/blakejs/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "bn.js-tests.ts"] +} diff --git a/blakejs/tslint.json b/blakejs/tslint.json new file mode 100644 index 0000000..3db14f8 --- /dev/null +++ b/blakejs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }