[spark-md5] Export State interface (#40350)

This commit is contained in:
Florian Keller
2019-11-18 13:50:28 -08:00
committed by Sheetal Nandi
parent f149f60a57
commit e192b28544
3 changed files with 35 additions and 30 deletions
+32 -27
View File
@@ -1,42 +1,47 @@
// Type definitions for spark-md5 3.0
// Project: https://github.com/satazor/js-spark-md5#readme
// Definitions by: Bastien Moulia <https://github.com/bastienmoulia>
// Florian Keller <https://github.com/ffflorian>
// 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 {}
type JsArrayBuffer = 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;
constructor();
static hash(str: string, raw?: boolean): string;
static hashBinary(content: string, raw?: boolean): string;
append(str: string): SparkMD5;
appendBinary(contents: string): SparkMD5;
destroy(): void;
end(raw?: boolean): string;
getState(): SparkMD5.State;
reset(): SparkMD5;
setState(state: SparkMD5.State): SparkMD5.State;
}
declare namespace SparkMD5 {
class ArrayBuffer {
constructor();
append(str: ArrayBufferCopy): ArrayBuffer;
end(raw?: boolean): string;
reset(): ArrayBuffer;
getState(): State;
setState(state: State): State;
destroy(): void;
static hash(arr: ArrayBufferCopy, raw?: boolean): string;
}
interface State {
buff: Uint8Array;
hash: number[];
length: number;
}
class ArrayBuffer {
constructor();
static hash(arr: JsArrayBuffer, raw?: boolean): string;
append(str: JsArrayBuffer): ArrayBuffer;
destroy(): void;
end(raw?: boolean): string;
getState(): State;
reset(): ArrayBuffer;
setState(state: State): State;
}
}
export = SparkMD5;
+2 -2
View File
@@ -1,8 +1,8 @@
import SparkMD5 = require("spark-md5");
import SparkMD5 = require('spark-md5');
SparkMD5.hash('Hi there');
SparkMD5.hash('Hi there', true);
SparkMD5.hashBinary("");
SparkMD5.hashBinary('');
const spark = new SparkMD5();
spark.append('Hi');
+1 -1
View File
@@ -20,4 +20,4 @@
"index.d.ts",
"spark-md5-tests.ts"
]
}
}