DefinitelyTyped/types/object-hash/object-hash-tests.ts
Artur Diniz Adam 5788e4e16c object-hash updated to v1.3.1 (#36071)
* 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
2019-06-11 14:38:14 -07:00

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);