OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-kb / skills / compact-encoding / api-extract.json

94 lines · json ref:
{
  "repo": "compact-encoding",
  "timestamp": "2026-01-16T23:05:20.185Z",
  "entryPoint": "index.js",
  "exports": {
    "packageJson": {
      "main": "index.js"
    }
  },
  "api": {
    "file": "index.js",
    "exports": [],
    "classes": [],
    "functions": [
      {
        "name": "typedarray"
      },
      {
        "name": "string"
      },
      {
        "name": "fixed"
      },
      {
        "name": "array"
      },
      {
        "name": "frame"
      },
      {
        "name": "getType"
      },
      {
        "name": "from"
      },
      {
        "name": "fromNamed"
      },
      {
        "name": "fromCodec"
      },
      {
        "name": "fromAbstractEncoder"
      },
      {
        "name": "encode"
      },
      {
        "name": "decode"
      },
      {
        "name": "zigZagInt"
      },
      {
        "name": "zigZagDecodeInt"
      },
      {
        "name": "zigZagEncodeInt"
      },
      {
        "name": "zigZagBigInt"
      },
      {
        "name": "zigZagDecodeBigInt"
      },
      {
        "name": "zigZagEncodeBigInt"
      },
      {
        "name": "validateUint"
      }
    ]
  },
  "readme": {
    "content": "# compact-encoding\n\nA series of compact encoding schemes for building small and fast parsers and serializers\n\n```\nnpm install compact-encoding\n```\n\n## Usage\n\n```js\nconst cenc = require('compact-encoding')\n\nconst state = cenc.state()\n\n// use preencode to figure out how big a buffer is needed\ncenc.uint.preencode(state, 42)\ncenc.string.preencode(state, 'hi')\n\nconsole.log(state) // { start: 0, end: 4, buffer: null }\n\nstate.buffer = Buffer.allocUnsafe(state.end)\n\n// then use encode to actually encode it to the buffer\ncenc.uint.encode(state, 42)\ncenc.string.encode(state, 'hi')\n\n// to decode it simply use decode instead\n\nstate.start = 0\ncenc.uint.decode(state) // 42\ncenc.string.decode(state) // 'hi'\n```\n\n## Encoder API\n\n#### `state`\n\nShould be an object that looks like this `{ start, end, buffer }`.\n\nYou can also get a blank state object using `cenc.state()`.\n\n- `start` is the byte offset to start encoding/decoding at.\n- `end` is the byte offset indicating the end of the buffer.\n- `buffer` sh",
    "sections": [
      "intro",
      "usage",
      "encoder api",
      "helpers",
      "bundled encodings",
      "license"
    ],
    "hasApi": true,
    "hasExamples": true,
    "exampleCount": 3,
    "examples": [
      "npm install compact-encoding",
      "const cenc = require('compact-encoding')\n\nconst state = cenc.state()\n\n// use preencode to figure out how big a buffer is needed\ncenc.uint.preencode(state, 42)\ncenc.string.preencode(state, 'hi')\n\nconsole.log(state) // { start: 0, end: 4, buffer: null }\n\nstate.buffer = Buffer.allocUnsafe(state.end)\n\n// then use encode to actually encode it to the buffer\ncenc.uint.encode(state, 42)\ncenc.string.encode(state, 'hi')\n\n// to decode it simply use decode instead\n\nstate.start = 0\ncenc.uint.decode(state) // 42\ncenc.string.decode(state) // 'hi'",
      "const buf = cenc.encode(cenc.bool, true)\nconst bool = cenc.decode(cenc.bool, buf)"
    ]
  },
  "patterns": []
}