@types/fast-text-encoding
Version:
TypeScript definitions for fast-text-encoding
80 lines (64 loc) • 2.23 kB
Markdown
# Installation
> `npm install --save @types/fast-text-encoding`
# Summary
This package contains type definitions for fast-text-encoding (https://github.com/samthor/fast-text-encoding#readme).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fast-text-encoding.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fast-text-encoding/index.d.ts)
````ts
/**
* fast-text-encoding does not export any members, but defines the global classes
* 1) TextDecoder (https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder)
* 2) TextEncoder (https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder)
* if they are not already defined.
*
* We do not declare these globals here since they are already declared in "lib.dom.d.ts" and would
* result in name collisions. Instead, we export the types so that `TextDecoder` and `TextEncoder`
* can be manually declared in a non-DOM environment (see tests).
*/
declare namespace fastTextEncoding {
/**
* Options for `TextDecoder.decode` and `TextEncoder.encode`.
*/
interface TextEncodingOptions {
stream: boolean;
}
/**
* Options for TextDecoder constructor.
*/
interface TextDecoderOptions {
fatal: boolean;
}
/**
* TextDecoder instance.
*/
class TextDecoderClass {
encoding: string;
fatal: boolean;
ignoreBOM: boolean;
constructor(utfLabel?: string, options?: TextDecoderOptions);
decode(buffer: Uint8Array, options?: TextEncodingOptions): string;
}
/**
* TextEncoder instance.
*/
class TextEncoderClass {
encoding: string;
constructor(label?: string);
encode(string: string, options?: TextEncodingOptions): Uint8Array;
}
/**
* TextDecoder class.
*/
type TextDecoder = typeof TextDecoderClass;
/**
* TextEncoder class.
*/
type TextEncoder = typeof TextEncoderClass;
}
````
### Additional Details
* Last updated: Tue, 07 Nov 2023 03:09:37 GMT
* Dependencies: none
# Credits
These definitions were written by [Ciarán Ingle](https://github.com/inglec-arista).