mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 15:57:13 +00:00
Add types for sha.js
This commit is contained in:
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
// Type definitions for sha.js 2.4
|
||||
// Project: https://github.com/crypto-browserify/sha.js
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Hash } from 'crypto';
|
||||
|
||||
export = SHA;
|
||||
|
||||
declare function SHA(algorithm: string): Hash;
|
||||
|
||||
declare namespace SHA {
|
||||
type Algorithm = 'sha' | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512';
|
||||
interface HashStatic {
|
||||
new (): Hash;
|
||||
}
|
||||
|
||||
const sha: HashStatic;
|
||||
const sha1: HashStatic;
|
||||
const sha224: HashStatic;
|
||||
const sha256: HashStatic;
|
||||
const sha384: HashStatic;
|
||||
const sha512: HashStatic;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import shajs = require('sha.js');
|
||||
|
||||
shajs('sha256')
|
||||
.update('42')
|
||||
.digest('hex');
|
||||
new shajs.sha().update('42').digest('hex');
|
||||
new shajs.sha1().update('42').digest('hex');
|
||||
new shajs.sha224().update('42').digest('hex');
|
||||
new shajs.sha256().update('42').digest('hex');
|
||||
new shajs.sha384().update('42').digest('hex');
|
||||
new shajs.sha512().update('42').digest('hex');
|
||||
|
||||
const sha256stream = shajs('sha256');
|
||||
sha256stream.end('42');
|
||||
(sha256stream.read() as Buffer).toString('hex');
|
||||
@@ -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",
|
||||
"sha.js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user