forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type definitions for punycode.js
Since January 19th ([1]), the `punycode` package has also been published under `punycode.js`. This solves the problem of needing to use `punycode/` to use the package (as `punycode` is a built-in Node package). However, types are missing for `punycode.js`. So this commit adds them. Note that the interface for the package hasn't changed since v2.1, so I didn't bump the version, just copied the existing type definitions from `punycode`. [1]: mathiasbynens/punycode.js#122
- Loading branch information
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Type definitions for punycode.js 2.1 | ||
// Project: https://mths.be/punycode | ||
// Definitions by: Dmitry Guketlev <https://github.com/yavanosta> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
export function decode(input: string): string; | ||
export function encode(input: string): string; | ||
export function toUnicode(input: string): string; | ||
export function toASCII(input: string): string; | ||
|
||
export namespace ucs2 { | ||
function decode(string: string): number[]; | ||
function encode(array: ReadonlyArray<number>): string; | ||
} | ||
|
||
export const version: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import punycode = require('punycode.js'); | ||
|
||
const result1: string = punycode.decode('x'); | ||
const result2: string = punycode.encode('x'); | ||
const result3: string = punycode.toASCII('x'); | ||
const result4: string = punycode.toUnicode('x'); | ||
|
||
const ucs2result1: number[] = punycode.ucs2.decode('x'); | ||
const ucs2result2: string = punycode.ucs2.encode([1, 2, 3]); | ||
|
||
const version: string = punycode.version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"baseUrl": "../", | ||
"typeRoots": [ | ||
"../" | ||
], | ||
"types": [], | ||
"noEmit": true, | ||
"forceConsistentCasingInFileNames": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"punycode.js-tests.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "extends": "@definitelytyped/dtslint/dt.json" } |