mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Add type for hash-it (#37593)
This commit is contained in:
committed by
Pranav Senthilnathan
parent
174e62ee37
commit
c50af0ccba
@@ -0,0 +1,39 @@
|
||||
/// tests originate from https://github.com/planttheidea/hash-it
|
||||
|
||||
import hash from "hash-it";
|
||||
|
||||
const foo = { foo: "bar"};
|
||||
const alsoFoo = {foo: "bar"};
|
||||
const stillFoo = { foo: "bar"};
|
||||
|
||||
hash(foo);
|
||||
|
||||
hash.is(null, 123);
|
||||
hash.is(null, null);
|
||||
|
||||
const isNull = hash.is(null);
|
||||
isNull(123);
|
||||
isNull(null);
|
||||
|
||||
hash.is.all(foo, alsoFoo, stillFoo);
|
||||
|
||||
const isAllFoo = hash.is.all(foo);
|
||||
isAllFoo(alsoFoo, stillFoo);
|
||||
|
||||
const nopeBar = {
|
||||
bar: "baz"
|
||||
};
|
||||
|
||||
hash.is.any(foo, alsoFoo);
|
||||
hash.is.any(foo, nopeBar);
|
||||
hash.is.any(foo, alsoFoo, nopeBar);
|
||||
|
||||
const isAnyFoo = hash.is.any(foo);
|
||||
isAnyFoo(alsoFoo, nopeBar);
|
||||
|
||||
hash.is.not(null, 123);
|
||||
hash.is.not(null, null);
|
||||
|
||||
const isNotNull = hash.is.not(null);
|
||||
isNotNull(123);
|
||||
isNotNull(null);
|
||||
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
// Type definitions for hash-it 4.0
|
||||
// Project: https://github.com/planttheidea/hash-it
|
||||
// Definitions by: Eric Gonzalez <https://github.com/lochiego>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// Documentation based on: https://github.com/planttheidea/hash-it
|
||||
|
||||
export default hash;
|
||||
|
||||
/**
|
||||
* hash the value passed to a unique, consistent hash value
|
||||
*
|
||||
* @param value the value to hash
|
||||
* @returns the object hash
|
||||
*/
|
||||
export function hash(object: any): number;
|
||||
|
||||
export namespace hash {
|
||||
/**
|
||||
* create a comparator for the object passed to determine if a second is equal
|
||||
*
|
||||
* @param object the object to test against
|
||||
* @returns the method to test against the object
|
||||
*/
|
||||
function is(object: any): (anotherObject: any) => boolean;
|
||||
|
||||
/**
|
||||
* create a comparator for the first object passed to determine if the second is equal
|
||||
*
|
||||
* @param object the object to test against
|
||||
* @param anotherObject the object to compare
|
||||
* @returns are the objects equal
|
||||
*/
|
||||
function is(object: any, anotherObject: any): boolean;
|
||||
|
||||
namespace is {
|
||||
type Comparator = (...objects: any[]) => boolean;
|
||||
|
||||
/**
|
||||
* create a comparator to determine if all of the objects passed are equal in value to the initial
|
||||
*
|
||||
* @param object the object to test for equality
|
||||
* @returns comparator function that checks if all objects equal the initial
|
||||
*/
|
||||
function all(object: any): Comparator;
|
||||
|
||||
/**
|
||||
* determine if all of the objects passed are equal in value to the first
|
||||
*
|
||||
* @param object the object to test for equality against
|
||||
* @param objects the objects to test for equality
|
||||
* @returns are the objects equal
|
||||
*/
|
||||
function all(object: any, ...objects: any[]): boolean;
|
||||
|
||||
/**
|
||||
* create a comparator to determine if any objects are equal in value to the initial
|
||||
*
|
||||
* @param object the object to test for equality
|
||||
* @returns comparator function that checks if all the objects equal the initial
|
||||
*/
|
||||
function any(object: any): Comparator;
|
||||
|
||||
/**
|
||||
* determine if any of the objects passed are equal in value to the first
|
||||
*
|
||||
* @param object the object to test for equality against
|
||||
* @param objects the objects to test for equality
|
||||
* @returns are the objects equal
|
||||
*/
|
||||
function any(object: any, ...args: any[]): boolean;
|
||||
|
||||
/**
|
||||
* create a comparator for the first object passed to determine if a second is not equal
|
||||
*
|
||||
* @param object the object to test against
|
||||
* @returns the method to test against the object
|
||||
*/
|
||||
function not(object: any): Comparator;
|
||||
|
||||
/**
|
||||
* determine if all of the objects passed are not equal in value to the first
|
||||
*
|
||||
* @param object the object to test against
|
||||
* @param objects the objects to compare
|
||||
* @returns are all the objects different from the first
|
||||
*/
|
||||
function not(object: any, ...objects: any[]): boolean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"hash-it-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user