From 19d322598681132893676203af46d8d2d81d5992 Mon Sep 17 00:00:00 2001 From: Joshua DeVinney Date: Tue, 20 Sep 2016 10:34:41 -0500 Subject: [PATCH 1/3] Typing for uid-safe --- uid-safe/index.d.ts | 19 +++++++++++++++++++ uid-safe/tsconfig.json | 19 +++++++++++++++++++ uid-safe/uid-safe-test.ts | 12 ++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 uid-safe/index.d.ts create mode 100644 uid-safe/tsconfig.json create mode 100644 uid-safe/uid-safe-test.ts diff --git a/uid-safe/index.d.ts b/uid-safe/index.d.ts new file mode 100644 index 0000000000..9892734e1c --- /dev/null +++ b/uid-safe/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for co-body +// Project: https://github.com/crypto-utils/uid-safe +// Definitions by: Joshua DeVinney +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace UID { + + export interface Generate { + + (byteLenth: number, callback: (err: any, str: string) => any): void; + (byteLenth: number): Promise; + (byteLenth: number, callback?: (err: any, str: string) => any): Promise | void; + + sync(byteLength: number): string; + } +} + +declare var UID: UID.Generate; +export = UID; diff --git a/uid-safe/tsconfig.json b/uid-safe/tsconfig.json new file mode 100644 index 0000000000..a0bda21ebe --- /dev/null +++ b/uid-safe/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fs-extra-promise-es6-tests.ts" + ] +} \ No newline at end of file diff --git a/uid-safe/uid-safe-test.ts b/uid-safe/uid-safe-test.ts new file mode 100644 index 0000000000..6af969ce60 --- /dev/null +++ b/uid-safe/uid-safe-test.ts @@ -0,0 +1,12 @@ +import * as uid from 'uid-safe'; + +uid(18, function (err, string) { + if (err) throw err + // do something with the string +}); + +uid(18).then(function (string) { + // do something with the string +}) + +var string = uid.sync(18); From 07fe82cac5529e424c62fc5da8c1502a43ae8a90 Mon Sep 17 00:00:00 2001 From: Joshua DeVinney Date: Tue, 20 Sep 2016 10:49:21 -0500 Subject: [PATCH 2/3] Fixing typos and mistakes in uid-safe typing --- uid-safe/index.d.ts | 7 +++---- uid-safe/tsconfig.json | 2 +- uid-safe/{uid-safe-test.ts => uid-safe-tests.ts} | 0 3 files changed, 4 insertions(+), 5 deletions(-) rename uid-safe/{uid-safe-test.ts => uid-safe-tests.ts} (100%) diff --git a/uid-safe/index.d.ts b/uid-safe/index.d.ts index 9892734e1c..d64c14ad4f 100644 --- a/uid-safe/index.d.ts +++ b/uid-safe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for co-body +// Type definitions for uid-safe // Project: https://github.com/crypto-utils/uid-safe // Definitions by: Joshua DeVinney // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,9 +7,8 @@ declare namespace UID { export interface Generate { - (byteLenth: number, callback: (err: any, str: string) => any): void; - (byteLenth: number): Promise; - (byteLenth: number, callback?: (err: any, str: string) => any): Promise | void; + (byteLength: number, callback: (err: any, str: string) => any): void; + (byteLength: number): Promise; sync(byteLength: number): string; } diff --git a/uid-safe/tsconfig.json b/uid-safe/tsconfig.json index a0bda21ebe..5c29fae11c 100644 --- a/uid-safe/tsconfig.json +++ b/uid-safe/tsconfig.json @@ -14,6 +14,6 @@ }, "files": [ "index.d.ts", - "fs-extra-promise-es6-tests.ts" + "uid-safe-tests.ts" ] } \ No newline at end of file diff --git a/uid-safe/uid-safe-test.ts b/uid-safe/uid-safe-tests.ts similarity index 100% rename from uid-safe/uid-safe-test.ts rename to uid-safe/uid-safe-tests.ts From 38c248d5bc105b8c1f789c23131810fd8702bf6b Mon Sep 17 00:00:00 2001 From: Joshua DeVinney Date: Tue, 20 Sep 2016 11:18:23 -0500 Subject: [PATCH 3/3] Adding uid-safe version number --- uid-safe/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uid-safe/index.d.ts b/uid-safe/index.d.ts index d64c14ad4f..ee7b13491f 100644 --- a/uid-safe/index.d.ts +++ b/uid-safe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for uid-safe +// Type definitions for uid-safe v2.1 // Project: https://github.com/crypto-utils/uid-safe // Definitions by: Joshua DeVinney // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped