Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
web-encoding
Advanced tools
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
The web-encoding package provides a polyfill for the TextEncoder and TextDecoder interfaces, which are part of the Encoding Living Standard. These interfaces allow for high-performance encoding and decoding of text in various character encodings, primarily UTF-8.
Text Encoding
This feature allows you to encode a JavaScript string into a Uint8Array of bytes using UTF-8 encoding. It is useful for preparing text data for network transmission or storage.
const { TextEncoder } = require('web-encoding');
const encoder = new TextEncoder();
const encoded = encoder.encode('Hello, world!');
console.log(encoded);
Text Decoding
This feature enables decoding of a Uint8Array of bytes into a JavaScript string using UTF-8 or other supported character encodings. It is essential for reading text data received from a network or read from binary storage.
const { TextDecoder } = require('web-encoding');
const decoder = new TextDecoder('utf-8');
const decoded = decoder.decode(new Uint8Array([72, 101, 108, 108, 111]));
console.log(decoded);
The text-encoding package also provides TextEncoder and TextDecoder polyfills. It supports a wider range of encodings than web-encoding, making it suitable for applications that need to handle various character sets beyond UTF-8.
Similar to web-encoding, fast-text-encoding offers TextEncoder and TextDecoder implementations. It focuses on performance optimizations for UTF-8 encoding and decoding, making it a good choice for performance-critical applications that primarily deal with UTF-8 data.
This package provides TextEncoder and TextDecoder Encoding Standard
APIs in a universal package. In the browsers it just exposes existing globals,
in nodejs it exposes globals in newer node versions and ones from util
module
in older versions, and in the React Native environments it exposes these from
the @zxing/text-encoding
polyfill (installed as an optional dependency).
Package also works as ES module and CommonJS module.
import { TextEncoder, TextDecoder } from "web-encoding"
npm install web-encoding
FAQs
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
The npm package web-encoding receives a total of 1,234,042 weekly downloads. As such, web-encoding popularity was classified as popular.
We found that web-encoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.