mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
types: add types of whatwg-encoding (#43328)
* types: add types of whatwg-encoding * rename to tests
This commit is contained in:
parent
7b906f2a33
commit
548030f4f9
10
types/whatwg-encoding/index.d.ts
vendored
Normal file
10
types/whatwg-encoding/index.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
// Type definitions for whatwg-encoding 1.0
|
||||
// Project: https://github.com/jsdom/whatwg-encoding
|
||||
// Definitions by: fengkx <https://github.com/fengkx>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
export function decode(buffer: Buffer, fallbackEncodingName: string): string;
|
||||
export function labelToName(label: string): string | null;
|
||||
export function isSupported(name: string): boolean;
|
||||
export function getBOMEncoding(buffer: Buffer): string | null;
|
||||
16
types/whatwg-encoding/tsconfig.json
Normal file
16
types/whatwg-encoding/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "whatwg-encoding-tests.ts"]
|
||||
}
|
||||
1
types/whatwg-encoding/tslint.json
Normal file
1
types/whatwg-encoding/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
17
types/whatwg-encoding/whatwg-encoding-tests.ts
Normal file
17
types/whatwg-encoding/whatwg-encoding-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import whatwgEncoding = require('whatwg-encoding');
|
||||
|
||||
console.assert(whatwgEncoding.labelToName('latin1') === 'windows-1252');
|
||||
console.assert(whatwgEncoding.labelToName(' CYRILLic ') === 'ISO-8859-5');
|
||||
|
||||
console.assert(whatwgEncoding.isSupported('IBM866'));
|
||||
|
||||
// Not supported by the Encoding Standard
|
||||
console.assert(!whatwgEncoding.isSupported('UTF-32'));
|
||||
|
||||
// In the Encoding Standard, but this package can't decode it
|
||||
console.assert(!whatwgEncoding.isSupported('x-mac-cyrillic'));
|
||||
|
||||
console.assert(whatwgEncoding.getBOMEncoding(Buffer.from([0xfe, 0xff])) === 'UTF-16BE');
|
||||
console.assert(whatwgEncoding.getBOMEncoding(Buffer.from([0x48, 0x69])) === null);
|
||||
|
||||
console.assert(whatwgEncoding.decode(Buffer.from([0x48, 0x69]), 'UTF-8') === 'Hi');
|
||||
Loading…
Reference in New Issue
Block a user