From 48658b669942906e8f5d495e25c380700b1da894 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Fri, 14 Jul 2017 15:40:54 -0400 Subject: [PATCH 1/2] Add support for v5 of node-uuid --- types/uuid/index.d.ts | 8 ++++++-- types/uuid/interfaces.d.ts | 9 +++++++++ types/uuid/tsconfig.json | 1 + types/uuid/uuid-tests.ts | 7 +++++++ types/uuid/v5.d.ts | 5 +++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 types/uuid/v5.d.ts diff --git a/types/uuid/index.d.ts b/types/uuid/index.d.ts index cc16cc830d..80122eaf5e 100644 --- a/types/uuid/index.d.ts +++ b/types/uuid/index.d.ts @@ -1,10 +1,14 @@ -// Type definitions for uuid 3.0 -// Project: https://github.com/defunctzombie/node-uuid +// Type definitions for uuid 3.4 +// Project: https://github.com/kelektiv/node-uuid // Definitions by: Oliver Hoffmann // Felipe Ochoa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +// The version number has been artificially set to 3.4, instead of 3.0, +// because of the existing uuid-js npm types package being at 3.3.28, +// meaning that `npm install @types/uuid` was installing the typings for uuid-js, not this + import { v1, v4 } from './interfaces'; interface UuidStatic { diff --git a/types/uuid/interfaces.d.ts b/types/uuid/interfaces.d.ts index 65ff0d4819..a5a6484f26 100644 --- a/types/uuid/interfaces.d.ts +++ b/types/uuid/interfaces.d.ts @@ -1,3 +1,8 @@ +// Type definitions for uuid 3.1 +// Project: // Project: https://github.com/kelektiv/node-uuid +// Definitions by: Oliver Hoffmann , Chris Barth +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + /// // Uses ArrayLike to admit Unit8 and co. @@ -19,3 +24,7 @@ export type v1 = v1String & v1Buffer; export type v4String = (options?: V4Options) => string; export type v4Buffer = (options: V4Options | null | undefined, buffer: T, offset?: number) => T; export type v4 = v4String & v4Buffer; + +export type v5String = (name: string | number[], namespace: string | number[]) => string; +export type v5Buffer = (name: string | number[], namespace: string | number[], buffer: T, offset?: number) => T; +export type v5 = v5String & v5Buffer; diff --git a/types/uuid/tsconfig.json b/types/uuid/tsconfig.json index 688d9add4b..52caac62b6 100644 --- a/types/uuid/tsconfig.json +++ b/types/uuid/tsconfig.json @@ -21,6 +21,7 @@ "index.d.ts", "v1.d.ts", "v4.d.ts", + "v5.d.ts", "interfaces.d.ts", "uuid-tests.ts" ] diff --git a/types/uuid/uuid-tests.ts b/types/uuid/uuid-tests.ts index 73dedec6c5..ec69275db9 100644 --- a/types/uuid/uuid-tests.ts +++ b/types/uuid/uuid-tests.ts @@ -1,6 +1,7 @@ import uuid = require('uuid'); import v1 = require('uuid/v1'); import v4 = require('uuid/v4'); +import v5 = require('uuid/v5'); let uuidv1: string = uuid.v1(); @@ -41,3 +42,9 @@ bufferv4 = uuid(undefined, bufferv4); bufferv4 = uuid(null, bufferv4, 16); bufferv4 = v4(null, bufferv4); bufferv4 = v4(undefined, bufferv4, 16); + +const MY_NAMESPACE = v4(); +const a: string = v5('hello', MY_NAMESPACE); +const b: string = v5('world', MY_NAMESPACE); +const c: Buffer = v5('world', MY_NAMESPACE, new Buffer(16)); +const d: number[] = v5('world', MY_NAMESPACE, [], 0); diff --git a/types/uuid/v5.d.ts b/types/uuid/v5.d.ts new file mode 100644 index 0000000000..67b8c8d051 --- /dev/null +++ b/types/uuid/v5.d.ts @@ -0,0 +1,5 @@ +import { v5 } from './interfaces'; + +declare const v5: v5; + +export = v5; From e5eba44aea3aee084e05b2c41034430a33dfb33f Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Fri, 14 Jul 2017 15:52:08 -0400 Subject: [PATCH 2/2] Linting --- types/uuid/index.d.ts | 1 + types/uuid/interfaces.d.ts | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/types/uuid/index.d.ts b/types/uuid/index.d.ts index 80122eaf5e..a979b989fd 100644 --- a/types/uuid/index.d.ts +++ b/types/uuid/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/kelektiv/node-uuid // Definitions by: Oliver Hoffmann // Felipe Ochoa +// Chris Barth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 diff --git a/types/uuid/interfaces.d.ts b/types/uuid/interfaces.d.ts index a5a6484f26..28a13fc3fa 100644 --- a/types/uuid/interfaces.d.ts +++ b/types/uuid/interfaces.d.ts @@ -1,8 +1,3 @@ -// Type definitions for uuid 3.1 -// Project: // Project: https://github.com/kelektiv/node-uuid -// Definitions by: Oliver Hoffmann , Chris Barth -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - /// // Uses ArrayLike to admit Unit8 and co.