{"id":21654726,"url":"https://github.com/localvoid/pck","last_synced_at":"2025-03-20T04:42:22.010Z","repository":{"id":57321270,"uuid":"106892576","full_name":"localvoid/pck","owner":"localvoid","description":":package: pck is a binary format and a set of tools for generating serializers/deserializers","archived":false,"fork":false,"pushed_at":"2017-11-09T05:17:27.000Z","size":587,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-12T07:04:52.862Z","etag":null,"topics":["binary-format","javascript","serialization"],"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/localvoid.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-14T02:48:54.000Z","updated_at":"2024-01-12T13:10:30.000Z","dependencies_parsed_at":"2022-08-26T01:10:47.764Z","dependency_job_id":null,"html_url":"https://github.com/localvoid/pck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Fpck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Fpck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Fpck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/localvoid%2Fpck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/localvoid","download_url":"https://codeload.github.com/localvoid/pck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244554121,"owners_count":20471173,"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":["binary-format","javascript","serialization"],"created_at":"2024-11-25T08:28:58.604Z","updated_at":"2025-03-20T04:42:21.991Z","avatar_url":"https://github.com/localvoid.png","language":"TypeScript","readme":"PCK is a binary format and a set of tools specifically designed for generating efficient deserializers in javascript.\n\n## Features\n\n- Binary format\n- Compact storage size\n- Javascript as a language to describe schemas\n- Efficient and compact deserialization and serialization in javascript\n\n## Supported Programming Languages\n\n- Javascript ([pck-emit-js](https://npmjs.com/package/pck-emit-js))\n- Go ([pck-emit-go](https://npmjs.com/package/pck-emit-go))\n\n## Packages\n\n- [pck](https://npmjs.com/package/pck) Core data structures and helper functions for generating schemas.\n- [pck-emit-js](https://npmjs.com/package/pck-emit-js) Emitter for Javascript/TypeScript (Browser/Node).\n- [pck-emit-go](https://npmjs.com/package/pck-emit-go) Emitter for Go.\n- [pck-browser](https://npmjs.com/package/pck-browser) Helper utilities for Javascript (Browser).\n- [pck-node](https://npmjs.com/package/pck-node) Helper utilities for Javascript (Node).\n\n## Benchmarks\n\n[pck-browser](https://npmjs.com/package/pck-browser) is optimized towards fast deserialization performance and compact\nseralization functions. It is possible to generate way much faster serializers, but it would require generating more\ncode and in most situations it is isn't worth it.\n\n[pck-node](https://npmjs.com/package/pck-node) works in the same way as `pck-browser`, but Node.js implementation\ndoesn't need to be super compact, so in the future, serialization functions will be optimized towards serialization\nperformance.\n\n### Basic Data\n\nBasic benchmarks that serialize and deserialize simple data structure that doesn't contain any strings:\n\n```js\nconst DATA = {\n  health: 100,\n  jumping: true,\n  position: { x: 10, y: 20 },\n  attributes: { str: 100, agi: 50, int: 10 },\n};\n```\n\n#### Schema\n\n```js\nconst Position = schema(ivar(\"x\"), ivar(\"y\"));\nconst Attributes = schema(u8(\"str\"), u8(\"agi\"), u8(\"int\"));\nconst Player = schema(\n  ivar(\"health\"),\n  bool(\"jumping\"),\n  ref(\"position\", Position),\n  ref(\"attributes\", Attributes),\n);\n```\n\n#### Storage Size\n\n- PCK: 8 bytes\n- JSON: 99 bytes\n\n#### Node v8.8.0 (i5 4570k, Linux)\n\n```txt\npck:encode x 3,424,757 ops/sec ±0.96% (94 runs sampled)\npck:decode x 19,974,290 ops/sec ±0.22% (96 runs sampled)\njson:encode x 508,511 ops/sec ±1.45% (84 runs sampled)\njson:decode x 589,417 ops/sec ±0.27% (96 runs sampled)\n```\n\n#### Browser (iPad 2017, iOS 11.0.3)\n\n```txt\npck:encode x 2,467,280 ops/sec ±4.99% (34 runs sampled)\npck:decode x 27,437,271 ops/sec ±0.78% (64 runs sampled)\njson:encode x 626,667 ops/sec ±1.26% (61 runs sampled)\njson:decode x 617,130 ops/sec ±0.27% (44 runs sampled)\n```\n\n#### Browser (Nexus 5, Chrome 61)\n\n```txt\npck:encode x 514,284 ops/sec ±5.64% (52 runs sampled)\npck:decode x 1,529,939 ops/sec ±4.71% (49 runs sampled)\njson:encode x 127,017 ops/sec ±3.10% (51 runs sampled)\njson:decode x 132,055 ops/sec ±0.71% (55 runs sampled)\n```\n\n#### Go 1.9 (i5 4570k, Linux)\n\n```txt\nBenchmarkPckEncode-4    \t200000000\t        65.9 ns/op\nBenchmarkPckDecode-4    \t200000000\t        92.6 ns/op\nBenchmarkJsonEncode-4   \t10000000\t      1380 ns/op\nBenchmarkJsonDecode-4   \t 3000000\t      4624 ns/op\n```\n\n### HackerNews Data\n\nThis benchmark serializes and deserializes response from [HackerNews](https://news.ycombinator.com/) top stories API.\n\n#### Schema\n\n```js\nconst Item = schema(\n  utf8(\"by\"),\n  uvar(\"descendants\"),\n  uvar(\"id\"),\n  omitEmpty(omitNull(array(\"kids\", UVAR))),\n  uvar(\"score\"),\n  u32(\"time\"),\n  utf8(\"title\"),\n  omitEmpty(utf8(\"url\")),\n);\n\nconst TopStories = schema(\n  array(\"items\", REF(Item)),\n);\n```\n\n#### Storage Size\n\n- PCK: 94815 bytes\n- JSON: 185885 bytes\n\n#### Node v8.8.0 (i5 4570k, Linux)\n\n```txt\npck:encode x 970 ops/sec ±2.41% (91 runs sampled)\npck:decode x 2,265 ops/sec ±0.67% (94 runs sampled)\njson:encode x 1,468 ops/sec ±0.21% (94 runs sampled)\njson:decode x 516 ops/sec ±2.86% (82 runs sampled)\n```\n\n#### Browser (iPad 2017, iOS 11.0.3)\n\n```txt\npck:encode x 441 ops/sec ±1.00% (63 runs sampled)\npck:decode x 1,176 ops/sec ±0.50% (62 runs sampled)\njson:encode x 941 ops/sec ±0.44% (62 runs sampled)\njson:decode x 587 ops/sec ±0.25% (63 runs sampled)\n```\n\n#### Browser (Nexus 5, Chrome 61)\n\n```txt\npck:encode x 102 ops/sec ±6.51% (45 runs sampled)\npck:decode x 511 ops/sec ±2.95% (54 runs sampled)\njson:encode x 238 ops/sec ±3.76% (51 runs sampled)\njson:decode x 71 ops/sec ±7.94% (44 runs sampled)\n```\n\n#### Go 1.9 (i5 4570k, Linux)\n\n```txt\nBenchmarkPckEncode-4    \t  100000\t    197485 ns/op\nBenchmarkPckDecode-4    \t   50000\t    308749 ns/op\nBenchmarkJsonEncode-4   \t   10000\t   1292727 ns/op\nBenchmarkJsonDecode-4   \t    3000\t   4856830 ns/op\n```\n\n## Data Types\n\n| Type         | Storage Size         | Description                       |\n| ---          | ---                  | ---                               |\n| Bool         | 1 bit (bit store)    | Boolean                           |\n| I8           | 1 byte               | Int8                              |\n| U8           | 1 byte               | Uint8                             |\n| I16          | 2 bytes              | Int16                             |\n| U16          | 2 bytes              | Uint16                            |\n| I32          | 4 bytes              | Int32                             |\n| U32          | 4 bytes              | Uint32                            |\n| F32          | 4 bytes              | Float32                           |\n| F64          | 8 bytes              | Float64                           |\n| IVAR         | 1-5 bytes            | Variadic Int32 (ZigZag encoding)  |\n| UVAR         | 1-5 bytes            | Variadic Uint32                   |\n| UTF8         | 1-5+N bytes          | UTF8 String                       |\n| ASCII        | 1-5+N bytes          | ASCII String                      |\n| BYTES        | 1-5+N bytes          | Byte Array                        |\n| ARRAY        | 1-5+N bytes          | Array                             |\n| MAP(K,V)     | 1-5+(NK+NV) bytes    | Map                               |\n| ASCII(N)     | N bytes              | Fixed ASCII String                |\n| BYTES(N)     | N bytes              | Fixed Byte Array                  |\n| ARRAY(N)     | NV bytes             | Fixed Array                       |\n| REF(T)       | size(T) bytes        | Reference to an Object            |\n| UNION(T...)  | 1-5+size(...T) bytes | Tagged Union                      |\n\n## Field Flags\n\n| Flag         | Storage Size         | Description                       |\n| ---          | ---                  | ---                               |\n| Optional     | 1 bit (bit store)    | OmitNull, OmitEmpty, OmitZero     |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalvoid%2Fpck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flocalvoid%2Fpck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flocalvoid%2Fpck/lists"}