{
"repo": "index-encoder",
"timestamp": "2026-01-16T23:56:02.311Z",
"entryPoint": "index.js",
"exports": {
"packageJson": {
"main": "index.js"
}
},
"api": {
"file": "index.js",
"exports": [
{
"type": "default",
"name": "class"
}
],
"classes": [
{
"name": "IndexEncoder"
}
],
"functions": [
{
"name": "encodeUint"
},
{
"name": "encodeUint32"
},
{
"name": "decodeUint32"
}
]
},
"readme": {
"content": "# index-encoder\n\nEncode multiple values into sorted keys\n\n```\nnpm install index-encoder\n```\n\n## Usage\n\n```js\nconst IndexEncoder = require('index-encoder')\n\nconst idx = new IndexEncoder([IndexEncoder.STRING, IndexEncoder.UINT])\n\nconst buf = idx.encode(['foo', 42])\nconsole.log(idx.decode(buf)) // ['foo', 42]\n\n// pass any compact encoding name to map it to the relevant encoding\nconst uintType = IndexEncoder.lookup('uint')\nconst bufferType = IndexEncoder.lookup('buffer')\nconst alsoBufferType = IndexEncoder.lookup('fixed32')\n```\n\n## API\n\n#### `const idx = new IndexEncoder(encodings, { prefix = -1 })`\n\nCreate an index encoder using the array of `encodings`. The index encoder will produce a buffer encoding in the same order as `encodings`. A `prefix` can be defined to differentiate encoded buffers with the same `encodings`.\n\n#### `const buf = idx.encode(keys)`\n\nEncode the provided `keys` as a buffer. `keys` must be in the same order as the `encodings` when constructing the index encoder. `key",
"sections": [
"intro",
"usage",
"api",
"encoding types",
"license"
],
"hasApi": true,
"hasExamples": true,
"exampleCount": 4,
"examples": [
"npm install index-encoder",
"const IndexEncoder = require('index-encoder')\n\nconst idx = new IndexEncoder([IndexEncoder.STRING, IndexEncoder.UINT])\n\nconst buf = idx.encode(['foo', 42])\nconsole.log(idx.decode(buf)) // ['foo', 42]\n\n// pass any compact encoding name to map it to the relevant encoding\nconst uintType = IndexEncoder.lookup('uint')\nconst bufferType = IndexEncoder.lookup('buffer')\nconst alsoBufferType = IndexEncoder.lookup('fixed32')",
"{\n gt, // Return values only > than this\n gte, // Return values >= than this\n lt, // Return values < than this\n lte: // Return values <= than this\n}"
]
},
"patterns": []
}