diff --git a/types/uuid/index.d.ts b/types/uuid/index.d.ts index cc16cc830d..a979b989fd 100644 --- a/types/uuid/index.d.ts +++ b/types/uuid/index.d.ts @@ -1,10 +1,15 @@ -// 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 +// Chris Barth // 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..28a13fc3fa 100644 --- a/types/uuid/interfaces.d.ts +++ b/types/uuid/interfaces.d.ts @@ -19,3 +19,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;