{"name":"verkit","version":"0.3.2","keywords":["semver","semantic-versioning","version","range","esm","typescript","functional","immutable"],"author":"Kevin Deng <sxzz@sxzz.moe>","license":"MIT","_id":"verkit@0.3.2","maintainers":[{"name":"sxzz","email":"npm@sxzz.moe"}],"homepage":"https://github.com/sxzz/verkit#readme","bugs":{"url":"https://github.com/sxzz/verkit/issues"},"dist":{"shasum":"0511ea63310551b62a20c010aa820350c5c350c6","tarball":"http://registry-npm.ywwl.com/verkit/download/verkit-0.3.2.tgz","fileCount":5,"integrity":"sha512-zj/ob3UsvJGN0whEAKFp53REA5X66hvffVqoCtVQAakJKnKlH+/PcOfMoFwIG/o4rElqLv/ycAFlx8ZlXUorCg==","signatures":[{"sig":"MEQCIFZC82Mlf7fOEPcLwIEriV1UkfHyUrvp8y+Do1MzaxEQAiABTbc9nM37z+ijIKSqnf5eD+zix/abfnefORgjNsUT8Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/verkit@0.3.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":62881,"size":14276,"noattachment":false,"key":"/verkit/-/verkit-0.3.2.tgz"},"type":"module","engines":{"node":">=18.12.0"},"exports":{".":"./dist/index.js","./package.json":"./package.json"},"funding":"https://github.com/sponsors/sxzz","scripts":{"dev":"tsdown --watch","lint":"eslint --cache .","test":"vitest","bench":"vitest bench --run","build":"tsdown","format":"prettier --cache --write .","release":"bumpp","lint:fix":"pnpm run lint --fix","test:size":"vitest run tests/bundle-size.test.ts","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","approver":{"name":"sxzz","email":"npm@sxzz.moe"},"trustedPublisher":{"id":"github","oidcConfigId":"oidc:f3d9f7c3-71d0-4884-b7aa-ae5ace0e0283"}},"prettier":"@sxzz/prettier-config","repository":{"url":"git+https://github.com/sxzz/verkit.git","type":"git"},"description":"Fast, zero-dependency SemVer for ESM and TypeScript, with functional, tree-shakeable APIs.","directories":{},"sideEffects":false,"_nodeVersion":"24.18.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"bumpp":"^12.1.1","eslint":"^10.8.0","semver":"^7.8.5","tsdown":"^0.22.14","tsnapi":"^1.2.0","vitest":"4.1.10","prettier":"^3.9.6","rolldown":"^1.2.2","typescript":"~6.0.3","@types/node":"^26.1.2","@types/semver":"^7.8.0","tsdown-preset-sxzz":"^0.7.0","@sxzz/eslint-config":"^8.4.0","@sxzz/prettier-config":"^2.3.2","@typescript/native-preview":"npm:typescript@7.0.2"},"_npmOperationalInternal":{"tmp":"tmp/verkit_0.3.2_1785866968919_0.10472520884598446","host":"s3://npm-registry-packages-npm-production"},"readme":"# verkit\n\n[![Open on npmx][npmx-version-src]][npmx-href]\n[![npm downloads][npmx-downloads-src]][npmx-href]\n[![Unit Test][unit-test-src]][unit-test-href]\n\nFast, zero-dependency SemVer for ESM and TypeScript, with functional,\ntree-shakeable APIs.\n\n## Features\n\n- ✅ Complete SemVer version and range toolkit.\n- 🚀 Faster than [node-semver] across tested operations.\n- 📦 Pure ESM with zero runtime dependencies.\n- 💙 First-class TypeScript declarations.\n- 🌳 Functional, tree-shakeable named exports.\n- 🔁 Mutable `SemVer` and `SemVerRange` records.\n- ⚡ 23.8% smaller for full CDN imports.\n- 🪶 60.3% smaller with common bundled imports.\n- 🛡️ Immutable collection operations.\n\n## Install\n\n```bash\nnpm add verkit\n```\n\n## Versions\n\n```ts\nimport {\n  coerce,\n  increment,\n  normalize,\n  normalizeFull,\n  parse,\n  truncate,\n} from 'verkit'\n\nconst version = parse('1.2.3-rc.1+sha.abc')\nconst coerced = coerce('release 42.6.7.9', { rtl: true })\nversion.patch = 4\n\nnormalizeFull(version) // '1.2.4-rc.1+sha.abc'\nnormalize(version) // '1.2.4-rc.1'\nincrement(version, 'minor') // '1.3.0'\ntruncate(version, 'patch') // '1.2.4'\ncoerced?.major // 6\n```\n\nVersion APIs accept strings or mutable `SemVer` objects returned by `parse` or\n`coerce`.\n`normalizeFull` keeps build metadata; normalized, incremented, and truncated\nversions omit it.\n\n## Comparison\n\n```ts\nimport { compare, compareBuild, sortReversed } from 'verkit'\n\ncompare('1.0.0+one', '1.0.0+two') // 0\ncompareBuild('1.0.0+one', '1.0.0+two') // -1\nsortReversed(['1.0.0', '2.0.0']) // ['2.0.0', '1.0.0']\n```\n\n`compare` ignores build metadata; `compareBuild` uses it as a tie-breaker.\n\n## Ranges\n\n```ts\nimport {\n  findMaxSatisfying,\n  normalizeRange,\n  parseRange,\n  satisfies,\n} from 'verkit'\n\nconst range = parseRange('^1.2.3')\n\nnormalizeRange(range) // '>=1.2.3 <2.0.0-0'\nsatisfies('1.5.0', range) // true\nfindMaxSatisfying(['1.2.3', '1.5.0', '2.0.0'], range) // '1.5.0'\n```\n\nRange APIs accept strings or mutable `SemVerRange` objects. They support\ncomparators, unions, hyphens, wildcards, tilde, caret, loose parsing, and\nprereleases.\n\nRange options are fixed when a `SemVerRange` is created. APIs that receive a\nparsed range use its stored options and do not accept another options argument:\n\n```ts\nconst prereleases = parseRange('1.x', { includePrerelease: true })\n\nsatisfies('1.0.0-rc.1', prereleases) // true\n```\n\nTo use different options, pass the original range string again or create\nanother parsed range.\n\n## API\n\nSee the [API reference](https://npmx.dev/package-docs/verkit).\n\n## Invalid input behavior\n\n`parse`, `parseComparator`, and `parseRange` throw detailed `TypeError`s. Their\n`tryParse*` wrappers return `null`; other safe transforms and predicates keep\ntheir documented `null`/`false` behavior.\n\n## Migrating from node-semver\n\nOnly renamed or reshaped [node-semver] APIs are listed; same-named functions\nsuch as `clean`, `coerce`, `compare`, and `satisfies` are omitted.\n\n| node-semver                                    | verkit                                                                              |\n| ---------------------------------------------- | ----------------------------------------------------------------------------------- |\n| `SemVer`                                       | `parse`                                                                             |\n| `parse`                                        | `tryParse`                                                                          |\n| `valid`                                        | `normalize`                                                                         |\n| `inc`, `diff`                                  | `increment`, `difference`                                                           |\n| `major`, `minor`, `patch`, `prerelease`        | `getMajor`, `getMinor`, `getPatch`, `getPrerelease`                                 |\n| `rcompare`, `compareLoose`, `cmp`              | `compareReversed`, `compare` with `{ loose: true }`, `compareWithOperator`          |\n| `eq`, `neq`, `gt`, `gte`, `lt`, `lte`          | `isEqual`, `isNotEqual`, `isGreater`, `isGreaterOrEqual`, `isLess`, `isLessOrEqual` |\n| `rsort`                                        | `sortReversed`                                                                      |\n| `rcompareIdentifiers`                          | `compareIdentifiersReversed`                                                        |\n| `Comparator`                                   | `SemVerComparator`, `parseComparator`, `tryParseComparator`                         |\n| Comparator formatting, test, and intersection  | `normalizeComparator`, `satisfiesComparator`, `comparatorsIntersect`                |\n| `Range`                                        | `parseRange`                                                                        |\n| `toComparators`, `validRange`                  | `rangeToComparators`, `normalizeRange`                                              |\n| `maxSatisfying`, `minSatisfying`, `minVersion` | `findMaxSatisfying`, `findMinSatisfying`, `findMinimumForRange`                     |\n| `outside`, `gtr`, `ltr`                        | `isOutsideRange`, `isGreaterThanRange`, `isLessThanRange`                           |\n| `intersects`, `subset`                         | `rangesIntersect`, `isRangeSubset`                                                  |\n| `RELEASE_TYPES`                                | `INCREMENT_TYPES` (also includes `release`)                                         |\n\n`valid` returns a normalized `string | null` in node-semver, so its equivalent\nis `normalize`. Use `isValid` when you only need a boolean.\n\nUse options objects such as `{ loose: true }` and `{ identifier, identifierBase }`.\nRange options belong to the string-parsing step; parsed `SemVerRange` objects\nalready contain them.\n\n## Differences from node-semver\n\nverkit follows [node-semver] semantics with four user-visible differences:\n\n- Array helpers never mutate their inputs.\n- Parsed `SemVerRange` objects retain their parse-time options. node-semver\n  helpers may reparse a `Range` from `raw` using call-site options.\n- verkit is ESM-only, with no CommonJS, CLI, or `NODE_DEBUG=semver` output.\n- Error text, stack traces, and supported runtimes may differ.\n\n## Bundle size\n\nFull package imports, minified with Rolldown:\n\n| Package               | Minified |    gzip |  Brotli |\n| --------------------- | -------: | ------: | ------: |\n| verkit                | 18,754 B | 5,874 B | 5,341 B |\n| [semver][node-semver] | 24,603 B | 7,356 B | 6,703 B |\n| verkit reduction      |    23.8% |   20.1% |   20.3% |\n\nCommon validation, range, comparison, increment, and coercion imports,\ntree-shaken and minified with Rolldown:\n\n| Package               | Minified |    gzip |  Brotli |\n| --------------------- | -------: | ------: | ------: |\n| verkit                |  9,834 B | 3,361 B | 3,086 B |\n| [semver][node-semver] | 24,754 B | 7,427 B | 6,764 B |\n| verkit reduction      |    60.3% |   54.7% |   54.4% |\n\nRun `pnpm test:size` to reproduce the comparison.\n\n## Benchmarks\n\nMeasured on a MacBook Pro with an Apple M1 Max and 32 GB RAM. Higher is\nbetter.\n\n| Operation                 | verkit ops/s | semver ops/s | Faster       |\n| ------------------------- | -----------: | -----------: | ------------ |\n| Parse and normalize       |        1.89M |        1.59M | verkit 1.19× |\n| Compare                   |        1.58M |        1.03M | verkit 1.53× |\n| Compare parsed versions   |       11.70M |        5.44M | verkit 2.15× |\n| Increment                 |        1.79M |        1.00M | verkit 1.79× |\n| Coerce                    |        1.40M |        1.06M | verkit 1.32× |\n| Satisfy uncached ranges   |        81.7K |        56.3K | verkit 1.45× |\n| Satisfy pre-parsed inputs |        5.34M |        2.05M | verkit 2.60× |\n\nRange benchmarks either cycle through 1,001 inputs to avoid cache hits or\nparse once and reuse the resulting objects.\n\nRun runtime benchmarks with `pnpm bench`.\n\n## Sponsors\n\n<p align=\"center\">\n  <a href=\"https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg\">\n    <img src=\"https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg\" alt=\"Sponsors\" />\n  </a>\n</p>\n\n## License\n\n[MIT](./LICENSE) © 2026-PRESENT [Kevin Deng](https://github.com/sxzz).\n\nParts of the implementation and test fixtures are derived from [node-semver]\nunder the ISC license; see [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).\n\n<!-- Badges -->\n\n[npmx-version-src]: https://npmx.dev/api/registry/badge/version/verkit\n[npmx-downloads-src]: https://npmx.dev/api/registry/badge/downloads-month/verkit\n[npmx-href]: https://npmx.dev/verkit\n[node-semver]: https://github.com/npm/node-semver\n[unit-test-src]: https://github.com/sxzz/verkit/actions/workflows/unit-test.yml/badge.svg\n[unit-test-href]: https://github.com/sxzz/verkit/actions/workflows/unit-test.yml\n","publish_time":1785866969008,"_cnpm_publish_time":1785866969008,"dist-tags":{"latest":"0.5.0"}}