Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

"safe-buffer" -- Can this be used/dropped into a Javascript app for a Browser/Extension (Chrome)

未关闭
#34 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
20/100
Issue 类型
文档
描述清晰度
需要澄清
活跃度
停滞
技术栈
javascript, nodejs
领域
web-dev

调研方向

从 issue 中描述的 request_test3.js 和 safe-buffer.js 浏览器 bundle 开始。测试 Chrome 扩展的设置,以确定 Buffer 的初始化方式,以及该 bundle 是否能与 pako 压缩示例配合工作。完成标准是记录一种已确认的浏览器兼容使用路径,或记录其限制。

由索引模型根据 Issue 内容生成。

描述

Update::

In my testing, I've managed to use nodejs/npm/bowserify to create a "safe-buffer.js" that might work in the browser.

However, I don't have a clue (yet) as to how to invoke the "Browser" for my test.

In a normal nodejs kind of script, the following line would be used:
var Buffer = require('safe-buffer').Buffer

I'm not quite sure what my test should have to init a Buffer in my script.

The sample code I'm trying to test is:
As a test, the lines of code I'm trying to test are: (within the request_test3.js
.
const compress = str => Buffer.from(pako.deflateRaw(str)).toString('base64');
console.log(compress('asdfasdfasdfasdf')); //SyxOSUtEwgA=
.
.

Any thoughts??

thanks

Hi.

I'm doing a test app in Chrome/Extension. Dealing with the pako.gzip compression in the Extension, and decompressing on the Server/Php side.

The issues I seem to be running into imply that possible solutions use code which need to have a "polyfil" for the "Buffer".

Given that my skillset with Javascript, is limited, I was wondering if this might work so I can test it out?

<src="safe-buffer.js"> <<< this kind of thing?

thanks

ps.
The test "code" from stackoverflow that I'm referring to is :

//JS
const pako = require('pako');
const compress = str => Buffer.from(pako.deflateRaw(str)).toString('base64');
console.log(compress('asdfasdfasdfasdf')); //SyxOSUtEwgA=
//PHP
function decompress($str) { return gzinflate(base64_decode($str)); }
echo decompress('SyxOSUtEwgA='); //asdfasdfasdfasdf

(the author states)
Note: Buffer instances are also Uint8Array instances, hence we don't need to convert the Buffer to a Uint8Array before giving it to pako.

For JS, this works out of the box in NodeJs. In a browser environment, you will need a polyfil for Buffer.

主要语言
JavaScript
星标
346
派生
47
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

feross/safe-buffer 的其他 Issue

查看 feross/safe-buffer 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。