punycode-esm 1.0.6 → 1.0.8
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/.c8rc.json +46 -0
- package/.eslintcache/punycode-esm +1 -0
- package/CHANGELOG.md +10 -0
- package/LICENSE +1 -1
- package/README.md +9 -9
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/src/index.html +116 -0
- package/coverage/src/lib/errors.ts.html +181 -0
- package/coverage/src/lib/index.html +116 -0
- package/coverage/src/punycode.ts.html +1198 -0
- package/coverage/tmp/coverage-159909-1722832351784-0.json +1 -0
- package/coverage/tmp/coverage-159914-1722832351615-0.json +1 -0
- package/dist/lib/errors.d.ts +4 -3
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +4 -9
- package/dist/lib/errors.js.map +1 -0
- package/dist/punycode.d.ts +14 -13
- package/dist/punycode.d.ts.map +1 -0
- package/dist/punycode.js +46 -185
- package/dist/punycode.js.map +1 -0
- package/dist/tests/unit/lib/errors.spec.d.ts +2 -0
- package/dist/tests/unit/lib/errors.spec.d.ts.map +1 -0
- package/dist/tests/unit/lib/errors.spec.js +43 -0
- package/dist/tests/unit/lib/errors.spec.js.map +1 -0
- package/dist/tests/unit/punycode.spec.d.ts +2 -0
- package/dist/tests/unit/punycode.spec.d.ts.map +1 -0
- package/dist/tests/unit/punycode.spec.js +331 -0
- package/dist/tests/unit/punycode.spec.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.js +4 -0
- package/package.json +21 -21
- package/project.json +27 -0
- package/src/lib/errors.ts +32 -0
- package/src/punycode.ts +371 -0
- package/src/tests/unit/lib/errors.spec.ts +44 -0
- package/src/tests/unit/punycode.spec.ts +343 -0
- package/tsconfig.json +22 -0
package/dist/punycode.js
CHANGED
|
@@ -1,200 +1,112 @@
|
|
|
1
|
-
import { checkOverflow, rangeError } from '
|
|
2
|
-
|
|
3
|
-
const maxInt = 0x7FFFFFFF;
|
|
4
|
-
/** Bootstring parameters */
|
|
1
|
+
import { checkOverflow, rangeError } from '#errors';
|
|
2
|
+
const maxInt = 0x7fffffff;
|
|
5
3
|
const base = 36;
|
|
6
4
|
const tMin = 1;
|
|
7
5
|
const tMax = 26;
|
|
8
6
|
const skew = 38;
|
|
9
7
|
const damp = 700;
|
|
10
8
|
const initialBias = 72;
|
|
11
|
-
const initialN = 128;
|
|
12
|
-
const delimiter = '-';
|
|
9
|
+
const initialN = 128;
|
|
10
|
+
const delimiter = '-';
|
|
13
11
|
const baseMinusTMin = base - tMin;
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
/**
|
|
18
|
-
* A simple `Array#map`-like wrapper to work with domain name strings or email addresses.
|
|
19
|
-
*
|
|
20
|
-
* @param {string} domain - The domain name or email address.
|
|
21
|
-
* @param {Function} callback - The function that gets called for every character.
|
|
22
|
-
* @returns {string} A new string of characters returned by the callback function.
|
|
23
|
-
*/
|
|
24
|
-
const mapDomain = (domain, callback) => {
|
|
12
|
+
const regexNonASCII = /[^\0-\u007E]/u;
|
|
13
|
+
const regexSeparators = /[\u002E\u3002\uFF0E\uFF61]/gu;
|
|
14
|
+
const mapDomain = (domain, callback)=>{
|
|
25
15
|
const [first, ...rest] = domain.split('@');
|
|
26
16
|
let result;
|
|
27
17
|
let toEncode;
|
|
28
18
|
if (rest.length > 0) {
|
|
29
|
-
// In email addresses, only the domain name should be punycoded. Leave
|
|
30
|
-
// the local part (i.e. everything up to `@`) intact.
|
|
31
19
|
result = `${first}@`;
|
|
32
20
|
toEncode = rest.join('@');
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
21
|
+
} else {
|
|
35
22
|
result = '';
|
|
36
23
|
toEncode = first;
|
|
37
24
|
}
|
|
38
25
|
const labels = toEncode.split(regexSeparators);
|
|
39
|
-
const encoded = labels.map(x
|
|
26
|
+
const encoded = labels.map((x)=>callback(x)).join('.');
|
|
40
27
|
return result + encoded;
|
|
41
28
|
};
|
|
42
|
-
|
|
43
|
-
* Creates an array containing the numeric code points of each Unicode
|
|
44
|
-
* character in the string. While JavaScript uses UCS-2 internally,
|
|
45
|
-
* this function will convert a pair of surrogate halves (each of which
|
|
46
|
-
* UCS-2 exposes as separate characters) into a single code point,
|
|
47
|
-
* matching UTF-16.
|
|
48
|
-
*
|
|
49
|
-
* @see {@link https://mathiasbynens.be/notes/javascript-encoding}
|
|
50
|
-
*
|
|
51
|
-
* @param {string} string - The Unicode input string (UCS-2).
|
|
52
|
-
* @returns {number[]} The new array of code points.
|
|
53
|
-
*/
|
|
54
|
-
export const ucs2Decode = (string) => {
|
|
29
|
+
export const ucs2Decode = (string)=>{
|
|
55
30
|
const output = [];
|
|
56
31
|
let counter = 0;
|
|
57
|
-
while
|
|
58
|
-
// eslint-disable-next-line unicorn/prefer-code-point
|
|
32
|
+
while(counter < string.length){
|
|
59
33
|
const value = string.charCodeAt(counter++);
|
|
60
|
-
if (value >=
|
|
61
|
-
// It's a high surrogate, and there is a next character.
|
|
62
|
-
// eslint-disable-next-line unicorn/prefer-code-point
|
|
34
|
+
if (value >= 0xd800 && value <= 0xdbff && counter < string.length) {
|
|
63
35
|
const extra = string.charCodeAt(counter++);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
// It's an unmatched surrogate; only append this code unit, in case the
|
|
71
|
-
// next code unit is the high surrogate of a surrogate pair.
|
|
36
|
+
if ((extra & 0xfc00) === 0xdc00) {
|
|
37
|
+
output.push(((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000);
|
|
38
|
+
} else {
|
|
72
39
|
output.push(value);
|
|
73
40
|
counter--;
|
|
74
41
|
}
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
42
|
+
} else {
|
|
77
43
|
output.push(value);
|
|
78
44
|
}
|
|
79
45
|
}
|
|
80
46
|
return output;
|
|
81
47
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* @param {number[]} codePoints - The array of numeric code points.
|
|
86
|
-
* @returns {string} The new Unicode string (UCS-2).
|
|
87
|
-
*/
|
|
88
|
-
export const ucs2Encode = (codePoints) => String.fromCodePoint(...codePoints);
|
|
89
|
-
/**
|
|
90
|
-
* Converts a basic code point into a digit/integer.
|
|
91
|
-
*
|
|
92
|
-
* @param {number} codePoint - The basic numeric code point value.
|
|
93
|
-
* @returns {number} The numeric value of a basic code point (for use in
|
|
94
|
-
* representing integers) in the range `0` to `base - 1`, or `base` if
|
|
95
|
-
* the code point does not represent a value.
|
|
96
|
-
*/
|
|
97
|
-
const basicToDigit = (codePoint) => {
|
|
98
|
-
if (codePoint - 0x30 < 0x0A) {
|
|
48
|
+
export const ucs2Encode = (codePoints)=>String.fromCodePoint(...codePoints);
|
|
49
|
+
const basicToDigit = (codePoint)=>{
|
|
50
|
+
if (codePoint - 0x30 < 0x0a) {
|
|
99
51
|
return codePoint - 0x16;
|
|
100
52
|
}
|
|
101
|
-
if (codePoint - 0x41 <
|
|
53
|
+
if (codePoint - 0x41 < 0x1a) {
|
|
102
54
|
return codePoint - 0x41;
|
|
103
55
|
}
|
|
104
|
-
if (codePoint - 0x61 <
|
|
56
|
+
if (codePoint - 0x61 < 0x1a) {
|
|
105
57
|
return codePoint - 0x61;
|
|
106
58
|
}
|
|
107
59
|
return base;
|
|
108
60
|
};
|
|
109
|
-
|
|
110
|
-
* Converts a digit/integer into a basic code point.
|
|
111
|
-
*
|
|
112
|
-
* @param {number} digit - The numeric value of a basic code point.
|
|
113
|
-
* @returns {number} The basic code point whose value (when used for
|
|
114
|
-
* representing integers) is `digit`, which needs to be in the range
|
|
115
|
-
* `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
|
|
116
|
-
* used; else, the lowercase form is used. The behavior is undefined
|
|
117
|
-
* if `flag` is non-zero and `digit` has no uppercase form.
|
|
118
|
-
*/
|
|
119
|
-
const digitToBasic = (digit) => {
|
|
61
|
+
const digitToBasic = (digit)=>{
|
|
120
62
|
const plus22 = digit + 22;
|
|
121
|
-
// 0..25 map to ASCII a..z or A..Z
|
|
122
|
-
// 26..35 map to ASCII 0..9
|
|
123
63
|
return digit < 26 ? plus22 + 75 : plus22;
|
|
124
64
|
};
|
|
125
|
-
|
|
126
|
-
* Bias adaptation function as per section 3.4 of RFC 3492.
|
|
127
|
-
*
|
|
128
|
-
* @see {@link https://tools.ietf.org/html/rfc3492#section-3.4}
|
|
129
|
-
*
|
|
130
|
-
* @param {number} delta - delta
|
|
131
|
-
* @param {number} numPoints - num points
|
|
132
|
-
* @param {boolean} firstTime - first time
|
|
133
|
-
* @returns {number} bias adaptation
|
|
134
|
-
*/
|
|
135
|
-
const adapt = (delta, numPoints, firstTime) => {
|
|
65
|
+
const adapt = (delta, numPoints, firstTime)=>{
|
|
136
66
|
let k = 0;
|
|
137
|
-
// eslint-disable-next-line no-bitwise
|
|
138
67
|
let newDelta = firstTime ? Math.floor(delta / damp) : delta >> 1;
|
|
139
68
|
newDelta += Math.floor(newDelta / numPoints);
|
|
140
|
-
// eslint-disable-next-line no-bitwise
|
|
141
69
|
const minCheck = baseMinusTMin * tMax >> 1;
|
|
142
|
-
while
|
|
70
|
+
while(newDelta > minCheck){
|
|
143
71
|
newDelta = Math.floor(newDelta / baseMinusTMin);
|
|
144
72
|
k += base;
|
|
145
73
|
}
|
|
146
74
|
return Math.floor(k + (baseMinusTMin + 1) * newDelta / (newDelta + skew));
|
|
147
75
|
};
|
|
148
|
-
|
|
149
|
-
* Converts a Punycode string of ASCII-only symbols to a string of Unicode symbols.
|
|
150
|
-
*
|
|
151
|
-
* @param {string} input - The Punycode string of ASCII-only symbols.
|
|
152
|
-
* @returns {string} The resulting string of Unicode symbols.
|
|
153
|
-
*/
|
|
154
|
-
export const decode = (input) => {
|
|
155
|
-
// Don't use UCS-2.
|
|
76
|
+
export const decode = (input)=>{
|
|
156
77
|
const output = [];
|
|
157
78
|
const inputLength = input.length;
|
|
158
79
|
let i = 0;
|
|
159
80
|
let n = initialN;
|
|
160
81
|
let bias = initialBias;
|
|
161
|
-
// Handle the basic code points: let `basic` be the number of input code
|
|
162
|
-
// points before the last delimiter, or `0` if there is none, then copy
|
|
163
|
-
// the first basic code points to the output.
|
|
164
82
|
let basic = input.lastIndexOf(delimiter);
|
|
165
83
|
if (basic < 0) {
|
|
166
84
|
basic = 0;
|
|
167
85
|
}
|
|
168
|
-
for
|
|
86
|
+
for(let j = 0; j < basic; ++j){
|
|
169
87
|
const codePoint = input.codePointAt(j);
|
|
170
|
-
// If it's not a basic code point
|
|
171
88
|
if (codePoint >= 0x80) {
|
|
172
89
|
rangeError('not-basic');
|
|
173
90
|
}
|
|
174
91
|
output.push(codePoint);
|
|
175
92
|
}
|
|
176
|
-
// Main decoding loop: start just after the last delimiter if any basic code
|
|
177
|
-
// points were copied; start at the beginning otherwise.
|
|
178
93
|
let index = basic > 0 ? basic + 1 : 0;
|
|
179
|
-
while
|
|
180
|
-
// `index` is the index of the next character to be consumed.
|
|
181
|
-
// Decode a generalized variable-length integer into `delta`,
|
|
182
|
-
// which gets added to `i`. The overflow checking is easier
|
|
183
|
-
// if we increase `i` as we go, then subtract off its starting
|
|
184
|
-
// value at the end to obtain `delta`.
|
|
94
|
+
while(index < inputLength){
|
|
185
95
|
const oldi = i;
|
|
186
96
|
let w = 1;
|
|
187
97
|
let k = base;
|
|
188
|
-
while
|
|
189
|
-
checkOverflow(index, inputLength, {
|
|
98
|
+
while(true){
|
|
99
|
+
checkOverflow(index, inputLength, {
|
|
100
|
+
gte: true,
|
|
101
|
+
error: 'invalid-input'
|
|
102
|
+
});
|
|
190
103
|
const digit = basicToDigit(input.codePointAt(index++));
|
|
191
|
-
checkOverflow(digit, base, {
|
|
104
|
+
checkOverflow(digit, base, {
|
|
105
|
+
gte: true
|
|
106
|
+
});
|
|
192
107
|
checkOverflow(digit, Math.floor((maxInt - i) / w));
|
|
193
108
|
i += digit * w;
|
|
194
|
-
const t = k <= bias ?
|
|
195
|
-
tMin :
|
|
196
|
-
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
|
197
|
-
(k >= bias + tMax ? tMax : k - bias);
|
|
109
|
+
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
198
110
|
if (digit < t) {
|
|
199
111
|
break;
|
|
200
112
|
}
|
|
@@ -205,76 +117,50 @@ export const decode = (input) => {
|
|
|
205
117
|
}
|
|
206
118
|
const out = output.length + 1;
|
|
207
119
|
bias = adapt(i - oldi, out, oldi === 0);
|
|
208
|
-
// `i` was supposed to wrap around from `out` to `0`,
|
|
209
|
-
// incrementing `n` each time, so we'll fix that now:
|
|
210
120
|
checkOverflow(Math.floor(i / out), maxInt - n);
|
|
211
121
|
n += Math.floor(i / out);
|
|
212
122
|
i %= out;
|
|
213
|
-
// Insert `n` at position `i` of the output.
|
|
214
123
|
output.splice(i++, 0, n);
|
|
215
124
|
}
|
|
216
125
|
return String.fromCodePoint(...output);
|
|
217
126
|
};
|
|
218
|
-
|
|
219
|
-
* Converts a string of Unicode symbols (e.g. a domain name label) to a
|
|
220
|
-
* Punycode string of ASCII-only symbols.
|
|
221
|
-
*
|
|
222
|
-
* @param {string} input - The string of Unicode symbols.
|
|
223
|
-
* @returns {string} The resulting Punycode string of ASCII-only symbols.
|
|
224
|
-
*/
|
|
225
|
-
export const encode = (input) => {
|
|
127
|
+
export const encode = (input)=>{
|
|
226
128
|
const output = [];
|
|
227
|
-
// Convert the input in UCS-2 to an array of Unicode code points.
|
|
228
129
|
const decodedInput = ucs2Decode(input);
|
|
229
|
-
// Cache the length.
|
|
230
130
|
const inputLength = decodedInput.length;
|
|
231
|
-
// Initialize the state.
|
|
232
131
|
let n = initialN;
|
|
233
132
|
let delta = 0;
|
|
234
133
|
let bias = initialBias;
|
|
235
|
-
|
|
236
|
-
for (const currentValue of decodedInput) {
|
|
134
|
+
for (const currentValue of decodedInput){
|
|
237
135
|
if (currentValue < 0x80) {
|
|
238
136
|
output.push(String.fromCodePoint(currentValue));
|
|
239
137
|
}
|
|
240
138
|
}
|
|
241
139
|
const basicLength = output.length;
|
|
242
140
|
let handledCPCount = basicLength;
|
|
243
|
-
// `handledCPCount` is the number of code points that have been handled;
|
|
244
|
-
// `basicLength` is the number of basic code points.
|
|
245
|
-
// Finish the basic string with a delimiter unless it's empty.
|
|
246
141
|
if (basicLength) {
|
|
247
142
|
output.push(delimiter);
|
|
248
143
|
}
|
|
249
|
-
|
|
250
|
-
while (handledCPCount < inputLength) {
|
|
251
|
-
// All non-basic code points < n have been handled already. Find the next
|
|
252
|
-
// larger one:
|
|
144
|
+
while(handledCPCount < inputLength){
|
|
253
145
|
let m = maxInt;
|
|
254
|
-
for (const currentValue of decodedInput)
|
|
146
|
+
for (const currentValue of decodedInput){
|
|
255
147
|
if (currentValue >= n && currentValue < m) {
|
|
256
148
|
m = currentValue;
|
|
257
149
|
}
|
|
258
150
|
}
|
|
259
|
-
// Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
|
|
260
|
-
// but guard against overflow.
|
|
261
151
|
const handledCPCountPlusOne = handledCPCount + 1;
|
|
262
152
|
checkOverflow(m - n, Math.floor((maxInt - delta) / handledCPCountPlusOne));
|
|
263
153
|
delta += (m - n) * handledCPCountPlusOne;
|
|
264
154
|
n = m;
|
|
265
|
-
for (const currentValue of decodedInput)
|
|
155
|
+
for (const currentValue of decodedInput){
|
|
266
156
|
if (currentValue < n) {
|
|
267
157
|
checkOverflow(++delta, maxInt);
|
|
268
158
|
}
|
|
269
159
|
if (currentValue === n) {
|
|
270
|
-
// Represent delta as a generalized variable-length integer.
|
|
271
160
|
let q = delta;
|
|
272
161
|
let k = base;
|
|
273
|
-
while
|
|
274
|
-
const t = k <= bias ?
|
|
275
|
-
tMin :
|
|
276
|
-
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
|
277
|
-
(k >= bias + tMax ? tMax : k - bias);
|
|
162
|
+
while(true){
|
|
163
|
+
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
278
164
|
if (q < t) {
|
|
279
165
|
break;
|
|
280
166
|
}
|
|
@@ -295,31 +181,6 @@ export const encode = (input) => {
|
|
|
295
181
|
}
|
|
296
182
|
return output.join('');
|
|
297
183
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
* it doesn't matter if you call it on a string that has already been
|
|
302
|
-
* converted to Unicode.
|
|
303
|
-
*
|
|
304
|
-
* @param {string} input - The Punycoded domain name or email address to
|
|
305
|
-
* convert to Unicode.
|
|
306
|
-
* @returns {string} The Unicode representation of the given Punycode
|
|
307
|
-
* string.
|
|
308
|
-
*/
|
|
309
|
-
export const toUnicode = (input) => mapDomain(input, (str) => (str.startsWith('xn--') ?
|
|
310
|
-
decode(str.slice(4).toLowerCase()) :
|
|
311
|
-
str));
|
|
312
|
-
/**
|
|
313
|
-
* Converts a Unicode string representing a domain name or an email address to
|
|
314
|
-
* Punycode. Only the non-ASCII parts of the domain name will be converted,
|
|
315
|
-
* i.e. it doesn't matter if you call it with a domain that's already in
|
|
316
|
-
* ASCII.
|
|
317
|
-
*
|
|
318
|
-
* @param {string} input - The domain name or email address to convert, as a
|
|
319
|
-
* Unicode string.
|
|
320
|
-
* @returns {string} The Punycode representation of the given domain name or
|
|
321
|
-
* email address.
|
|
322
|
-
*/
|
|
323
|
-
export const toASCII = (input) => mapDomain(input, (string) => (regexNonASCII.test(string) ?
|
|
324
|
-
`xn--${encode(string)}` :
|
|
325
|
-
string));
|
|
184
|
+
export const toUnicode = (input)=>mapDomain(input, (str)=>str.startsWith('xn--') ? decode(str.slice(4).toLowerCase()) : str);
|
|
185
|
+
export const toASCII = (input)=>mapDomain(input, (string)=>regexNonASCII.test(string) ? `xn--${encode(string)}` : string);
|
|
186
|
+
//# sourceMappingURL=punycode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/punycode.ts"],"sourceRoot":"","names":["checkOverflow","rangeError","maxInt","base","tMin","tMax","skew","damp","initialBias","initialN","delimiter","baseMinusTMin","regexNonASCII","regexSeparators","mapDomain","domain","callback","first","rest","split","result","toEncode","length","join","labels","encoded","map","x","ucs2Decode","string","output","counter","value","charCodeAt","extra","push","ucs2Encode","codePoints","String","fromCodePoint","basicToDigit","codePoint","digitToBasic","digit","plus22","adapt","delta","numPoints","firstTime","k","newDelta","Math","floor","minCheck","decode","input","inputLength","i","n","bias","basic","lastIndexOf","j","codePointAt","index","oldi","w","gte","error","t","baseMinusT","out","splice","encode","decodedInput","currentValue","basicLength","handledCPCount","m","handledCPCountPlusOne","q","qMinusT","toUnicode","str","startsWith","slice","toLowerCase","toASCII","test"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,UAAU;AAGpD,MAAMC,SAAS;AAGf,MAAMC,OAAO;AACb,MAAMC,OAAO;AACb,MAAMC,OAAO;AACb,MAAMC,OAAO;AACb,MAAMC,OAAO;AACb,MAAMC,cAAc;AACpB,MAAMC,WAAW;AACjB,MAAMC,YAAY;AAElB,MAAMC,gBAAgBR,OAAOC;AAG7B,MAAMQ,gBAAgB;AACtB,MAAMC,kBAAkB;AASxB,MAAMC,YAAY,CAACC,QAAgBC;IAC/B,MAAM,CAACC,OAAO,GAAGC,KAAK,GAAGH,OAAOI,KAAK,CAAC;IACtC,IAAIC;IACJ,IAAIC;IACJ,IAAIH,KAAKI,MAAM,GAAG,GAAG;QAGjBF,SAAS,CAAC,EAAEH,MAAO,CAAC,CAAC;QACrBI,WAAWH,KAAKK,IAAI,CAAC;IACzB,OAAO;QACHH,SAAS;QACTC,WAAWJ;IACf;IACA,MAAMO,SAASH,SAASF,KAAK,CAACN;IAC9B,MAAMY,UAAUD,O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gBAClB1D,cAAc,EAAE8C,OAAO5C;YAC3B;YACA,IAAIyE,iBAAiBjB,GAAG;gBAEpB,IAAIsB,IAAIlC;gBACR,IAAIG,IAAI9C;gBACR,MAAO,KAAM;oBACT,MAAMkE,IAEFpB,KAAKU,OAAOvD,OAAO6C,KAAKU,OAAOtD,OAAOA,OAAO4C,IAAIU;oBACrD,IAAIqB,IAAIX,GAAG;wBACP;oBACJ;oBACA,MAAMY,UAAUD,IAAIX;oBACpB,MAAMC,aAAanE,OAAOkE;oBAC1BvC,OAAOK,IAAI,CAACG,OAAOC,aAAa,CAACG,aAAa2B,IAAKY,UAAUX;oBAC7DU,IAAI7B,KAAKC,KAAK,CAAC6B,UAAUX;oBACzBrB,KAAK9C;gBACT;gBAEA2B,OAAOK,IAAI,CAACG,OAAOC,aAAa,CAACG,aAAasC;gBAC9CrB,OAAOd,MAAMC,OAAOiC,uBAAuBF,mBAAmBD;gBAC9D9B,QAAQ;gBACR,EAAE+B;YACN;QACJ;QAEA,EAAE/B;QACF,EAAEY;IACN;IACA,OAAO5B,OAAOP,IAAI,CAAC;AACvB,EAAE;AAaF,OAAO,MAAM2D,YAAY,CAAC3B,QACtBzC,UAAUyC,OAAO,CAAC4B,MACdA,IAAIC,UAAU,CAAC,UAAU9B,OAAO6B,IAAIE,KAAK,CAAC,GAAGC,WAAW,MAAMH,KAChE;AAaN,OAAO,MAAMI,UAAU,CAAChC,QACpBzC,UAAUyC,OAAO,CAAC1B,SACdjB,cAAc4E,IAAI,CAAC3D,UAAU,CAAC,IAAI,EAAE4C,OAAO5C,QAAQ,CAAC,GAAGA,QACzD","file":"punycode.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.spec.d.ts","sourceRoot":"","sources":["../../../../src/tests/unit/lib/errors.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { suite, test } from 'mocha-chain';
|
|
3
|
+
import * as Errors from '#errors';
|
|
4
|
+
suite('errors', ()=>{
|
|
5
|
+
suite('checkOverflow', ()=>{
|
|
6
|
+
suite('success', ()=>{
|
|
7
|
+
test('Less than', ()=>{
|
|
8
|
+
Errors.checkOverflow(1, 2);
|
|
9
|
+
});
|
|
10
|
+
test('Less than (gte)', ()=>{
|
|
11
|
+
Errors.checkOverflow(1, 2, {
|
|
12
|
+
gte: true
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
test('Equal to', ()=>{
|
|
16
|
+
Errors.checkOverflow(1, 1);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
suite('failure', ()=>{
|
|
20
|
+
test('Greater than', ()=>{
|
|
21
|
+
expect(()=>{
|
|
22
|
+
Errors.checkOverflow(2, 1);
|
|
23
|
+
}).to.throw(RangeError);
|
|
24
|
+
});
|
|
25
|
+
test('Greater than (gte)', ()=>{
|
|
26
|
+
expect(()=>{
|
|
27
|
+
Errors.checkOverflow(2, 1, {
|
|
28
|
+
gte: true
|
|
29
|
+
});
|
|
30
|
+
}).to.throw('Overflow: input needs wider integers to process');
|
|
31
|
+
});
|
|
32
|
+
test('Equal to', ()=>{
|
|
33
|
+
expect(()=>{
|
|
34
|
+
Errors.checkOverflow(1, 1, {
|
|
35
|
+
gte: true,
|
|
36
|
+
error: 'invalid-input'
|
|
37
|
+
});
|
|
38
|
+
}).to.throw('Invalid input');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=errors.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/tests/unit/lib/errors.spec.ts"],"sourceRoot":"","names":["expect","suite","test","Errors","checkOverflow","gte","to","throw","RangeError","error"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,KAAK,EAAEC,IAAI,QAAQ,cAAc;AAC1C,YAAYC,YAAY,UAAU;AAElCF,MAAM,UAAU;IACZA,MAAM,iBAAiB;QACnBA,MAAM,WAAW;YACbC,KAAK,aAAa;gBACdC,OAAOC,aAAa,CAAC,GAAG;YAC5B;YAEAF,KAAK,mBAAmB;gBACpBC,OAAOC,aAAa,CAAC,GAAG,GAAG;oBAAEC,KAAK;gBAAK;YAC3C;YAEAH,KAAK,YAAY;gBACbC,OAAOC,aAAa,CAAC,GAAG;YAC5B;QACJ;QAEAH,MAAM,WAAW;YACbC,KAAK,gBAAgB;gBACjBF,OAAO;oBACHG,OAAOC,aAAa,CAAC,GAAG;gBAC5B,GAAGE,EAAE,CAACC,KAAK,CAACC;YAChB;YAEAN,KAAK,sBAAsB;gBACvBF,OAAO;oBACHG,OAAOC,aAAa,CAAC,GAAG,GAAG;wBAAEC,KAAK;oBAAK;gBAC3C,GAAGC,EAAE,CAACC,KAAK,CAAC;YAChB;YAEAL,KAAK,YAAY;gBACbF,OAAO;oBACHG,OAAOC,aAAa,CAAC,GAAG,GAAG;wBACvBC,KAAK;wBACLI,OAAO;oBACX;gBACJ,GAAGH,EAAE,CAACC,KAAK,CAAC;YAChB;QACJ;IACJ;AACJ","file":"errors.spec.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"punycode.spec.d.ts","sourceRoot":"","sources":["../../../src/tests/unit/punycode.spec.ts"],"names":[],"mappings":""}
|