mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
feat(node-md5): minor change to support options (#43618)
- version bump to 2.2 - creation time options support https://github.com/pvorb/node-md5/blob/master/md5.js#L150 - minor changes to rebrush package definition. Thanks!
This commit is contained in:
parent
c9f8669862
commit
d92f6a5650
Vendored
+15
-6
@@ -1,6 +1,8 @@
|
||||
// Type definitions for md5 v2.1.0
|
||||
// Type definitions for md5 2.2
|
||||
// Project: https://github.com/pvorb/node-md5
|
||||
// Definitions by: Bill Sourour <https://github.com/arcdev1>, Cameron Crothers <https://github.com/jprogrammer>
|
||||
// Definitions by: Bill Sourour <https://github.com/arcdev1>
|
||||
// Cameron Crothers <https://github.com/jprogrammer>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -8,11 +10,18 @@
|
||||
/**
|
||||
* 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
|
||||
* @param message - a string or buffer to hash
|
||||
* @param options
|
||||
* @returns the resultant MD5 hash of the given message
|
||||
*/
|
||||
declare function md5(message: string | Buffer | Array<number>): string;
|
||||
declare function md5(message: string | Buffer | number[], options?: md5.Options): string;
|
||||
|
||||
declare namespace md5 {}
|
||||
declare namespace md5 {
|
||||
interface Options {
|
||||
asBytes?: boolean;
|
||||
asString?: boolean;
|
||||
encoding?: 'binary' | string;
|
||||
}
|
||||
}
|
||||
|
||||
export = md5;
|
||||
|
||||
+8
-29
@@ -1,34 +1,13 @@
|
||||
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)); *
|
||||
* }); *
|
||||
* **************************************************
|
||||
*/
|
||||
const message = 'message';
|
||||
import md5 = require('md5');
|
||||
|
||||
const message = 'message';
|
||||
console.log(md5(message)); // should print 78e731027d8fd50ed642340b7c9a63b3
|
||||
|
||||
const array = new Array<number>(message.length);
|
||||
for (let i = 0; i < message.length; ++i)
|
||||
array[i] = message.charCodeAt(i);
|
||||
for (let i = 0; i < message.length; ++i) array[i] = message.charCodeAt(i);
|
||||
const buffer = new Buffer(array);
|
||||
console.log(md5(buffer)); // Should be same result as above.
|
||||
console.log(md5(buffer)); // Should be same result as above.
|
||||
|
||||
const hash1 = md5('abc', { asString: true });
|
||||
const hash2 = md5(hash1 + 'a', { asString: true, encoding: 'binary' });
|
||||
const hash3 = md5(hash1 + 'a', { encoding: 'binary' });
|
||||
|
||||
+1
-12
@@ -1,12 +1 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"array-type": false,
|
||||
"callable-types": false,
|
||||
"dt-header": false,
|
||||
"jsdoc-format": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"prefer-method-signature": false
|
||||
}
|
||||
}
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
|
||||
Reference in New Issue
Block a user