mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-08 03:00:02 +00:00
Merge pull request #17933 from bastienmoulia/spark-md5
[spark-md5] Add types
This commit is contained in:
42
types/spark-md5/index.d.ts
vendored
Normal file
42
types/spark-md5/index.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Type definitions for spark-md5 3.0
|
||||
// Project: https://github.com/satazor/js-spark-md5#readme
|
||||
// Definitions by: Bastien Moulia <https://github.com/bastienmoulia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
interface State {
|
||||
buff: Uint8Array;
|
||||
length: number;
|
||||
hash: number[];
|
||||
}
|
||||
|
||||
// copy of ArrayBuffer because of a conflict with the class SparkMD5.ArrayBuffer
|
||||
interface ArrayBufferCopy extends ArrayBuffer {}
|
||||
|
||||
declare class SparkMD5 {
|
||||
constructor();
|
||||
append(str: string): SparkMD5;
|
||||
appendBinary(contents: string): SparkMD5;
|
||||
end(raw?: boolean): string;
|
||||
reset(): SparkMD5;
|
||||
getState(): State;
|
||||
setState(state: State): State;
|
||||
destroy(): void;
|
||||
static hash(str: string, raw?: boolean): string;
|
||||
static hashBinary(content: string, raw?: boolean): string;
|
||||
}
|
||||
|
||||
declare namespace SparkMD5 {
|
||||
class ArrayBuffer {
|
||||
constructor();
|
||||
append(str: string): ArrayBuffer;
|
||||
end(raw?: boolean): string;
|
||||
reset(): ArrayBuffer;
|
||||
getState(): State;
|
||||
setState(state: State): State;
|
||||
destroy(): void;
|
||||
static hash(arr: ArrayBufferCopy, raw?: boolean): string;
|
||||
}
|
||||
}
|
||||
|
||||
export = SparkMD5;
|
||||
20
types/spark-md5/spark-md5-tests.ts
Normal file
20
types/spark-md5/spark-md5-tests.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import * as SparkMD5 from "spark-md5";
|
||||
|
||||
SparkMD5.hash('Hi there');
|
||||
SparkMD5.hash('Hi there', true);
|
||||
SparkMD5.hashBinary("");
|
||||
|
||||
let spark = new SparkMD5();
|
||||
spark.append('Hi');
|
||||
spark.append(' there');
|
||||
let hexHash = spark.end();
|
||||
let rawHash = spark.end(true);
|
||||
|
||||
let sparkArr = new SparkMD5.ArrayBuffer();
|
||||
sparkArr.append('Hi');
|
||||
sparkArr.append(' there');
|
||||
hexHash = sparkArr.end();
|
||||
rawHash = sparkArr.end(true);
|
||||
|
||||
const arr = new ArrayBuffer(8);
|
||||
SparkMD5.ArrayBuffer.hash(arr);
|
||||
22
types/spark-md5/tsconfig.json
Normal file
22
types/spark-md5/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"spark-md5-tests.ts"
|
||||
]
|
||||
}
|
||||
6
types/spark-md5/tslint.json
Normal file
6
types/spark-md5/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-empty-interface": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user