mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add typings for sha256
This commit is contained in:
parent
adf4e18eef
commit
b5e6c7c8a8
23
types/sha256/index.d.ts
vendored
Normal file
23
types/sha256/index.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// Type definitions for sha256 0.2
|
||||
// Project: https://github.com/cryptocoinjs/sha256
|
||||
// Definitions by: Nathan Hardy <https://github.com/nhardy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
type Message = string | Buffer | number[];
|
||||
|
||||
interface Sha256 {
|
||||
(message: Message, options?: { asString: true }): string;
|
||||
(message: Message, options: { asBytes: true }): number[];
|
||||
}
|
||||
|
||||
interface Sha256WithX2 extends Sha256 {
|
||||
x2: Sha256;
|
||||
}
|
||||
|
||||
declare const sha256: Sha256WithX2;
|
||||
|
||||
export = sha256;
|
||||
|
||||
export as namespace sha256;
|
||||
10
types/sha256/sha256-tests.ts
Normal file
10
types/sha256/sha256-tests.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import sha256 = require("sha256");
|
||||
|
||||
const test1: string = sha256('message');
|
||||
const test2: number[] = sha256('message', { asBytes: true });
|
||||
const test3: string = sha256('message', { asString: true });
|
||||
const test4: string = sha256(Buffer.from('message'));
|
||||
const test5: string = sha256(Array.from(Buffer.from('message')));
|
||||
const test6: string = sha256.x2('message');
|
||||
const test7: number[] = sha256.x2('message', { asBytes: true });
|
||||
const test8: string = sha256.x2('message', { asString: true });
|
||||
23
types/sha256/tsconfig.json
Normal file
23
types/sha256/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"sha256-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/sha256/tslint.json
Normal file
1
types/sha256/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user