fast-text-encoding: Add v1 types (#40564)

This commit is contained in:
inglec-arista
2019-11-22 10:54:34 -08:00
committed by Sheetal Nandi
parent 9fec3bbf15
commit 138d4e6c93
4 changed files with 68 additions and 0 deletions
@@ -0,0 +1,20 @@
import 'fast-text-encoding';
const encoder1 = new TextEncoder();
const _encoder2 = new TextEncoder('utf-8');
const _encoderEncoding = encoder1.encoding;
const _encoded1 = encoder1.encode('foo');
const _encoded2 = encoder1.encode('foo', { stream: false });
const decoder1 = new TextDecoder();
const _decoder2 = new TextDecoder('utf-8');
const _decoder3 = new TextDecoder('utf-8', { fatal: false });
const _decoderEncoding = decoder1.encoding;
const _decoderFatal = decoder1.fatal;
const _decoderIgnoreBOM = decoder1.ignoreBOM;
const _decoded1 = decoder1.decode(new Uint8Array(16));
const _decoded2 = decoder1.decode(new Uint8Array(16), { stream: false });
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for fast-text-encoding 1.0
// Project: https://github.com/samthor/fast-text-encoder#readme
// Definitions by: Ciarán Ingle <https://github.com/inglec-arista>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace fastTextEncoder {
interface Options {
stream: boolean;
}
}
declare class TextEncoder {
encoding: string;
constructor(label?: string);
encode(string: string, options?: fastTextEncoder.Options): Uint8Array;
}
declare class TextDecoder {
encoding: string;
fatal: boolean;
ignoreBOM: boolean;
constructor(utfLabel?: string, options?: { fatal: boolean });
decode(buffer: Uint8Array, options?: fastTextEncoder.Options): string;
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"fast-text-encoding-tests.ts",
"index.d.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }