mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Object-hash has added new options that weren’t included in previous definitions based on version 0.5.0.
50 lines
925 B
TypeScript
50 lines
925 B
TypeScript
|
|
|
|
import hash = require('object-hash');
|
|
|
|
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 options = {
|
|
algorithm: 'md5',
|
|
encoding: 'utf8',
|
|
excludeValues: true,
|
|
unorderedArrays: true
|
|
};
|
|
|
|
hashed = hash(obj, options);
|
|
|
|
// HashTable
|
|
var table: any;
|
|
table = hash.HashTable();
|
|
table = hash.HashTable(options);
|
|
|
|
table = table.add(obj);
|
|
table = table.add(obj, obj);
|
|
table = table.remove(obj);
|
|
table = table.remove(obj, obj);
|
|
|
|
var has: boolean = table.hasKey('whatEver');
|
|
var value: any = table.getValue('whatEver');
|
|
var count: number = table.getCount('whatEver');
|
|
|
|
var tableObject = table.table();
|
|
tableObject['whatEver'].value;
|
|
tableObject['whatEver'].count;
|
|
|
|
var tableArray = table.toArray();
|
|
tableArray.shift().value;
|
|
tableArray.pop().count;
|
|
tableArray[2].hash;
|
|
|
|
table = table.reset();
|