UNPKG

@nberlette/utf8

Version:

Blazing fast universal ponyfills for TextEncoder and TextDecoder.

65 lines (64 loc) 4.83 kB
import * as dntShim from "./_dnt.shims.js"; export declare var undefined: undefined; export declare const $global: typeof dntShim.dntGlobalThis; type Uncurry<T, This = void> = T extends (this: infer ThisArg, ...args: infer A) => infer R ? [This] extends [void] ? (thisArg: ThisArg, ...args: A) => R : (thisArg: This, ...args: A) => R : T extends (...args: infer A) => infer R ? (thisArg: [This] extends [void] ? unknown : This, ...args: A) => R : never; export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor | (typeof dntShim.dntGlobalThis extends { Float16Array: infer F; } ? F : never); export type TypedArray = InstanceType<TypedArrayConstructor>; type TypedArrayToStringTag = TypedArray[typeof Symbol.toStringTag]; type TypedArrayFromTag<T extends TypedArrayToStringTag> = TypedArray extends infer A extends TypedArray ? A extends { [Symbol.toStringTag]: T; } ? A : never : never; export declare function isTypedArray<T extends TypedArrayToStringTag = TypedArrayToStringTag>(it: unknown, type?: T | undefined): it is TypedArrayFromTag<T>; export declare const Object: typeof globalThis.Object; export declare const ObjectGetPrototypeOf: (o: any) => any; export declare const ObjectDefineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T; export declare const ObjectGetOwnPropertyDescriptor: (o: any, p: PropertyKey) => PropertyDescriptor | undefined; export declare function gracefulDefine<T extends object, K extends PropertyKey, V>(target: T, key: K, value: V): asserts target is T & { [P in K]: P extends keyof T ? T[P] : V; }; export declare const toString: (thisArg: unknown) => string; export declare const Error: typeof globalThis.Error; export declare const TypeError: typeof globalThis.TypeError; export declare const RangeError: typeof globalThis.RangeError; export declare const ReferenceError: typeof globalThis.ReferenceError; export declare const Array: typeof globalThis.Array; export declare const Symbol: typeof globalThis.Symbol; export declare const ArrayBuffer: typeof globalThis.ArrayBuffer; export declare const ArrayBufferIsView: (arg: any) => arg is ArrayBufferView; export declare const ArrayBufferPrototypeGetByteLength: (thisArg: ArrayBuffer) => number; export declare const SharedArrayBuffer: typeof globalThis.SharedArrayBuffer; export declare const SharedArrayBufferPrototypeGetByteLength: (thisArg: SharedArrayBuffer) => number; export declare const Uint8Array: typeof globalThis.Uint8Array; export declare const Uint8ArrayPrototypeSlice: Uncurry<typeof Uint8Array.prototype.slice, Uint8Array>; export declare const Uint8ArrayPrototypeSubarray: Uncurry<typeof Uint8Array.prototype.subarray, Uint8Array>; export declare const TypedArray: TypedArrayConstructor; export declare const TypedArrayPrototype: InstanceType<TypedArrayConstructor>; export declare const TypedArrayPrototypeGetToStringTag: { (target: unknown): TypedArrayToStringTag | undefined; }; export declare const TypedArrayPrototypeSubarray: Uncurry<typeof TypedArrayPrototype.subarray, typeof TypedArrayPrototype>; export declare const String: typeof globalThis.String; export declare const StringFromCharCode: typeof String.fromCharCode; export declare const StringPrototype: typeof String.prototype; export declare const StringPrototypeCharCodeAt: Uncurry<typeof String.prototype.charCodeAt, string>; export declare const StringPrototypeReplace: Uncurry<typeof String.prototype.replace, string>; export declare const StringPrototypeSlice: Uncurry<typeof String.prototype.slice, string>; export declare const StringPrototypeCodePointAt: Uncurry<typeof String.prototype.codePointAt, string>; export declare const StringPrototypeToLowerCase: Uncurry<typeof String.prototype.toLowerCase, string>; export declare const StringPrototypeTrim: Uncurry<typeof String.prototype.trim, string>; export declare const Promise: typeof globalThis.Promise; export declare const PromiseResolve: { (): Promise<void>; <T>(value: T): Promise<Awaited<T>>; <T>(value: T | PromiseLike<T>): Promise<Awaited<T>>; }; export declare const PromiseReject: <T = never>(reason?: any) => Promise<T>; export declare const TransformStream: typeof globalThis.TransformStream; export type BufferSource = ArrayBufferLike | ArrayBufferView; export declare function getCodePoint(input: string, index: number): number; export declare function utf8BytesNeeded(codePoint: number): number; export declare function normalizeEncoding(label: string): string; export declare function toUint8Array(input?: BufferSource | null): Uint8Array; export {};