Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#34 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
20/100
Tipo di issue
Documentazione
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, nodejs
Ambito
web-dev

Direzione di ricerca

Inizia con request_test3.js e il bundle browser safe-buffer.js descritto nella issue. Testa la configurazione dell’estensione Chrome per determinare come viene inizializzato Buffer e se il bundle funziona con l’esempio di compressione pako. Il lavoro è completato quando viene documentato un percorso di utilizzo confermato compatibile con il browser oppure la limitazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
346
Fork
47
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di feross/safe-buffer

Tutte le issue di feross/safe-buffer

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.