Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012 polygonplanet
Copyright (c) 2012-present polygonplanet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -19,3 +19,27 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

-----

Third-Party Licenses and Credits

TypeScript declarations and type tests are based on the type definitions for
encoding-japanese from DefinitelyTyped, licensed under the MIT License.

Upstream package: @types/encoding-japanese 2.2.1

The LICENSE distributed with @types/encoding-japanese states:

Copyright (c) Microsoft Corporation.

The LICENSE in the DefinitelyTyped repository states:

Copyrights are respective of each contributor listed at the beginning of
each definition file.

The contributors credited in the upstream package are:
rhysd (https://github.com/rhysd)
Piotr Błażejewicz (https://github.com/peterblazejewicz)

The MIT License terms stated above apply equally to these files.
102 changes: 102 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// TypeScript declarations originally from DefinitelyTyped
// Upstream package: @types/encoding-japanese 2.2.1
// Thanks to the DefinitelyTyped contributors
// Licensed under the MIT License. See the LICENSE file

export as namespace Encoding;

export type Encoding =
| "UTF32"
| "UTF16"
| "UTF16BE"
| "UTF16LE"
| "BINARY"
| "ASCII"
| "JIS"
| "UTF8"
| "EUCJP"
| "SJIS"
| "UNICODE"
| "AUTO";
type IntArrayType =
| readonly number[]
| Uint8Array
| Uint16Array
| Uint32Array
| Int8Array
| Int16Array
| Int32Array;
type EncodingDetection = Encoding | false;

export type ConvertOptions =
| ConvertStringOptions
| ConvertArrayBufferOptions
| ConvertArrayOptions
| ConvertUnknownOptions;

export interface ConvertStringOptions {
to: Encoding;
from?: Encoding | undefined;
type: "string";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export interface ConvertArrayBufferOptions {
to: Encoding;
from?: Encoding | undefined;
type: "arraybuffer";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export interface ConvertArrayOptions {
to: Encoding;
from?: Encoding | undefined;
type: "array";
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export interface ConvertUnknownOptions {
to: Encoding;
from?: Encoding | undefined;
fallback?: "html-entity" | "html-entity-hex" | "ignore" | "error";
bom?: boolean | string | undefined;
}

export function detect(data: IntArrayType | string, encodings?: Encoding | Encoding[]): EncodingDetection;
export function convert(data: IntArrayType, to: Encoding, from?: Encoding): number[];
export function convert(data: string, to: Encoding, from?: Encoding): string;
export function convert(data: IntArrayType | string, options: ConvertStringOptions): string;
export function convert(data: IntArrayType | string, options: ConvertArrayBufferOptions): Uint16Array;
export function convert(data: IntArrayType | string, options: ConvertArrayOptions): number[];
export function convert(data: string, options: ConvertUnknownOptions): string;
export function convert(data: IntArrayType, options: ConvertUnknownOptions): number[];
export function urlEncode(data: IntArrayType): string;
export function urlDecode(data: string): number[];
export function base64Encode(data: IntArrayType): string;
export function base64Decode(data: string): number[];
export function codeToString(data: IntArrayType): string;
export function stringToCode(data: string): number[];
export function toHankakuCase(data: readonly number[]): number[];
export function toHankakuCase(data: string): string;
export function toZenkakuCase(data: readonly number[]): number[];
export function toZenkakuCase(data: string): string;
export function toHiraganaCase(data: readonly number[]): number[];
export function toHiraganaCase(data: string): string;
export function toKatakanaCase(data: readonly number[]): number[];
export function toKatakanaCase(data: string): string;
export function toHankanaCase(data: readonly number[]): number[];
export function toHankanaCase(data: string): string;
export function toZenkanaCase(data: readonly number[]): number[];
export function toZenkanaCase(data: string): string;
export function toHankakuSpace(data: readonly number[]): number[];
export function toHankakuSpace(data: string): string;
export function toZenkakuSpace(data: readonly number[]): number[];
export function toZenkakuSpace(data: string): string;

export const version: string;
export const orders: string[];

export {};
Loading