🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@types/html-encoding-sniffer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/html-encoding-sniffer

TypeScript definitions for html-encoding-sniffer

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
ts5.9
ts6.0
latest
Source
npmnpm
Version
3.0.2
Version published
Weekly downloads
20K
2.84%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install --save @types/html-encoding-sniffer

Summary

This package contains type definitions for html-encoding-sniffer (https://github.com/jsdom/html-encoding-sniffer#readme).

Details

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

index.d.ts

/**
 * Determine the Encoding of a HTML Byte Stream.
 *
 * Implements the HTML Standard's
 * [encoding sniffing algorithm](https://html.spec.whatwg.org/multipage/syntax.html#encoding-sniffing-algorithm)
 * in all its glory. The most interesting part of this is how it pre-scans the first 1024 bytes in order to search
 * for certain `<meta charset>`-related patterns.
 *
 * @param htmlBytes The typed array containing the (X)HTML source text.
 *
 * @return The canonical [encoding name](https://encoding.spec.whatwg.org/#names-and-labels)
 *         for use with the [`whatwg-encoding`](https://github.com/jsdom/whatwg-encoding) or similar package.
 *
 * @example
 * import htmlEncodingSniffer = require("html-encoding-sniffer");
 * import * as fs from "fs";
 *
 * const htmlBytes = fs.readFileSync("./html-page.html");
 * const sniffedEncoding = htmlEncodingSniffer(htmlBytes);
 */
declare function sniffHTMLEncoding(htmlBytes: Uint8Array, options?: sniffHTMLEncoding.Options): string;

declare namespace sniffHTMLEncoding {
    interface Options {
        /**
         * An encoding label that is obtained from the "transport layer"
         * (probably an HTTP `Content-Type` header), which overrides
         * everything but a BOM.
         */
        transportLayerEncodingLabel?: string | undefined;

        /**
         * The ultimate fallback encoding used if no valid encoding is supplied
         * by the transport layer, and no encoding is sniffed from the bytes.
         *
         * @default
         * ```
         * 'windows-1252'
         * ```
         *
         * Which is recommended by the algorithm's table of suggested
         * defaults for "All other locales" (including the `en` locale).
         */
        defaultEncoding?: string | undefined;
    }
}

export = sniffHTMLEncoding;

Additional Details

  • Last updated: Tue, 07 Nov 2023 03:09:37 GMT
  • Dependencies: none

Credits

These definitions were written by ExE Boss, 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