Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/whatwg-encoding

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

@types/whatwg-encoding

TypeScript definitions for whatwg-encoding

  • 2.0.3
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.7K
decreased by-18.31%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install --save @types/whatwg-encoding

Summary

This package contains type definitions for whatwg-encoding (https://github.com/jsdom/whatwg-encoding).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/whatwg-encoding.

index.d.ts

/**
 * Performs the [decode](https://encoding.spec.whatwg.org/#decode) algorithm (in which any BOM will override
 * the passed fallback encoding).
 *
 * @returns The resulting string.
 * @throws `RangeError` if an unsupported encoding is provided for `fallbackEncodingName`.
 *
 * @example
 * import { decode } from "whatwg-encoding";
 *
 * console.assert(decode(new Uint8Array([0x48, 0x69]), "UTF-8") === "Hi");
 */
export function decode(uint8Array: Uint8Array, fallbackEncodingName: string): string;
/**
 * Performs the [get an encoding](https://encoding.spec.whatwg.org/#concept-encoding-get) algorithm.
 *
 * @returns The resulting encoding's name, or `null` for failure.
 *
 * @example
 * import { labelToName } from "whatwg-encoding";
 *
 * console.assert(labelToName("latin1") === "windows-1252");
 * console.assert(labelToName("  CYRILLic ") === "ISO-8859-5");
 */
export function labelToName(label: string): string | null;
/**
 * Checks whether the encoding is one of [the encodings](https://encoding.spec.whatwg.org/#names-and-labels)
 * of the Encoding Standard, _and_ is an encoding that this package can decode (via `iconv-lite`).
 *
 * @example
 * import { isSupported } from "whatwg-encoding";
 *
 * console.assert(isSupported("IBM866") === true);
 *
 * // Not supported by the Encoding Standard
 * console.assert(isSupported("UTF-32") === false);
 *
 * // In the Encoding Standard, but this package can't decode it
 * console.assert(isSupported("x-mac-cyrillic") === false);
 */
export function isSupported(name: string): boolean;
/**
 * Sniffs the first 2–3 bytes of the supplied `Uint8Array`.
 *
 * @returns One of the encoding names if the appropriate BOM is present, or `null` if no BOM is present.
 *
 * @example
 * import { getBOMEncoding } from "whatwg-encoding";
 *
 * console.assert(getBOMEncoding(new Uint8Array([0xFE, 0xFF])) === "UTF-16BE");
 * console.assert(getBOMEncoding(new Uint8Array([0x48, 0x69])) === null);
 */
export function getBOMEncoding(uint8Array: Uint8Array): BOMEncoding | null;

export type BOMEncoding = "UTF-16BE" | "UTF-16LE" | "UTF-8";

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: none

Credits

These definitions were written by fengkx, and BendingBender.

FAQs

Package last updated on 07 Nov 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc