{"id":18631306,"url":"https://github.com/bahamas10/node-destruct","last_synced_at":"2025-11-04T05:30:29.345Z","repository":{"id":3859636,"uuid":"4944658","full_name":"bahamas10/node-destruct","owner":"bahamas10","description":"Easily unpack C Structs and binary buffers","archived":false,"fork":false,"pushed_at":"2012-07-25T19:26:15.000Z","size":110,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T23:07:13.879Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bahamas10.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-08T08:18:26.000Z","updated_at":"2020-09-28T22:35:04.000Z","dependencies_parsed_at":"2022-09-16T00:01:14.078Z","dependency_job_id":null,"html_url":"https://github.com/bahamas10/node-destruct","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahamas10%2Fnode-destruct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahamas10%2Fnode-destruct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahamas10%2Fnode-destruct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahamas10%2Fnode-destruct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahamas10","download_url":"https://codeload.github.com/bahamas10/node-destruct/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239425427,"owners_count":19636346,"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":[],"created_at":"2024-11-07T05:06:32.513Z","updated_at":"2025-11-04T05:30:29.289Z","avatar_url":"https://github.com/bahamas10.png","language":"JavaScript","readme":"(De) Struct\n===========\n\nEasily unpack C Structs and binary buffers\n\nBased off the `unpack` function in Perl, and inspired by [prustat][1]\nby [Brendan Gregg][2].  There were other modules that claimed to have the same functionality,\nbut most of them were too poorly documented with the source code almost unreadable, while the\nothers were overcomplicated and didn't support a simple format string.\n\nInstall\n------\n\nInstall locally to use as a module\n\n    npm install destruct\n\nUsage\n-----\n\nas a module\n\n``` js\nvar destruct = require('destruct');\n```\n\nKnown Limitations\n-----------------\n\nThis module does not handle all data types, it has only been tested on SmartOS,\nand was built for making it easier to extend the [proc][3] Node module by [@dshaw][4].\n\nFunctions\n---------\n\n### destruct.unpack(fmt, buf, [pos])\n\nUnpack a given binary buffer with the given format starting from `pos` (default 0)\n\nExample\n-------\n\n``` js\nvar destruct = require('destruct'),\n    fs = require('fs');\n\nfs.readFile('/proc/self/psinfo', function(err, buf) {\n  console.log(destruct.unpack('iiiiiiiiiiIiiiiSSa8a8a8Z16Z80iiIIaa3iiiiii', buf));\n});\n```\n\nyields\n\n``` js\n[ 33554432,\n  3,\n  714,\n  18456,\n  714,\n  18456,\n  2011,\n  2011,\n  2300,\n  2300,\n  0,\n  14536,\n  9736,\n  0,\n  1572868,\n  11,\n  3,\n  \u003cBuffer 64 41 f9 4f 3b fe 6c 1a\u003e,\n  \u003cBuffer 00 00 00 00 35 d5 31 0b\u003e,\n  \u003cBuffer 00 00 00 00 00 00 00 00\u003e,\n  'node',\n  'node ./psinfo.js',\n  0,\n  2,\n  134511788,\n  134511800,\n  \u003cBuffer 01\u003e,\n  \u003cBuffer 00 00 00\u003e,\n  674523,\n  3,\n  0,\n  0,\n  29,\n  19167112 ]\n```\n\nLicense\n-------\n\nMIT Licensed\n\n[1]: http://www.brendangregg.com/DTrace/prustat\n[2]: http://www.brendangregg.com\n[3]: https://github.com/dshaw/proc\n[4]: https://github.com/dshaw\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahamas10%2Fnode-destruct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahamas10%2Fnode-destruct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahamas10%2Fnode-destruct/lists"}