mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Drop hashtable impl from object-hash as of v1.0 * Adding writeToStream method in object-hash * Addin missing options in object-hash * Bumping version and "Definitions by" headers
28 lines
532 B
TypeScript
28 lines
532 B
TypeScript
import hash = require('object-hash');
|
|
import stream = require('stream')
|
|
|
|
var hashed: string;
|
|
|
|
var obj = { any: true };
|
|
|
|
// hash object
|
|
hashed = hash(obj);
|
|
|
|
hashed = hash.sha1(obj);
|
|
hashed = hash.keys(obj);
|
|
hashed = hash.MD5(obj);
|
|
hashed = hash.keysMD5(obj);
|
|
|
|
var passThroughStream = new stream.PassThrough();
|
|
hash.writeToStream(obj, passThroughStream);
|
|
hashed = passThroughStream.read().toString();
|
|
|
|
var options = {
|
|
algorithm: 'md5',
|
|
encoding: 'utf8',
|
|
excludeValues: true,
|
|
unorderedArrays: true
|
|
};
|
|
|
|
hashed = hash(obj, options);
|