[spark-md5] Add types

This commit is contained in:
Bastien
2017-07-11 12:19:20 +02:00
parent e545c1e19a
commit 99dee20f49
4 changed files with 85 additions and 0 deletions

42
types/spark-md5/index.d.ts vendored Normal file
View File

@@ -0,0 +1,42 @@
// Type definitions for spark-md5 3.0
// Project: https://github.com/satazor/js-spark-md5#readme
// Definitions by: My Self <https://github.com/bastienmoulia>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface State {
buff: Uint8Array;
length: number;
hash: number[];
}
interface IArrayBuffer 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: IArrayBuffer, raw?: boolean): string
}
}
declare module "spark-md5" {
export = SparkMD5;
}

View File

@@ -0,0 +1,20 @@
import * as SparkMD5 from "spark-md5";
SparkMD5.hash('Hi there');
SparkMD5.hash('Hi there', true);
SparkMD5.hashBinary("");
var spark = new SparkMD5();
spark.append('Hi');
spark.append(' there');
var hexHash = spark.end();
var rawHash = spark.end(true);
var sparkArr = new SparkMD5.ArrayBuffer();
sparkArr.append('Hi');
sparkArr.append(' there');
var hexHash = sparkArr.end();
var rawHash = sparkArr.end(true);
const arr = new ArrayBuffer(8);
SparkMD5.ArrayBuffer.hash(arr);

View 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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }