diff --git a/types/hat/hat-tests.ts b/types/hat/hat-tests.ts new file mode 100644 index 0000000000..1b91702742 --- /dev/null +++ b/types/hat/hat-tests.ts @@ -0,0 +1,10 @@ +import * as hat from 'hat'; + +const randomId = hat(); + +const rack = hat.rack(); +rack('car'); +const tractorId = rack('tractor'); +rack.get(tractorId); +rack.set(randomId, 'bicycle'); +rack.hats; diff --git a/types/hat/index.d.ts b/types/hat/index.d.ts new file mode 100644 index 0000000000..58a7bdc983 --- /dev/null +++ b/types/hat/index.d.ts @@ -0,0 +1,28 @@ +// Type definitions for hat 0.0 +// Project: https://github.com/substack/node-hat +// Definitions by: Sasha Grin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface HatsList { + [key: string]: any; +} + +interface Rack { + bits: number; + base: number; + hats: HatsList; + + (data: any): string; + get(id: string): any; + set(id: string, value: any): Rack; +} + +type CreateRack = (bits?: number, base?: number, expandBy?: number) => Rack; + +interface Hat { + (bits?: number, base?: number): string; + rack: CreateRack; +} + +declare const hat: Hat; +export = hat; diff --git a/types/hat/tsconfig.json b/types/hat/tsconfig.json new file mode 100644 index 0000000000..c13e03fd48 --- /dev/null +++ b/types/hat/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es5" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hat-tests.ts" + ] +} diff --git a/types/hat/tslint.json b/types/hat/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hat/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }