Skip to content

Commit

Permalink
Add TypeScript typings
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbynens committed Nov 28, 2021
1 parent 10e7d5d commit d995bc8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"bugs": "https://github.com/mathiasbynens/koi8-r/issues",
"files": [
"LICENSE-MIT.txt",
"koi8-r.mjs"
"koi8-r.mjs",
"koi8-r.d.ts"
],
"types": "koi8-r.d.ts",
"scripts": {
"download": "curl https://encoding.spec.whatwg.org/index-koi8-r.txt > data/index.txt",
"build": "node scripts/transform-data.js",
Expand Down
18 changes: 18 additions & 0 deletions src/koi8-r.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
declare module 'koi8-r' {
type EncodeOptions = {
mode: 'fatal' | 'replacement';
};
type DecodeOptions = {
mode: 'fatal' | 'replacement';
};

export declare function encode(
text: string,
options?: EncodeOptions
): Uint16Array;
export declare function decode(
buffer: Uint16Array | Uint8Array | Buffer | string,
options?: DecodeOptions
): string;
export type labels = string[];
}

0 comments on commit d995bc8

Please sign in to comment.