{"id":15047970,"url":"https://github.com/montyanderson/construction","last_synced_at":"2026-01-02T04:38:21.589Z","repository":{"id":43790546,"uuid":"72843242","full_name":"montyanderson/construction","owner":"montyanderson","description":":construction: Interface with binary structures in Javascript, built for network protocols.","archived":false,"fork":false,"pushed_at":"2016-11-05T00:00:37.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-23T16:19:57.809Z","etag":null,"topics":["binary","buffer","c","construction","cpp","interface","javascript","network-protocol","node"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/construction","language":"JavaScript","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/montyanderson.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":"2016-11-04T11:50:11.000Z","updated_at":"2017-07-17T16:44:38.000Z","dependencies_parsed_at":"2022-08-26T23:11:07.914Z","dependency_job_id":null,"html_url":"https://github.com/montyanderson/construction","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/montyanderson%2Fconstruction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montyanderson%2Fconstruction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montyanderson%2Fconstruction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/montyanderson%2Fconstruction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/montyanderson","download_url":"https://codeload.github.com/montyanderson/construction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489778,"owners_count":20298997,"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","buffer","c","construction","cpp","interface","javascript","network-protocol","node"],"created_at":"2024-09-24T21:06:23.007Z","updated_at":"2026-01-02T04:38:21.551Z","avatar_url":"https://github.com/montyanderson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# construction\n\n:construction: Interface with binary structures in Javascript, built for network protocols.\n\n[![Build Status](https://travis-ci.org/montyanderson/construction.svg?branch=master)](https://travis-ci.org/montyanderson/construction) [![npm version](https://badge.fury.io/js/construction.svg)](https://badge.fury.io/js/construction)\n\n## Features\n\n* Small, concise codebase with no dependencies.\n* Full test suite, testing *every type*.\n* Supports, Int8, Int16, Int32, UInt8, UInt16, UInt32.\n\n## To Do\n\n* Add char and array types.\n\n``` C\nstruct User {\n\tuint8_t age;\n\tint32_t favouriteNumber;\n}\n```\n\n``` javascript\nconst Construction = requrie(\"construction\");\nconst t = Construction.types;\n\nconst User = new Construction(\"LE\", {\n\tage: t.UInt8;\n\tfavouriteNumber: t.Int32\n});\n```\n\n## API\n\n### new Construction(endianness, object)\n\nCreate a new construction object.\n\n``` javascript\n// Endianness can be \"LE\" or \"BE\"\n\nconst User = new Construction(\"LE\", {\n\tage: t.UInt8,\n\tfavouriteNumber: t.Int32\n});\n```\n\n### buffer Construction#write(object)\n\nConvert a javascript object to a binary buffer.\n\n``` javascript\nconst buffer = User.write({\n\tage: 15,\n\tfavouriteNumber: 1000000\n});\n\nconsole.log(buffer);\n// \u003cBuffer 0f 40 42 0f 00\u003e\n```\n\n### object Construction#read(buffer)\n\nConvert a binary buffer to a javascript object.\n\n``` javascript\nconst user = User.read(Buffer.from(\"0f40420f00\", \"hex\"));\n\nconsole.log(user);\n// { age: 15, favouriteNumber: 1000000 }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmontyanderson%2Fconstruction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmontyanderson%2Fconstruction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmontyanderson%2Fconstruction/lists"}