New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@borewit/text-codec

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@borewit/text-codec

Text Decoder

Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
11M
1.92%
Maintainers
1
Weekly downloads
 
Created
Source

CI npm version npm downloads bundlejs License: MIT

@borewit/text-codec

A lightweight alternative implementation of TextEncoder / TextDecoder supporting common encodings missing in some JavaScript engines and Node.js builds.
Works in environments like Hermes (React Native) or Small-ICU Node.js where only UTF-8 and UTF-16LE are available.

EncodingHermes — EncodeHermes — DecodeSmall-ICU Node.js — EncodeSmall-ICU Node.js — Decode
utf-8 / utf8NativeNativeNative
utf-16leNativeNative
ascii
latin1 / iso-8859-1Native (sometimes)
windows-1252

Legend:

  • Native — Supported natively by the JavaScript engine.
  • — Support added by this module.
  • Native (sometimes) — Available in some builds (e.g., certain Small-ICU Node.js builds).

When your project needs to handle encodings like latin1 / iso-8859-1 or windows-1252 in these environments, native TextDecoder / TextEncoder may throw an error or return incorrect results.

✨ Features

  • Decoding and encoding
  • Lightweight
  • Typed

Supported encodings:

  • utf-8 / utf8
  • utf-16le
  • ascii
  • latin1 / iso-8859-1
  • windows-1252

📦 Installation

npm install @borewit/text-codec

📚 API Documentation

textDecode(bytes, encoding): string

Decodes binary data into a JavaScript string using the specified encoding.

Parameters

  • bytes (Uint8Array) — The binary data to decode.
  • encoding (SupportedEncoding, optional) — Encoding type. Defaults to "utf-8".

Returns

  • string — The decoded text.

Example

import { textDecode } from "@borewit/text-encode";

const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
const text = textDecode(bytes, "ascii");
console.log(text); // "Hello"

Encodes a JavaScript string into binary form using the specified encoding.

textEncode(input, encoding): Uint8Array

Parameters

  • input (string) — The string to encode.
  • encoding (SupportedEncoding, optional) — Encoding type. Defaults to "utf-8".

Returns

Uint8Array — The encoded binary data.

Example:

import { textEncode } from "@borewit/text-encode";

const bytes = textEncode("Hello", "utf-16le");
console.log(bytes); // Uint8Array([...])

📜 Licence

This project is licensed under the MIT License. Feel free to use, modify, and distribute as needed.

Keywords

TextDecoder

FAQs

Package last updated on 29 Dec 2025

Did you know?

Socket

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.

Install

Related posts