Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including stringencoding with all npm packages installed. Try it out:

var stringencoding = require("stringencoding")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

stringencoding v0.0.0

Encode to/from Typed Array buffers

stringencoding

basic usage

// encode a string into a typed array given an encoding
var uint8array = TextEncoder(encoding).encode(string);

// decode typed array into a string
var string = TextDecoder(encoding).decode(uint8array);

streaming decode

var string = '';
var decoder = TextDecoder(encoding), buffer;

while (buffer = next_chunk()) {
    string += decoder.decode(buffer, { stream:true });
}

string += decoder.decode(); // finish the stream

install

npm install stringencoding

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free