Add types for sha.js

This commit is contained in:
Dimitri Benin
2018-11-26 21:41:06 +01:00
parent 3fd74d83b5
commit afe5664ded
4 changed files with 65 additions and 0 deletions
+26
View File
@@ -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;
}
+15
View File
@@ -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');
+23
View 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",
"sha.js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }