Merge pull request #14167 from mwmccarthy/master

js-md5 - add ArrayBuffer parameter
This commit is contained in:
Bowden Kelly
2017-02-03 18:31:36 -08:00
committed by GitHub
4 changed files with 57 additions and 50 deletions
+26 -30
View File
@@ -1,36 +1,32 @@
// Type definitions for js-md5 v0.3.0
// Type definitions for js-md5 0.4
// Project: https://github.com/emn178/js-md5
// Definitions by: Roland Greim <https://github.com/tigerxy>
// Definitions by: Michael McCarthy <https://github.com/mwmccarthy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/
/// <reference types="jquery"/>
declare namespace md5 {
type message = string | any[] | Uint8Array | ArrayBuffer;
interface JQuery {
md5(value: string): string;
md5(value: Array<any>): string;
md5(value: Uint8Array): string;
interface Md5 {
array: () => number[];
arrayBuffer: () => ArrayBuffer;
buffer: () => ArrayBuffer;
digest: () => number[];
hex: () => string;
toString: () => string;
update: (message: message) => Md5;
}
interface md5 {
(message: message): string;
hex: (message: message) => string;
array: (message: message) => number[];
digest: (message: message) => number[];
arrayBuffer: (message: message) => ArrayBuffer;
buffer: (message: message) => ArrayBuffer;
create: () => Md5;
update: (message: message) => Md5;
}
}
interface JQueryStatic {
md5(value: string): string;
md5(value: Array<any>): string;
md5(value: Uint8Array): string;
}
interface md5 {
(value: string): string;
(value: Array<any>): string;
(value: Uint8Array): string;
}
interface String {
md5(value: string): string;
md5(value: Array<any>): string;
md5(value: Uint8Array): string;
}
declare module "js-md5" {
export = md5;
}
declare var md5: md5;
declare const md5: md5.md5;
export = md5;
+25 -16
View File
@@ -1,20 +1,29 @@
import md5 = require("js-md5");
let str: string = md5.hex('The quick brown fox jumps over the lazy dog');
str = md5('The quick brown fox jumps over the lazy dog');
let arr: number[] = md5.digest('The quick brown fox jumps over the lazy dog');
arr = md5.array('The quick brown fox jumps over the lazy dog');
let buf: ArrayBuffer = md5.arrayBuffer('The quick brown fox jumps over the lazy dog');
buf = md5.buffer('The quick brown fox jumps over the lazy dog');
md5('Message to hash');
md5('');
md5('中文');
md5([]);
md5(new Uint8Array([]));
const hash1 = md5.create();
hash1.update('The quick brown fox jumps over the lazy dog');
str = hash1.hex();
str = hash1.toString();
arr = hash1.digest();
arr = hash1.array();
buf = hash1.arrayBuffer();
buf = hash1.buffer();
$.md5('message');
$.md5('Message to hash');
$.md5('');
$.md5('中文');
$.md5([]);
$.md5(new Uint8Array([]));
const hash2 = md5.update('The quick brown fox jumps over the lazy dog');
str = hash2.hex();
str = hash2.toString();
arr = hash2.digest();
arr = hash2.array();
buf = hash2.arrayBuffer();
buf = hash2.buffer();
'message'.md5('Message to hash');
'message'.md5('');
'message'.md5('中文');
'message'.md5([]);
'message'.md5(new Uint8Array([]));
str = md5([]);
str = md5(new Uint8Array([]));
str = md5(new ArrayBuffer(0));
+3 -4
View File
@@ -2,12 +2,11 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +19,4 @@
"index.d.ts",
"js-md5-tests.ts"
]
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "../tslint.json"
}