{"id":13525776,"url":"https://github.com/rse/pure-uuid","last_synced_at":"2025-04-09T11:10:37.052Z","repository":{"id":26794102,"uuid":"30252504","full_name":"rse/pure-uuid","owner":"rse","description":"Pure JavaScript Based Universally Unique Identifiers (UUID)","archived":false,"fork":false,"pushed_at":"2023-09-04T11:53:46.000Z","size":191,"stargazers_count":67,"open_issues_count":4,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T09:07:58.356Z","etag":null,"topics":["identifier","javascript","unique","uuid"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pure-uuid","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-02-03T16:32:29.000Z","updated_at":"2024-12-22T03:54:44.000Z","dependencies_parsed_at":"2024-01-13T22:55:22.958Z","dependency_job_id":"effb2238-ef01-4282-a88f-b96d9936daea","html_url":"https://github.com/rse/pure-uuid","commit_stats":{"total_commits":159,"total_committers":7,"mean_commits":"22.714285714285715","dds":0.04402515723270439,"last_synced_commit":"a3074a8e0611e43d7ad0ca3f266e7945676dacdb"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fpure-uuid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fpure-uuid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fpure-uuid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rse%2Fpure-uuid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rse","download_url":"https://codeload.github.com/rse/pure-uuid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027407,"owners_count":21035594,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["identifier","javascript","unique","uuid"],"created_at":"2024-08-01T06:01:21.997Z","updated_at":"2025-04-09T11:10:37.032Z","avatar_url":"https://github.com/rse.png","language":"JavaScript","funding_links":[],"categories":["Repository"],"sub_categories":["Text/String"],"readme":"\nPure-UUID\n=========\n\n**Pure JavaScript Based Universally Unique Identifier (UUID)**\n\n\u003cp/\u003e\n\u003cimg src=\"https://nodei.co/npm/pure-uuid.png?downloads=true\u0026stars=true\" alt=\"\"/\u003e\n\n\u003cp/\u003e\n\u003cimg src=\"https://david-dm.org/rse/pure-uuid.png\" alt=\"\"/\u003e\n\nAbstract\n--------\n\nThis is a pure JavaScript and dependency-free library for the generation\nof DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122 compliant Universally\nUnique Identifier (UUID). It supports DCE 1.1 variant UUIDs of version\n1 (time and node based), version 3 (name based, MD5), version 4 (random\nnumber based) and version 5 (name based, SHA-1). It can be used in both\n[Node.js](http://nodejs.org/) based server and browser based client\nenvironments.\n\nThe essential points of this implementation (in contrast to the many\nothers) are: First, although internally 32/64 bit unsigned integer\narithmentic and MD5/SHA-1 digest algorithmic is required, this UUID\nimplementation is fully self-contained and dependency-free. Second,\nthis implementation wraps around either `Uint8Array`, `Buffer` or\n`Array` standard classes and this way tries to represent UUIDs as best\nas possible in the particular environment. Third, thanks to a Universal\nModule Definition (UMD) wrapper, this library works out-of-the-box in\nall important JavaScript run-time environments.\n\nWhat is a UUID?\n---------------\n\nUUIDs are 128 bit numbers which are intended to have a high likelihood\nof uniqueness over space and time and are computationally difficult to\nguess. They are globally unique identifiers which can be locally\ngenerated without contacting a global registration authority. UUIDs are\nintended as unique identifiers for both mass tagging objects with an\nextremely short lifetime and to reliably identifying very persistent\nobjects across a network.\n\n### UUID Binary Representation\n\nAccording to the DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122\nstandards, a DCE 1.1 variant UUID is a 128 bit number defined out of 7\nfields, each field a multiple of an octet in size and stored in network\nbyte order:\n\n```txt\n                                                    [4]\n                                                   version\n                                                 --\u003e|  |\u003c--\n                                                    |  |\n                                                    |  |  [16]\n                [32]                      [16]      |  |time_hi\n              time_low                  time_mid    | _and_version\n    |\u003c----------------------------\u003e||\u003c------------\u003e||\u003c------------\u003e|\n    | MSB                          ||              ||  |           |\n    | /                            ||              ||  |           |\n    |/                             ||              ||  |           |\n\n    +------++------++------++------++------++------++------++------+~~\n    |  15  ||  14  ||  13  ||  12  ||  11  ||  10  |####9  ||   8  |\n    | MSO  ||      ||      ||      ||      ||      |####   ||      |\n    +------++------++------++------++------++------++------++------+~~\n    7654321076543210765432107654321076543210765432107654321076543210\n\n  ~~+------++------++------++------++------++------++------++------+\n    ##* 7  ||   6  ||   5  ||   4  ||   3  ||   2  ||   1  ||   0  |\n    ##*    ||      ||      ||      ||      ||      ||      ||  LSO |\n  ~~+------++------++------++------++------++------++------++------+\n    7654321076543210765432107654321076543210765432107654321076543210\n\n    | |    ||      ||                                             /|\n    | |    ||      ||                                            / |\n    | |    ||      ||                                          LSB |\n    |\u003c----\u003e||\u003c----\u003e||\u003c--------------------------------------------\u003e|\n    |clk_seq clk_seq                      node\n    |_hi_res _low                         [48]\n    |[5-6]    [8]\n    | |\n --\u003e| |\u003c--\n  variant\n   [2-3]\n```\n\nAn example of a UUID binary representation is the octet stream 0xF8\n0x1D 0x4F 0xAE 0x7D 0xEC 0x11 0xD0 0xA7 0x65 0x00 0xA0 0xC9 0x1E 0x6B\n0xF6.\n\n### UUID ASCII String Representation\n\nAccording to the DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122\nstandards, a DCE 1.1 variant UUID is represented as an ASCII string\nconsisting of 8 hexadecimal digits followed by a hyphen, then three\ngroups of 4 hexadecimal digits each followed by a hyphen, then 12\nhexadecimal digits.\n\nGetting Pure-UUID\n-----------------\n\n```\n$ npm install pure-uuid\n```\n\nUsing Pure-UUID\n---------------\n\n- global environment:\n\n```js\nvar uuid = new UUID(3, \"ns:URL\", \"http://example.com/\");\n```\n\n- CommonJS environment:\n\n```js\nvar UUID = require(\"pure-uuid\");\nvar uuid = new UUID(3, \"ns:URL\", \"http://example.com/\");\n```\n\n- AMD environment:\n\n```js\ndefine([\"pure-uuid\"], function (UUID) {\n    var uuid = new UUID(3, \"ns:URL\", \"http://example.com/\");\n});\n```\n\nAPI\n---\n\n```ts\ninterface UUID {\n    /*  making  */\n    make(version: number, ...params: any[]): UUID;\n\n    /*  parsing  */\n    parse(str: string): UUID;\n\n    /*  formatting  */\n    format(type?: string): string;\n\n    /*  formatting (alias)  */\n    toString(type?: string): string;\n\n    /*  sensible JSON serialization  */\n    toJSON(): string;\n\n    /*  importing  */\n    import(arr: number[]): UUID;\n\n    /*  exporting  */\n    export(): number[];\n\n    /*  byte-wise comparison  */\n    compare(other: UUID): boolean;\n\n    /*  equal check  */\n    equal(other: UUID): boolean;\n\n    /*  fold 1-4 times  */\n    fold(k: number): number[];\n}\n\nexport interface UUIDConstructor {\n  /*  default construction  */\n  new(): UUID;\n\n  /*  parsing construction  */\n  new(uuid: string): UUID;\n\n  /*  making construction  */\n  new(version: number): UUID;\n  new(version: number, ns: string, data: string): UUID;\n}\n\ndeclare var UUID: UUIDConstructor;\nexport default UUID;\n```\n\nExamples\n--------\n\n```js\n//  load a UUID\nuuid = new UUID(\"0a300ee9-f9e4-5697-a51a-efc7fafaba67\");\n\n//  make a UUID version 1 (time and node based)\nuuid = new UUID(1);\n\n//  make a UUID version 3 (name-based, MD5)\nuuid = new UUID(3, \"ns:URL\", \"http://example.com/\");\n\n//  make a UUID version 4 (random number based)\nuuid = new UUID(4);\n\n//  make a UUID version 5 (name-based, SHA-1)\nuuid = new UUID(5, \"ns:URL\", \"http://example.com/\");\n\n//  format a UUID in standard format\nstr = uuid.format()\nstr = uuid.format(\"std\")\n\n//  format a UUID in Base16 format\nstr = uuid.format(\"b16\")\n\n//  format a UUID in ZeroMQ-Base85 format\nstr = uuid.format(\"z85\")\n```\n\nLicense\n-------\n\nCopyright \u0026copy; 2004-2023 Dr. Ralf S. Engelschall (http://engelschall.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be included\nin all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fpure-uuid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frse%2Fpure-uuid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frse%2Fpure-uuid/lists"}