转换nodejs'缓冲浏览器'javascript [英] Convert nodejs' Buffer to browsers' javascript
问题描述
我正在将代码从Node.js转换为浏览器的javascript,但是我对node.js中的缓冲区有问题.如何在Javascript中使用它们?
I'm converting my code from Node.js to browsers' javascript, but I have a problem with the Buffers in node.js. How can I use them in Javascript?
这是一个例子:
new Buffer("foo", encoding='utf8')
<Buffer 66 6f 6f>
我需要将javascript中的[66、6f,6f]转换为"foo",反之亦然.我怎样才能做到这一点?注意:必须在没有Node.js的情况下完成此操作.
I need to transform [66, 6f, 6f] in javascript to "foo" and vice-versa. How can I do that? NOTE: this must be done without Node.js.
推荐答案
使用 https://github.com/substack/node-browserify ,您可以使用以下浏览器在浏览器中使用缓冲区: https://github.com/toots/buffer-browserify .但是:这在浏览器中可能非常慢:要更快地访问,请使用 https://github.com/chrisdickinson/bops
With https://github.com/substack/node-browserify you can work with buffers in the Browser by using: https://github.com/toots/buffer-browserify. However: this can be very slow in the browser: For faster access use https://github.com/chrisdickinson/bops
这篇关于转换nodejs&#39;缓冲浏览器&#39;javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!