add type defintions for correct md5 module (per npm) (#9347)

* add type defintions for correct md5 module (per npm)

* Corrected md5 to CybozuLabs-md5

* added typings for md5 (npm version)
This commit is contained in:
arcdev1
2016-05-21 08:32:51 -07:00
committed by Masahiro Wakame
parent 03fd25f9b0
commit bb7f67e2e1
4 changed files with 64 additions and 15 deletions
+9
View File
@@ -0,0 +1,9 @@
/// <reference path="CybozuLabs-md5.d.ts" />
var hash: string;
hash = CybozuLabs.MD5.calc("abc");
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_ASCII);
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_UTF16);
var version: string;
version = CybozuLabs.MD5.VERSION;
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for CybozuLabs.MD5
// Project: http://labs.cybozu.co.jp/blog/mitsunari/2007/07/md5js_1.html
// Definitions by: MIZUNE Pine <https://github.com/pine613>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace CybozuLabs.MD5 {
var VERSION: string;
var BY_ASCII: number;
var BY_UTF16: number;
function calc(str: string, option?: number): string;
}
+31 -7
View File
@@ -1,9 +1,33 @@
/// <reference path="md5.d.ts" />
/// <reference path="../node/node.d.ts" />
import fs =require("fs");
import md5 = require("md5");
/**
* API
* md5(message)
* message -- String or Buffer
* returns String
*
* Usage
****************************************************
* var md5 = require('md5'); *
* console.log(md5('message')); *
****************************************************
* This will print the following
* 78e731027d8fd50ed642340b7c9a63b3
*
* It supports buffers, too
****************************************************
* var fs = require('fs'); *
* var md5 = require('md5'); *
* *
* fs.readFile('example.txt', function(err, buf) { *
* console.log(md5(buf)); *
* }); *
* **************************************************
*/
console.log(md5('message')); // should print 78e731027d8fd50ed642340b7c9a63b3
var hash: string;
hash = CybozuLabs.MD5.calc("abc");
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_ASCII);
hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_UTF16);
var version: string;
version = CybozuLabs.MD5.VERSION;
fs.readFile('md5.d.ts', function(err: Error, buf: Buffer) {
console.log(md5(buf));
});
+13 -8
View File
@@ -1,11 +1,16 @@
// Type definitions for CybozuLabs.MD5
// Project: http://labs.cybozu.co.jp/blog/mitsunari/2007/07/md5js_1.html
// Definitions by: MIZUNE Pine <https://github.com/pine613>
// Type definitions for md5 v2.1.0
// Project: https://github.com/pvorb/node-md5
// Definitions by: Bill Sourour <https://github.com/arcdev1>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace CybozuLabs.MD5 {
var VERSION: string;
var BY_ASCII: number;
var BY_UTF16: number;
function calc(str: string, option?: number): string;
/// <reference path="../node/node.d.ts" />
declare module 'md5' {
/**
* js function for hashing messages with MD5
*
* @param {(string | Buffer)} message - a string or buffer to hash
* @returns {string} the resultant MD5 hash of the given message
*/
function main(message: string | Buffer): string;
export = main;
}