{"id":13778085,"url":"https://github.com/catwell/luajit-msgpack-pure","last_synced_at":"2025-05-11T11:34:58.186Z","repository":{"id":2068169,"uuid":"3006921","full_name":"catwell/luajit-msgpack-pure","owner":"catwell","description":"MessagePack for LuaJIT (using FFI, no bindings, V4 API)","archived":true,"fork":false,"pushed_at":"2019-09-11T09:20:18.000Z","size":44,"stargazers_count":71,"open_issues_count":0,"forks_count":14,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-02-15T05:34:40.500Z","etag":null,"topics":["lua","luajit","messagepack"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"OctoMap/octomap","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/catwell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-18T17:11:16.000Z","updated_at":"2023-09-08T16:31:31.000Z","dependencies_parsed_at":"2022-08-29T16:21:14.174Z","dependency_job_id":null,"html_url":"https://github.com/catwell/luajit-msgpack-pure","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/catwell%2Fluajit-msgpack-pure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Fluajit-msgpack-pure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Fluajit-msgpack-pure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/catwell%2Fluajit-msgpack-pure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/catwell","download_url":"https://codeload.github.com/catwell/luajit-msgpack-pure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225043278,"owners_count":17411955,"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":["lua","luajit","messagepack"],"created_at":"2024-08-03T18:00:51.070Z","updated_at":"2024-11-17T13:31:23.741Z","avatar_url":"https://github.com/catwell.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"# luajit-msgpack-pure\n\n## Warning\n\nThis library implements MessagePack [spec v4](https://github.com/msgpack/msgpack/blob/814275fb2760d794f9f899b0a5b85db0f80c3332/spec-old.md) with some extensions compatible with [msgpack-js](https://github.com/creationix/msgpack-js). *It does not implement [spec v5](https://github.com/msgpack/msgpack/blob/814275fb2760d794f9f899b0a5b85db0f80c3332/spec.md).* If you need support for spec v5 (including STR8, BIN types, etc), see [alternatives](#alternatives).\n\n## Presentation\n\nThis is yet another implementation of MessagePack for LuaJIT.\nHowever, unlike [luajit-msgpack](https://github.com/catwell/cw-lua/tree/master/luajit-msgpack),\nluajit-msgpack-pure does not depend on the MessagePack C library.\nEverything is re-implemented in LuaJIT code (using the FFI but only to\nmanipulate data structures).\n\n## Alternatives\n\nIf I had to pick a single MessagePack implementation, it would be [lua-MessagePack](https://fperrad.frama.io/lua-MessagePack/). It is pure Lua, its performance is very close to luajit-msgpack-pure and it supports the latest revision of the standard. If it had existed earlier, I would not have written this one. *If you start a new project, use it.*\n\nAnother interesting implementation is [lua-cmsgpack](https://github.com/antirez/lua-cmsgpack), written in C specifically for use in Redis.\n\nOther implementations:\n\n - [lua-msgpack](https://github.com/kengonakajima/lua-msgpack) (pure Lua)\n - [lua-msgpack-native](https://github.com/kengonakajima/lua-msgpack-native)\n   (Lua-specific C implementation targeting luvit)\n - [MPLua](https://github.com/nobu-k/mplua) (binding)\n\nBefore luajit-msgpack-pure, I had written [luajit-msgpack](https://github.com/catwell/cw-lua/tree/master/luajit-msgpack), a FFI binding which is now deprecated.\n\n## TODO\n\n- Missing datatype tests\n- Comparison tests vs. other implementations\n\n## Usage\n\n### Basics\n\n```lua\nlocal mp = require \"luajit-msgpack-pure\"\nlocal my_data = {this = {\"is\",4,\"test\"}}\nlocal encoded = mp.pack(my_data)\nlocal offset,decoded = mp.unpack(encoded)\nassert(offset == #encoded)\n```\n\n### Concatenating encoded data\n\n```lua\nlocal mp = require \"luajit-msgpack-pure\"\nlocal my_data_1 = 42\nlocal my_data_2 = \"foo\"\nlocal encoded = mp.pack(my_data_1) .. mp.pack(my_data_2)\nlocal offset_1,decoded_1 = mp.unpack(encoded)\nassert(decoded_1 == 42)\nlocal offset_2,decoded_2 = mp.unpack(encoded,offset_1)\nassert(decoded_2 == \"foo\")\nlocal offset_3,decoded_3 = mp.unpack(encoded,offset_2)\nassert((not offset_3) and (decoded_3 == nil))\n```\n\n### Setting floating point precision\n\n```lua\nlocal mp = require \"luajit-msgpack-pure\"\nlocal my_data = math.pi\nlocal encoded_1 = mp.pack(my_data) -- default is double\nlocal offset_1,decoded_1 = mp.unpack(encoded_1)\nassert(offset_1 == 9) -- 1 byte overhead + 8 bytes double\nassert(decoded_1 == math.pi)\nmp.set_fp_type(\"float\")\nlocal encoded_2 = mp.pack(my_data)\nlocal offset_2,decoded_2 = mp.unpack(encoded_2)\nassert(offset_2 == 5) -- 1 byte overhead + 5 bytes float\nassert(decoded_2 ~= math.pi) -- loss of precision\nmp.set_fp_type(\"double\") -- back to double precision\nlocal encoded_3 = mp.pack(my_data)\nlocal offset_3,decoded_3 = mp.unpack(encoded_3)\nassert((offset_3 == 9) and (decoded_3 == math.pi))\n```\n## Copyright\n\nCopyright (c) 2011-2019 Pierre Chapuis\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatwell%2Fluajit-msgpack-pure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcatwell%2Fluajit-msgpack-pure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcatwell%2Fluajit-msgpack-pure/lists"}