{"id":27201093,"url":"https://github.com/gregl83/monotonic-id","last_synced_at":"2025-04-09T21:55:08.310Z","repository":{"id":57302578,"uuid":"44984319","full_name":"gregl83/monotonic-id","owner":"gregl83","description":"JavaScript Unique Monotonic ID Class","archived":false,"fork":false,"pushed_at":"2016-12-11T04:07:42.000Z","size":14,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T21:55:03.508Z","etag":null,"topics":["binary","monotonic","nodejs","primary-key","uuid"],"latest_commit_sha":null,"homepage":"","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/gregl83.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}},"created_at":"2015-10-26T17:07:57.000Z","updated_at":"2022-07-17T00:12:00.000Z","dependencies_parsed_at":"2022-09-20T19:51:39.342Z","dependency_job_id":null,"html_url":"https://github.com/gregl83/monotonic-id","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregl83%2Fmonotonic-id","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregl83%2Fmonotonic-id/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregl83%2Fmonotonic-id/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregl83%2Fmonotonic-id/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregl83","download_url":"https://codeload.github.com/gregl83/monotonic-id/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119394,"owners_count":21050754,"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":["binary","monotonic","nodejs","primary-key","uuid"],"created_at":"2025-04-09T21:55:07.762Z","updated_at":"2025-04-09T21:55:08.303Z","avatar_url":"https://github.com/gregl83.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/gregl83/monotonic-id.svg?branch=master)](https://travis-ci.org/gregl83/monotonic-id)\n[![Coverage Status](https://coveralls.io/repos/gregl83/monotonic-id/badge.svg)](https://coveralls.io/r/gregl83/monotonic-id?branch=master)\n# monotonic-id\n\nJavaScript Unique Monotonic ID Class\n\nA unique monotonic ID class that is based on UUID version 1.\n\nThe UUID sequence is stripped of the `-` separator and is organized such that IDs are *far more likely to be sequential*.\n\nThe resulting ID can be indexed as a binary value providing a reliable format for large databases with negligible performance loss and smaller footprint than auto incremented IDs (MySQL/MariaDB binary(16) vs bigint).\n\nFor more information see the following [Percona UUID Blog Post](https://www.percona.com/blog/2014/12/19/store-uuid-optimized-way/) which was referenced to create this package.\n\n## Requirements\n\n- NodeJS v5.0.x or higher\n- NPM\n\nSee `./package.json`\n\n## Installation\n\nSource available on [GitHub](https://github.com/gregl83/monotonic-id) or install module via NPM:\n\n    $ npm install monotonic-id\n\n## Usage\n\nCreate instances of the monotonic-id require class.\n\n```js\n// get MID class\nvar MID = require('monotonic-id')\n\n// create MID class instance\nvar mid = new MID()\n\n// cast mid instance in various formats\nvar midID = mid.toID()\nvar midUUID = mid.toUUID()\nvar midHex = mid.toString('hex')\nvar midBuffer = mid.toBuffer()\n\n// additional functionality\n\n// test for valid ID\nMID.isID(midID) // returns true\nMID.isID(midHex) // returns false\n\n// create MID class instance from ID\nvar midFromID = new MID(null, midID)\n\n// create MID class instance from buffer\nvar midFromBuffer = new MID(null, midBuffer)\n\n// create MID class with uuid.v1 options\nvar mid = new MID({\n    node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],\n    clockseq: 0x1234,\n    msecs: new Date('2011-11-01').getTime(),\n    nsecs: 5678\n})\n```\n\nThe above first creates a instance of the monotonic-id class then casts the instance to an id string and hex string.\n\nAfter there are some examples of additional monotonic-id functionality.\n\nThat's it!\n\n## Options\n\nThe following are the supported options for creating a new monotonic-id instance.\n\n- `options` - - (Object | null) Optional uuid state to apply (ignored if `mid` arg supplied). Properties may include:\n  - `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID.\n  - `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence.  Default: An internally maintained clockseq is used.\n  - `msecs` - (Number | Date) Time in milliseconds since unix Epoch.  Default: The current time is used.\n  - `nsecs` - (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.\n- `mid` - (String | Buffer) string id or buffer to cast as a monotonic-id.\n\nFor more information on options checkout the [uuid v1 docs](https://github.com/broofa/node-uuid).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregl83%2Fmonotonic-id","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregl83%2Fmonotonic-id","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregl83%2Fmonotonic-id/lists"}