Javascript node.js 的打包/解包函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5605108/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pack / unpack functions for node.js
提问by Adam M-W
Are there any modules that provide pack / unpack functionality for nodejs similar to python's struct module? I haven't found any specifically for node, and I'd assume that javascript implementations would be significantly slower.
是否有任何模块为类似于 python 的 struct 模块的 nodejs 提供打包/解包功能?我还没有找到任何专门针对 node 的,我认为 javascript 实现会明显变慢。
Thanks.
谢谢。
采纳答案by clee
https://github.com/pgriess/node-jspackappears to be a straight-up port of Python's struct
API for packing binary data, but it's implemented in JS. It doesn't appear to be packaged for npm yet.
https://github.com/pgriess/node-jspack似乎是 Pythonstruct
用于打包二进制数据的API的直接端口,但它是在 JS 中实现的。它似乎还没有为 npm 打包。
https://github.com/substack/node-binaryprovides unpacking, also implemented in JS, and you can install it with npm install binary
if you have npm installed.
https://github.com/substack/node-binary提供解包,也是用JS实现的,npm install binary
如果你安装了npm就可以安装。
回答by Touv
https://github.com/ryanrolds/bufferpackis another solution
回答by danvk
jBinaryis another tool in this space which seems to be actively maintained (as of late 2014). It includes sample specificationsfor a variety of well-known formats, e.g. tar, ico and mp3.
jBinary是这个领域的另一个工具,它似乎得到了积极维护(截至 2014 年底)。它包括各种知名格式的样本规范,例如 tar、ico 和 mp3。