{"id":17398445,"url":"https://github.com/vweevers/lexicographic-integer-encoding","last_synced_at":"2025-06-23T18:06:32.660Z","repository":{"id":55828339,"uuid":"108037573","full_name":"vweevers/lexicographic-integer-encoding","owner":"vweevers","description":"Lexicographically ordered integers for level(up).","archived":false,"fork":false,"pushed_at":"2020-12-11T17:48:17.000Z","size":5,"stargazers_count":5,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-19T06:15:16.721Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vweevers.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-23T20:47:12.000Z","updated_at":"2023-12-16T14:00:13.000Z","dependencies_parsed_at":"2022-08-15T07:31:19.914Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/lexicographic-integer-encoding","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/vweevers/lexicographic-integer-encoding","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Flexicographic-integer-encoding","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Flexicographic-integer-encoding/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Flexicographic-integer-encoding/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Flexicographic-integer-encoding/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/lexicographic-integer-encoding/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Flexicographic-integer-encoding/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261528654,"owners_count":23172749,"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":[],"created_at":"2024-10-16T14:56:33.717Z","updated_at":"2025-06-23T18:06:32.604Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lexicographic-integer-encoding\n\n**Lexicographically ordered integers for `level(up)`. Wraps [`lexicographic-integer`].**\n\n[![npm status](http://img.shields.io/npm/v/lexicographic-integer-encoding.svg?style=flat-square)](https://www.npmjs.org/package/lexicographic-integer-encoding)\n[![node](https://img.shields.io/node/v/lexicographic-integer-encoding.svg?style=flat-square)](https://www.npmjs.org/package/lexicographic-integer-encoding) [![Travis build status](https://img.shields.io/travis/vweevers/lexicographic-integer-encoding.svg?style=flat-square\u0026label=travis)](http://travis-ci.org/vweevers/lexicographic-integer-encoding) [![AppVeyor build status](https://img.shields.io/appveyor/ci/vweevers/lexicographic-integer-encoding.svg?style=flat-square\u0026label=appveyor)](https://ci.appveyor.com/project/vweevers/lexicographic-integer-encoding) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](https://standardjs.com) [![Dependency status](https://img.shields.io/david/vweevers/lexicographic-integer-encoding.svg?style=flat-square)](https://david-dm.org/vweevers/lexicographic-integer-encoding)\n\n## usage with [`level`]\n\n```js\nconst level = require('level')\nconst lexint = require('lexicographic-integer-encoding')('hex')\n\nconst db = level('./db', { keyEncoding: lexint })\n\ndb.put(2, 'example', (err) =\u003e {\n  db.put(10, 'example', (err) =\u003e {\n    // Without our encoding, the keys would sort as 10, 2.\n    db.createKeyStream().on('data', console.log) // 2, 10\n  })\n})\n```\n\n## usage with [`levelup`]\n\n```js\nconst levelup = require('levelup')\nconst encode = require('encoding-down')\nconst leveldown = require('leveldown')\nconst lexint = require('lexicographic-integer-encoding')('hex')\n\nconst db = levelup(encode(leveldown('./db'), { keyEncoding: lexint }))\n```\n\n## api\n\n### `lexint = require('lexicographic-integer-encoding')(encoding, [options])`\n\n- `encoding` (string, required): `'hex'` or `'buffer'`\n- `options.strict` (boolean): opt-in to type-checking input. If true, encode will throw:\n  - A `TypeError` if input is not a number or if `NaN`\n  - A `RangeError` if input is \u003c 0 or \u003e `Number.MAX_SAFE_INTEGER`\n\nReturns a [`level-codec` compliant encoding](https://github.com/Level/codec#encoding-format) object.\n\n## see also\n\n- [`lexicographic-integer`]: main encoding logic\n- [`unique-lexicographic-integer`]: `lexicographic-integer` plus a suffix if input is the same as the last call;\n- [`monotonic-lexicographic-timestamp`]: `unique-lexicographic-integer` with `Date.now()` to get a monotonically increasing timestamp with lexicographic order.\n\n## install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install lexicographic-integer-encoding\n```\n\n## license\n\n[MIT](http://opensource.org/licenses/MIT) © Vincent Weevers\n\n[`lexicographic-integer`]: https://github.com/substack/lexicographic-integer\n[`level`]: https://github.com/Level/level\n[`levelup`]: https://github.com/Level/levelup\n[`unique-lexicographic-integer`]: https://github.com/vweevers/unique-lexicographic-integer\n[`monotonic-lexicographic-timestamp`]: https://github.com/vweevers/monotonic-lexicographic-timestamp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Flexicographic-integer-encoding","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Flexicographic-integer-encoding","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Flexicographic-integer-encoding/lists"}