punycode-esm 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -19
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<div style="text-align:center">
|
|
2
2
|
|
|
3
3
|
# punycode-esm
|
|
4
|
+
|
|
4
5
|
ESM and TypeScript port of the punycode.js library.
|
|
5
6
|
|
|
6
7
|
[](https://www.npmjs.com/package/punycode-esm)
|
|
@@ -9,6 +10,7 @@ ESM and TypeScript port of the punycode.js library.
|
|
|
9
10
|
</div>
|
|
10
11
|
|
|
11
12
|
## Contents
|
|
13
|
+
|
|
12
14
|
- [Install](#install)
|
|
13
15
|
- [Example](#example)
|
|
14
16
|
- [Usage](#usage)
|
|
@@ -45,7 +47,7 @@ toUnicode('xn----dqo34k.com'); // '☃-⌘.com'
|
|
|
45
47
|
|
|
46
48
|
`punycode-esm` is an ESM module. It must be `import`ed. To load from a CJS module, use dynamic import: `const { encode } = await import('punycode-esm')`.
|
|
47
49
|
|
|
48
|
-
Functions throw `RangeError` for malformed Punycode: `decode` and `toUnicode` for input that is not ASCII (`Invalid input`), is not valid Punycode, or needs wider integers than JavaScript numbers hold (`Overflow: input needs wider integers to process`); `encode` and `toASCII` for the overflow case only. `toASCII` and `toUnicode` only convert labels, and do none of the other IDNA processing: no case folding, no Unicode normalization and no length checks. They split on `.` and the other full-stop characters `。`, `.` and `。` (all written as `.` in the result), and only
|
|
50
|
+
Functions throw `RangeError` for malformed Punycode: `decode` and `toUnicode` for input that is not ASCII (`Invalid input`), is not valid Punycode, or needs wider integers than JavaScript numbers hold (`Overflow: input needs wider integers to process`); `encode` and `toASCII` for the overflow case only. `toASCII` and `toUnicode` only convert labels, and do none of the other IDNA processing: no case folding, no Unicode normalization and no length checks. They split on `.` and the other full-stop characters `。`, `.` and `。` (all written as `.` in the result), and only recognize the lowercase `xn--` prefix.
|
|
49
51
|
|
|
50
52
|
## API
|
|
51
53
|
|
|
@@ -55,9 +57,9 @@ Converts a string of Unicode symbols (a single domain label) to a Punycode strin
|
|
|
55
57
|
|
|
56
58
|
**Parameters**
|
|
57
59
|
|
|
58
|
-
| Parameter | Type
|
|
59
|
-
|
|
60
|
-
| `string`
|
|
60
|
+
| Parameter | Type | Default | Description |
|
|
61
|
+
| --------- | -------- | ------- | ------------------------------------------- |
|
|
62
|
+
| `string` | `string` | — | Required. A Unicode domain label (no dots). |
|
|
61
63
|
|
|
62
64
|
**Returns** `string` — the Punycode-encoded ASCII label.
|
|
63
65
|
|
|
@@ -74,9 +76,9 @@ Converts a Punycode string of ASCII-only symbols (a single domain label) to a st
|
|
|
74
76
|
|
|
75
77
|
**Parameters**
|
|
76
78
|
|
|
77
|
-
| Parameter | Type
|
|
78
|
-
|
|
79
|
-
| `string`
|
|
79
|
+
| Parameter | Type | Default | Description |
|
|
80
|
+
| --------- | -------- | ------- | --------------------------------------------------- |
|
|
81
|
+
| `string` | `string` | — | Required. A Punycode-encoded ASCII label (no dots). |
|
|
80
82
|
|
|
81
83
|
**Returns** `string` — the decoded Unicode label.
|
|
82
84
|
|
|
@@ -93,9 +95,9 @@ Converts a Unicode domain name or email address to its Punycode (ASCII) represen
|
|
|
93
95
|
|
|
94
96
|
**Parameters**
|
|
95
97
|
|
|
96
|
-
| Parameter | Type
|
|
97
|
-
|
|
98
|
-
| `string`
|
|
98
|
+
| Parameter | Type | Default | Description |
|
|
99
|
+
| --------- | -------- | ------- | ------------------------------------------------- |
|
|
100
|
+
| `string` | `string` | — | Required. A Unicode domain name or email address. |
|
|
99
101
|
|
|
100
102
|
**Returns** `string` — the ASCII-compatible encoding of the domain or email.
|
|
101
103
|
|
|
@@ -113,9 +115,9 @@ Converts a Punycode domain name or email address to Unicode. Only Punycode-encod
|
|
|
113
115
|
|
|
114
116
|
**Parameters**
|
|
115
117
|
|
|
116
|
-
| Parameter | Type
|
|
117
|
-
|
|
118
|
-
| `string`
|
|
118
|
+
| Parameter | Type | Default | Description |
|
|
119
|
+
| --------- | -------- | ------- | -------------------------------------------------- |
|
|
120
|
+
| `string` | `string` | — | Required. A Punycode domain name or email address. |
|
|
119
121
|
|
|
120
122
|
**Returns** `string` — the Unicode representation of the domain or email.
|
|
121
123
|
|
|
@@ -133,9 +135,9 @@ Creates an array of Unicode code point values from a string. Surrogate pairs (as
|
|
|
133
135
|
|
|
134
136
|
**Parameters**
|
|
135
137
|
|
|
136
|
-
| Parameter | Type
|
|
137
|
-
|
|
138
|
-
| `string`
|
|
138
|
+
| Parameter | Type | Default | Description |
|
|
139
|
+
| --------- | -------- | ------- | --------------------------------- |
|
|
140
|
+
| `string` | `string` | — | Required. A UCS-2 encoded string. |
|
|
139
141
|
|
|
140
142
|
**Returns** `number[]` — array of Unicode code point integers.
|
|
141
143
|
|
|
@@ -152,9 +154,9 @@ Creates a string from an array of Unicode code point values.
|
|
|
152
154
|
|
|
153
155
|
**Parameters**
|
|
154
156
|
|
|
155
|
-
| Parameter
|
|
156
|
-
|
|
157
|
-
| `codePoints` | `readonly number[]` | —
|
|
157
|
+
| Parameter | Type | Default | Description |
|
|
158
|
+
| ------------ | ------------------- | ------- | ----------------------------------------------- |
|
|
159
|
+
| `codePoints` | `readonly number[]` | — | Required. Array of Unicode code point integers. |
|
|
158
160
|
|
|
159
161
|
**Returns** `string` — the UCS-2 encoded string.
|
|
160
162
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "punycode-esm",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "ESM and TypeScript port of the punycode.js library.",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
6
|
+
"node": ">=22"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"author": "JacobLey",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"#errors": "./dist/lib/errors.js"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@biomejs/biome": "^2.
|
|
40
|
+
"@biomejs/biome": "^2.6.4",
|
|
41
41
|
"@leyman/eslint-config": "^0.0.1",
|
|
42
42
|
"@leyman/expect": "^0.0.1",
|
|
43
43
|
"@swc/cli": "^0.8.1",
|
|
44
|
-
"@swc/core": "^1.16.
|
|
44
|
+
"@swc/core": "^1.16.20",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|
|
46
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^22.20.5",
|
|
47
47
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
48
48
|
"c8": "^12.0.0",
|
|
49
49
|
"eslint": "^10.13.0",
|
|
50
50
|
"mocha": "^12.0.3",
|
|
51
|
-
"mocha-chain": "^1.0
|
|
51
|
+
"mocha-chain": "^1.1.0",
|
|
52
52
|
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
53
53
|
}
|
|
54
54
|
}
|