FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/benchmark/misc/punycode.js at main · fetchapi/node · GitHub
fetchapi
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
benchmark
/
misc
/
punycode.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
79 lines (72 loc) · 1.72 KB
Breadcrumbs
node
/
benchmark
/
misc
/
punycode.js
Copy path
File metadata and controls
79 lines (72 loc) · 1.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
'use strict'
;
const
common
=
require
(
'../common.js'
)
;
let
icu
;
try
{
icu
=
common
.
binding
(
'icu'
)
;
}
catch
{
// Continue regardless of error.
}
const
punycode
=
require
(
'punycode'
)
;
const
bench
=
common
.
createBenchmark
(
main
,
{
method
:
[
'punycode'
]
.
concat
(
icu
!==
undefined
?
[
'icu'
]
:
[
]
)
,
n
:
[
1024
]
,
val
:
[
'افغانستا.icom.museum'
,
'الجزائر.icom.museum'
,
'österreich.icom.museum'
,
'বাংলাদেশ.icom.museum'
,
'беларусь.icom.museum'
,
'belgië.icom.museum'
,
'българия.icom.museum'
,
'تشادر.icom.museum'
,
'中国.icom.museum'
,
'القمر.icom.museum'
,
'κυπρος.icom.museum'
,
'českárepublika.icom.museum'
,
'مصر.icom.museum'
,
'ελλάδα.icom.museum'
,
'magyarország.icom.museum'
,
'ísland.icom.museum'
,
'भारत.icom.museum'
,
'ايران.icom.museum'
,
'éire.icom.museum'
,
'איקו״ם.ישראל.museum'
,
'日本.icom.museum'
,
'الأردن.icom.museum'
,
]
,
}
)
;
function
usingPunycode
(
val
)
{
punycode
.
toUnicode
(
punycode
.
toASCII
(
val
)
)
;
}
function
usingICU
(
val
)
{
icu
.
toUnicode
(
icu
.
toASCII
(
val
)
)
;
}
function
runPunycode
(
n
,
val
)
{
for
(
let
i
=
0
;
i
<
n
;
i
++
)
usingPunycode
(
val
)
;
bench
.
start
(
)
;
for
(
let
i
=
0
;
i
<
n
;
i
++
)
usingPunycode
(
val
)
;
bench
.
end
(
n
)
;
}
function
runICU
(
n
,
val
)
{
bench
.
start
(
)
;
for
(
let
i
=
0
;
i
<
n
;
i
++
)
usingICU
(
val
)
;
bench
.
end
(
n
)
;
}
function
main
(
{
n
,
val
,
method
}
)
{
switch
(
method
)
{
case
'punycode'
:
runPunycode
(
n
,
val
)
;
break
;
case
'icu'
:
if
(
icu
!==
undefined
)
{
runICU
(
n
,
val
)
;
break
;
}
// fallthrough
default
:
throw
new
Error
(
`Unexpected method "
${
method
}
"`
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL