{"id":44547913,"url":"https://github.com/countertype/brotli-lib","last_synced_at":"2026-02-13T19:20:32.513Z","repository":{"id":336229659,"uuid":"1148585355","full_name":"countertype/brotli-lib","owner":"countertype","description":"TypeScript Brotli encoder and decoder","archived":false,"fork":false,"pushed_at":"2026-02-03T11:34:54.000Z","size":15537,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-04T01:10:49.893Z","etag":null,"topics":["brotli","brotli-compression","brotli-decoder","brotli-decompressor","brotli-encoder","compression","decode","decoder","decompression","encode","encoder","javascript","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/countertype.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-03T06:06:16.000Z","updated_at":"2026-02-03T11:33:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/countertype/brotli-lib","commit_stats":null,"previous_names":["countertype/brotli-lib"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/countertype/brotli-lib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/countertype%2Fbrotli-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/countertype%2Fbrotli-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/countertype%2Fbrotli-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/countertype%2Fbrotli-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/countertype","download_url":"https://codeload.github.com/countertype/brotli-lib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/countertype%2Fbrotli-lib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29414979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T06:24:03.484Z","status":"ssl_error","status_checked_at":"2026-02-13T06:23:12.830Z","response_time":78,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["brotli","brotli-compression","brotli-decoder","brotli-decompressor","brotli-encoder","compression","decode","decoder","decompression","encode","encoder","javascript","typescript"],"created_at":"2026-02-13T19:20:31.877Z","updated_at":"2026-02-13T19:20:32.501Z","avatar_url":"https://github.com/countertype.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# brotli-lib\n\n[![npm version](https://img.shields.io/npm/v/brotli-lib)](https://www.npmjs.com/package/brotli-lib)\n\nTypeScript Brotli encoder and decoder\n\n## Install\n\n```bash\nnpm install brotli-lib\n```\n\n## Usage\n\n```typescript\nimport { brotliDecode } from 'brotli-lib/decode'\n\nconst decompressed = brotliDecode(compressed)\n```\n\n```typescript\nimport { brotliEncode } from 'brotli-lib/encode'\n\nconst compressed = brotliEncode(data, { quality: 11 })\n```\n\n```typescript\nimport { brotliEncode, brotliDecode } from 'brotli-lib'\n```\n\n## API\n\n### Decode\n\n```typescript\nfunction brotliDecode(\n  data: Uint8Array,\n  options?: { maxOutputSize?: number; customDictionary?: Uint8Array }\n): Uint8Array\n\nfunction brotliDecodedSize(data: Uint8Array): number  // -1 if multi-metablock\n```\n\n### Encode\n\n```typescript\nfunction brotliEncode(\n  data: Uint8Array,\n  options?: {\n    quality?: number   // 0-11, default 11\n    lgwin?: number     // window bits 10-24, default 22\n    mode?: EncoderMode // GENERIC, TEXT, or FONT\n  }\n): Uint8Array\n\nclass BrotliEncoder {\n  constructor(options?: BrotliEncodeOptions)\n  update(chunk: Uint8Array): void\n  finish(): Uint8Array\n}\n```\n\nFONT mode uses distance coding parameters optimized for transformed font data. It doesn't improve compression on raw TTF/OTF files - the gains come from WOFF2's font-specific transforms (glyf, loca, hmtx) applied before brotli compression\n\n## Performance\n\n### Decode\n\n|  | brotli-lib | brotli.js | Google decode.ts |\n|--|------------|-----------|---------------|\n| Speed (vs Google) | 1.2x | 0.5-0.6x | 1x |\n| Custom dictionary | yes | no | yes |\n| Compressed static dict | yes | yes | no |\n\nDecode times (Apple M2 Max, Node 22):\n\n| File | brotli-lib | brotli.js | Google decode.ts |\n|------|------------|-----------|---------------|\n| enc-ttf (305 KB) | 2.3 ms | 4.4 ms | 2.9 ms |\n| enc-otf (253 KB) | 2.2 ms | 4.3 ms | 2.8 ms |\n| enc-var-ttf (788 KB) | 5.8 ms | 11.6 ms | 7.0 ms |\n| noto-tc (7 MB) | 47 ms | 90 ms | 57 ms |\n\n2x faster than brotli.js, ~20% faster than Google's JS decoder\n\n### Encode\n\nEncoder vs Node.js native `zlib.brotliCompressSync` (quality 11):\n\n| Input | brotli-lib | node:zlib | vs native |\n|-------|-----------|-----------|-----------|\n| 13 B | 0.001 ms | 0.16 ms | 160x faster |\n| 4.5 KB | 0.27 ms | 0.33 ms | 1.2x faster |\n| 45 KB | 3.0 ms | 1.4 ms | 2x slower |\n\nMuch faster for tiny inputs (no native binding overhead), faster for medium, ~2x slower for large\n\nRun `npm run bench` to reproduce\n\n## Subpath exports\n\n| Import | Export size (gzip) |\n|--------|--------------------|\n| `brotli-lib/encode` | 25 KB |\n| `brotli-lib/decode` | 66 KB |\n| `brotli-lib` | 90 KB |\n\nThe 122 KB static dictionary is compressed to 52 KB and bootstrapped at runtime (à la Devon Govett's brotli.js).\n\n## License\n\nMIT\n\nDerived from Google's [brotli](https://github.com/google/brotli) (MIT)\n\nMaintained by [@jpt](https://github.com/jpt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcountertype%2Fbrotli-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcountertype%2Fbrotli-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcountertype%2Fbrotli-lib/lists"}