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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 18:00:54  来源:igfitidea点击:

pack / unpack functions for node.js

javascriptstructnode.jspackunpack

提问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 structAPI 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 binaryif you have npm installed.

https://github.com/substack/node-binary提供解包,也是用JS实现的,npm install binary如果你安装了npm就可以安装。

回答by Touv

回答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。