{"name":"ulid","version":"3.0.2","description":"A universally-unique, lexicographically-sortable, identifier generator","type":"module","exports":{".":{"types":{"require":"./dist/index.d.cts","default":"./dist/index.d.ts"},"node":{"require":"./dist/node/index.cjs","default":"./dist/node/index.js"},"default":{"require":"./dist/browser/index.cjs","default":"./dist/browser/index.js"}},"./package.json":"./package.json"},"main":"dist/node/index.cjs","module":"./dist/node/index.js","browser":{"./dist/node/index.cjs":"./dist/browser/index.cjs","./dist/node/index.js":"./dist/browser/index.js"},"react-native":"./dist/browser/index.cjs","types":"dist/index.d.ts","sideEffects":false,"bin":{"ulid":"dist/cli.js"},"scripts":{"bench":"npm run build && node test/benchmark.js","build":"npm run clean && npm run build:node:cjs && npm run build:node:esm && npm run build:browser:cjs && npm run build:browser:esm && npm run build:cli && npm run build:types","build:browser:cjs":"FMT=cjs ENV=browser rollup -c --name ulidx","build:browser:esm":"FMT=esm ENV=browser rollup -c --name ulidx","build:cli":"FMT=esm ENV=cli rollup -c && chmod +x ./dist/cli.js","build:node:cjs":"FMT=cjs ENV=node rollup -c","build:node:esm":"FMT=esm ENV=node rollup -c","build:types":"tsc -p tsconfig.dec.json --emitDeclarationOnly  && find ./dist -name '*.d.ts' -exec sh -c 'cp {} $(dirname {})/$(basename -s .d.ts {}).d.cts' \\;","clean":"rm -rf ./dist","format":"prettier --write \"{{source,test}/**/*.{js,ts},rollup.config.js,vitest.config.js}\"","prepublishOnly":"npm run build","test":"npm run build && npm run test:specs && npm run test:format && npm run test:types","test:format":"prettier --check \"{{source,test}/**/*.{js,ts},rollup.config.js,vitest.config.js}\"","test:specs":"vitest","test:types":"npx --yes @arethetypeswrong/cli --pack ."},"repository":{"type":"git","url":"git+https://github.com/ulid/javascript.git"},"author":{"name":"Alizain Feerasta"},"license":"MIT","bugs":{"url":"https://github.com/ulid/javascript/issues"},"homepage":"https://github.com/ulid/javascript#readme","devDependencies":{"@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^28.0.3","@rollup/plugin-node-resolve":"^16.0.1","@rollup/plugin-typescript":"^12.1.2","@types/node":"^22.15.30","benchmark":"^2.1.4","prettier":"^3.5.3","rollup":"^4.42.0","tslib":"^2.8.1","typescript":"^5.8.3","vitest":"^3.2.2"},"_id":"ulid@3.0.2","gitHead":"11c2067821ee19e4dc787ca4e0125a025485edc6","_nodeVersion":"23.11.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-yu26mwteFYzBAot7KVMqFGCVpsF6g8wXfJzQUHvu1no3+rRRSFcSV2nKeYvNPLD2J4b08jYBDhHUjeH0ygIl9w==","shasum":"b6a1f2a3de7852e39aa86bf497a8e33b1867c984","tarball":"http://registry-npm.ywwl.com/ulid/download/ulid-3.0.2.tgz","fileCount":28,"unpackedSize":69343,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIG4CAlc7cL+IJn4yCqw1h7UjEPjfh9KnllCjRvCPzkR7AiEA2pj85HA+q65emOEyZm6B06LuQZCdksw2ugAZyn1mWSw="}],"size":9879,"noattachment":false,"key":"/ulid/-/ulid-3.0.2.tgz"},"_npmUser":{"name":"perrymitchell","email":"perry@perrymitchell.net"},"directories":{},"maintainers":[{"name":"perrymitchell","email":"perry@perrymitchell.net"},{"name":"alizain","email":"alizain.feerasta@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ulid_3.0.2_1764532970527_0.13850725650414675"},"_hasShrinkwrap":false,"readme":"<h1 align=\"center\">\n\t<br>\n\t<br>\n\t<img width=\"360\" src=\"logo.png\" alt=\"ulid\">\n\t<br>\n\t<br>\n\t<br>\n</h1>\n\n# Universally Unique Lexicographically Sortable Identifier\n\n[![Tests](https://github.com/ulid/javascript/actions/workflows/test.yml/badge.svg)](https://github.com/ulid/javascript/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/ulid/javascript/branch/master/graph/badge.svg)](https://codecov.io/gh/ulid/javascript)\n[![npm](https://img.shields.io/npm/dm/ulid.svg)](https://www.npmjs.com/package/ulid) [![npm](https://img.shields.io/npm/dy/ulid)](https://www.npmjs.com/package/ulid)\n\nULIDs are unique, sortable identifiers that work much in the same way as UUIDs, though with some improvements:\n\n * Lexicographically sortable\n * Canonically encoded as a 26 character string, as opposed to the 36 character UUID\n * Uses Crockford's base32 for better efficiency and readability (5 bits per character)\n * Monotonic sort order (correctly detects and handles the same millisecond)\n\nULIDs also provide:\n\n * 128-bit compatibility with UUID\n * 1.21e+24 unique IDs per millisecond\n * Case insensitivity\n * No special characters (URL safe)\n\nUUID can be suboptimal for many uses-cases because:\n\n- It isn't the most character efficient way of encoding 128 bits of randomness\n- UUID v1/v2 is impractical in many environments, as it requires access to a unique, stable MAC address\n- UUID v3/v5 requires a unique seed and produces randomly distributed IDs, which can cause fragmentation in many data structures\n- UUID v4 provides no other information than randomness which can cause fragmentation in many data structures\n\n## Installation\n\nInstall using NPM:\n\n```shell\nnpm install ulid --save\n```\n\n### Compatibility\n\nULID supports the following environments:\n\n| Version   | NodeJS    | Browsers      | React-Native  | Web Workers   | Edge Functions    |\n|-----------|-----------|---------------|---------------|---------------|-------------------|\n| v3        | v18+      | Yes           | Yes           | Yes           | ?                 |\n| v2        | v16+      | Yes           | No            | No            | No                |\n\nAdditionally, both ESM and CommonJS entrypoints are provided.\n\n## Usage\n\nTo quickly generate a ULID, you can simply import the `ulid` function:\n\n```typescript\nimport { ulid } from \"ulid\";\n\nulid(); // \"01ARZ3NDEKTSV4RRFFQ69G5FAV\"\n```\n\n### Seed Time\n\nYou can also input a seed time which will consistently give you the same string for the time component. This is useful for migrating to ulid.\n\n```typescript\nulid(1469918176385) // \"01ARYZ6S41TSV4RRFFQ69G5FAV\"\n```\n\n### Monotonic ULIDs\n\nTo generate monotonically increasing ULIDs, create a monotonic counter with `monotonicFactory`.\n\n> Note that the same seed time is being passed in for this example to demonstrate its behaviour when generating multiple ULIDs within the same millisecond\n\n```typescript\nimport { monotonicFactory } from \"ulid\";\n\nconst ulid = monotonicFactory();\n\n// Strict ordering for the same timestamp, by incrementing the least-significant random bit by 1\nulid(150000); // \"000XAL6S41ACTAV9WEVGEMMVR8\"\nulid(150000); // \"000XAL6S41ACTAV9WEVGEMMVR9\"\nulid(150000); // \"000XAL6S41ACTAV9WEVGEMMVRA\"\nulid(150000); // \"000XAL6S41ACTAV9WEVGEMMVRB\"\nulid(150000); // \"000XAL6S41ACTAV9WEVGEMMVRC\"\n\n// Even if a lower timestamp is passed (or generated), it will preserve sort order\nulid(100000); // \"000XAL6S41ACTAV9WEVGEMMVRD\"\n```\n\n### Pseudo-Random Number Generators\n\n`ulid` automatically detects a suitable (cryptographically-secure) PRNG. In the browser it will use `crypto.getRandomValues` and on NodeJS it will use `crypto.randomBytes`.\n\n#### Using `Math.random` (insecure)\n\nBy default, `ulid` will not use `Math.random` to generate random values. You can bypass this limitation by overriding the PRNG:\n\n```typescript\nconst ulid = monotonicFactory(() => Math.random());\n\nulid(); // \"01BXAVRG61YJ5YSBRM51702F6M\"\n```\n\n### Validity\n\nYou can verify if a value is a valid ULID by using `isValid`:\n\n```typescript\nimport { isValid } from \"ulid\";\n\nisValid(\"01ARYZ6S41TSV4RRFFQ69G5FAV\"); // true\nisValid(\"01ARYZ6S41TSV4RRFFQ69G5FA\"); // false\n```\n\n### ULID Time\n\nYou can encode and decode ULID timestamps by using `encodeTime` and `decodeTime` respectively:\n\n```typescript\nimport { decodeTime } from \"ulid\";\n\ndecodeTime(\"01ARYZ6S41TSV4RRFFQ69G5FAV\"); // 1469918176385\n```\n\nNote that while `decodeTime` works on full ULIDs, `encodeTime` encodes only the _time portion_ of ULIDs:\n\n```typescript\nimport { encodeTime } from \"ulid\";\n\nencodeTime(1469918176385); // \"01ARYZ6S41\"\n```\n\n### Tests\n\nInstall dependencies using `npm install` first, and then simply run `npm test` to run the test suite.\n\n### CLI\n\n`ulid` can be used on the command line, either via global install:\n\n```shell\nnpm install -g ulid\nulid\n```\n\nOr via `npx`:\n\n```shell\nnpx ulid\n```\n\nYou can also generate multiple IDs at the same time:\n\n```shell\nulid --count 15\n```\n\n## Specification\n\nYou can find the full specification, as well as information regarding implementations in other languages, over at [ulid/spec](https://github.com/ulid/spec).\n\n## Performance\n\nYou can test `ulid`'s performance by running `npm run bench`:\n\n```\nSimple ulid x 56,782 ops/sec ±2.50% (86 runs sampled)\nulid with timestamp x 58,574 ops/sec ±1.80% (87 runs sampled)\nDone!\n```\n","publish_time":1764532970707,"_cnpm_publish_time":1764532970707,"dist-tags":{"latest":"3.0.2"}}