From 6dc732cd0e251379bf5533bb78869b4ece75508a Mon Sep 17 00:00:00 2001 From: Jeff May Date: Sun, 20 Apr 2014 00:12:00 -0400 Subject: [PATCH 1/2] Added node-uuid and tests --- node-uuid/node-uuid.d.ts | 49 ++++++++++++++++++++++++++++++++++++ node-uuid/node-uuid.tests.ts | 22 ++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 node-uuid/node-uuid.d.ts create mode 100644 node-uuid/node-uuid.tests.ts diff --git a/node-uuid/node-uuid.d.ts b/node-uuid/node-uuid.d.ts new file mode 100644 index 000000000..8c287bb2e --- /dev/null +++ b/node-uuid/node-uuid.d.ts @@ -0,0 +1,49 @@ +// Type definitions for node-uuid.js +// Project: https://github.com/broofa/node-uuid +// Definitions by: Jeff May +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface UUIDOptions { + + /** + * Node id as Array of 6 bytes (per 4.1.6). + * Default: Randomly generated ID. See note 1. + */ + node: any[] + + /** + * (Number between 0 - 0x3fff) RFC clock sequence. + * Default: An internally maintained clockseq is used. + */ + clockseq: number + + /** + * (Number | Date) Time in milliseconds since unix Epoch. + * Default: The current time is used. + */ + msecs: any + + /** + * (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if msecs is unspecified. + * Default: internal uuid counter is used, as per 4.2.1.2. + */ + nsecs: number +} + +interface UUID { + v1(options?: UUIDOptions, buffer?: number[], offset?: number): string + v1(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + + v2(options?: UUIDOptions, buffer?: number[], offset?: number): string + v2(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + + v3(options?: UUIDOptions, buffer?: number[], offset?: number): string + v3(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + + v4(options?: UUIDOptions, buffer?: number[], offset?: number): string + v4(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string +} + +declare var uuid: UUID; diff --git a/node-uuid/node-uuid.tests.ts b/node-uuid/node-uuid.tests.ts new file mode 100644 index 000000000..6e1d7bd8c --- /dev/null +++ b/node-uuid/node-uuid.tests.ts @@ -0,0 +1,22 @@ +/// + +var uid1: string = uuid.v1() +var uid2: string = uuid.v2() +var uid3: string = uuid.v3() +var uid4: string = uuid.v4() + +var options: UUIDOptions = { + node: [], + clockseq: 2, + nsecs: 3, + msecs: new Date() +} + +var padding: number[] = [0, 1, 2] + +var offset: number = 15 + +uuid.v1(options, padding, offset) +uuid.v2(options, padding, offset) +uuid.v3(options, padding, offset) +uuid.v4(options, padding, offset) From f4d822a03e20f93022648be6cc1e3bc9dcc39354 Mon Sep 17 00:00:00 2001 From: Jeff May Date: Tue, 22 Apr 2014 11:47:50 -0400 Subject: [PATCH 2/2] Added node-uuid to README.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061c..88263116e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -207,6 +207,7 @@ All definitions files include a header with the author and editors, so at some p * [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) +* [node-uuid](https://github.com/broofa/node-uuid) (by [Jeff May](https://github.com/jeffmay)) * [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker)) * [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/))