mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #2071 from jeffmay/node-uuid
Add definition for node-uuid
This commit is contained in:
@@ -214,6 +214,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [nodeunit](https://github.com/caolan/nodeunit) (by [Jeff Goddard](https://github.com/jedigo))
|
||||
* [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/))
|
||||
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// Type definitions for node-uuid.js
|
||||
// Project: https://github.com/broofa/node-uuid
|
||||
// Definitions by: Jeff May <https://github.com/jeffmay>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
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;
|
||||
@@ -0,0 +1,22 @@
|
||||
/// <reference path="node-uuid.d.ts" />
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user