diff --git a/types/object-hash/index.d.ts b/types/object-hash/index.d.ts index 4da49c262c..a6f147cd1e 100644 --- a/types/object-hash/index.d.ts +++ b/types/object-hash/index.d.ts @@ -1,8 +1,12 @@ -// Type definitions for object-hash v1.2.0 +// Type definitions for object-hash v1.3.1 // Project: https://github.com/puleos/object-hash -// Definitions by: Michael Zabka +// Definitions by: Michael Zabka , Artur Diniz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +import stream = require("stream"); + import HashStatic = ObjectHash.HashStatic; export = HashStatic; export as namespace objectHash; @@ -15,43 +19,22 @@ declare namespace ObjectHash { ignoreUnknown?: boolean; replacer?: (value: any) => any; respectFunctionProperties?: boolean; - respectFunctionNames?: boolean; + respectFunctionNames?: boolean; + respectType?: boolean; unorderedArrays?: boolean; - unorderedSets?: boolean; + unorderedSets?: boolean; + unorderedObjects?: boolean; excludeKeys?: (key: string) => boolean; } - interface HashTableItem { - value: any; - count: number; - } - - interface HashTableItemWithKey extends HashTableItem { - hash: string; - } - - export interface HashTable { - add(...values: any[]): HashTable; - remove(...values: any[]): HashTable; - hasKey(key: string): boolean; - getValue(key: string): any; - getCount(key: string): number; - table(): { [key: string]: HashTableItem }; - toArray(): HashTableItemWithKey[]; - reset(): HashTable; - } - - export interface HashTableStatic { - (options?: IOptions): HashTable; - } - export interface Hash { (object: any, options?: IOptions): string; sha1(object: any): string; keys(object: any): string; MD5(object: any): string; keysMD5(object: any): string; - HashTable: HashTableStatic; + writeToStream(value: any, stream: stream.PassThrough): void; + writeToStream(value: any, options: IOptions, stream: stream.PassThrough): void; } export var HashStatic: Hash; diff --git a/types/object-hash/object-hash-tests.ts b/types/object-hash/object-hash-tests.ts index 24e8f05fcb..0a20d28a08 100644 --- a/types/object-hash/object-hash-tests.ts +++ b/types/object-hash/object-hash-tests.ts @@ -1,6 +1,5 @@ - - import hash = require('object-hash'); +import stream = require('stream') var hashed: string; @@ -14,6 +13,10 @@ 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', @@ -22,28 +25,3 @@ var options = { }; 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();