From cb95e528e74d728691e0a14482b5634685553893 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Sat, 21 Jan 2017 19:49:48 -0500 Subject: [PATCH 1/8] Add ArrayBuffer parameter to js-md5 --- js-md5/index.d.ts | 4 ++++ js-md5/js-md5-tests.ts | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 32ef8b30ff..d635a58a6c 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -9,24 +9,28 @@ interface JQuery { md5(value: string): string; md5(value: Array): string; md5(value: Uint8Array): string; + md5(value: ArrayBuffer): string; } interface JQueryStatic { md5(value: string): string; md5(value: Array): string; md5(value: Uint8Array): string; + md5(value: ArrayBuffer): string; } interface md5 { (value: string): string; (value: Array): string; (value: Uint8Array): string; + (value: ArrayBuffer): string; } interface String { md5(value: string): string; md5(value: Array): string; md5(value: Uint8Array): string; + md5(value: ArrayBuffer): string; } declare module "js-md5" { diff --git a/js-md5/js-md5-tests.ts b/js-md5/js-md5-tests.ts index 984a919ec3..77b10c09ce 100644 --- a/js-md5/js-md5-tests.ts +++ b/js-md5/js-md5-tests.ts @@ -5,6 +5,7 @@ md5(''); md5('中文'); md5([]); md5(new Uint8Array([])); +md5(new ArrayBuffer(0)); $.md5('message'); $.md5('Message to hash'); @@ -12,9 +13,11 @@ $.md5(''); $.md5('中文'); $.md5([]); $.md5(new Uint8Array([])); +$.md5(new ArrayBuffer(0)); 'message'.md5('Message to hash'); 'message'.md5(''); 'message'.md5('中文'); 'message'.md5([]); -'message'.md5(new Uint8Array([])); \ No newline at end of file +'message'.md5(new Uint8Array([])); +'message'.md5(new ArrayBuffer(0)); \ No newline at end of file From bccb2cadc334c36fc262838879d51a9646de3627 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Sat, 21 Jan 2017 19:54:19 -0500 Subject: [PATCH 2/8] Add ArrayBuffer parameter to js-md5 --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index d635a58a6c..7292463815 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for js-md5 v0.3.0 // Project: https://github.com/emn178/js-md5 -// Definitions by: Roland Greim +// Definitions by: Roland Greim , Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ /// From f96596fa4efa2156052e8a98f4da302d8918fcac Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Sat, 21 Jan 2017 20:02:09 -0500 Subject: [PATCH 3/8] Increase version number in header --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 7292463815..db202ed628 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-md5 v0.3.0 +// Type definitions for js-md5 v0.3.1 // Project: https://github.com/emn178/js-md5 // Definitions by: Roland Greim , Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ From f81b13123cfe681d066c39835685b730a74154be Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 15:38:11 -0500 Subject: [PATCH 4/8] Rewrite definitions and tests, add tslint. --- js-md5/index.d.ts | 61 +++++++++++++++++++----------------------- js-md5/js-md5-tests.ts | 44 +++++++++++++++++------------- js-md5/tsconfig.json | 7 +++-- js-md5/tslint.json | 3 +++ 4 files changed, 58 insertions(+), 57 deletions(-) create mode 100644 js-md5/tslint.json diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index db202ed628..9f6d7abc09 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,40 +1,33 @@ -// Type definitions for js-md5 v0.3.1 +// Type definitions for js-md5 v0.4.2 // Project: https://github.com/emn178/js-md5 -// Definitions by: Roland Greim , Michael McCarthy +// Definitions by: Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ -/// +declare namespace md5 { + type message = string | any[] | Uint8Array | ArrayBuffer; -interface JQuery { - md5(value: string): string; - md5(value: Array): string; - md5(value: Uint8Array): string; - md5(value: ArrayBuffer): string; + interface Md5 { + array: () => number[]; + arrayBuffer: () => ArrayBuffer; + buffer: () => ArrayBuffer; + digest: () => number[]; + finalize: () => void; + 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): string; - md5(value: Uint8Array): string; - md5(value: ArrayBuffer): string; -} - -interface md5 { - (value: string): string; - (value: Array): string; - (value: Uint8Array): string; - (value: ArrayBuffer): string; -} - -interface String { - md5(value: string): string; - md5(value: Array): string; - md5(value: Uint8Array): string; - md5(value: ArrayBuffer): string; -} - -declare module "js-md5" { - export = md5; -} - -declare var md5: md5; +declare const md5: md5.md5; +export = md5; diff --git a/js-md5/js-md5-tests.ts b/js-md5/js-md5-tests.ts index 77b10c09ce..e77ed82d8e 100644 --- a/js-md5/js-md5-tests.ts +++ b/js-md5/js-md5-tests.ts @@ -1,23 +1,29 @@ +import * as md5 from "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([])); -md5(new ArrayBuffer(0)); +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([])); -$.md5(new ArrayBuffer(0)); +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([])); -'message'.md5(new ArrayBuffer(0)); \ No newline at end of file +str = md5([]); +str = md5(new Uint8Array([])); +str = md5(new ArrayBuffer(0)); diff --git a/js-md5/tsconfig.json b/js-md5/tsconfig.json index eceeb1fb3d..f0ae291e30 100644 --- a/js-md5/tsconfig.json +++ b/js-md5/tsconfig.json @@ -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" ] -} \ No newline at end of file +} diff --git a/js-md5/tslint.json b/js-md5/tslint.json new file mode 100644 index 0000000000..f9e30021f4 --- /dev/null +++ b/js-md5/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From cf15d34bc47ea7a7b4e553ebb749e76e91bf36b7 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 15:44:52 -0500 Subject: [PATCH 5/8] Replace stray tab with spaces --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 9f6d7abc09..f28a3eef80 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -22,7 +22,7 @@ declare namespace md5 { hex: (message: message) => string; array: (message: message) => number[]; digest: (message: message) => number[]; - arrayBuffer: (message: message) => ArrayBuffer; + arrayBuffer: (message: message) => ArrayBuffer; buffer: (message: message) => ArrayBuffer; create: () => Md5; update: (message: message) => Md5; From 0b4f4a2538fcae6fd25fd4c4e99e3b576cbf8746 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 16:09:28 -0500 Subject: [PATCH 6/8] Edit import to use require, fix version number --- js-md5/index.d.ts | 2 +- js-md5/js-md5-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index f28a3eef80..4f1a1b351e 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-md5 v0.4.2 +// Type definitions for js-md5 v0.4 // Project: https://github.com/emn178/js-md5 // Definitions by: Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ diff --git a/js-md5/js-md5-tests.ts b/js-md5/js-md5-tests.ts index e77ed82d8e..231b12ebf2 100644 --- a/js-md5/js-md5-tests.ts +++ b/js-md5/js-md5-tests.ts @@ -1,4 +1,4 @@ -import * as md5 from "js-md5"; +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'); From cfdd4d3496b96711bc9fa2600213a9dd244875a2 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 16:13:11 -0500 Subject: [PATCH 7/8] Remove v from version number --- js-md5/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 4f1a1b351e..41f19fba42 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for js-md5 v0.4 +// Type definitions for js-md5 0.4 // Project: https://github.com/emn178/js-md5 // Definitions by: Michael McCarthy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/ From 82634e7bfbc82d4224e20fc3561fc91b91875672 Mon Sep 17 00:00:00 2001 From: Michael McCarthy Date: Wed, 25 Jan 2017 16:27:38 -0500 Subject: [PATCH 8/8] Remove finalize from Md5 interface --- js-md5/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/js-md5/index.d.ts b/js-md5/index.d.ts index 41f19fba42..690279bbe4 100644 --- a/js-md5/index.d.ts +++ b/js-md5/index.d.ts @@ -11,7 +11,6 @@ declare namespace md5 { arrayBuffer: () => ArrayBuffer; buffer: () => ArrayBuffer; digest: () => number[]; - finalize: () => void; hex: () => string; toString: () => string; update: (message: message) => Md5;