FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
browsercode/packages/codemode/src/stdlib/string.ts at main · code2labgit/browsercode · GitHub
code2labgit
/
browsercode
Public
forked from
browser-use/browsercode
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
browsercode
/
packages
/
codemode
/
src
/
stdlib
/
string.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (50 loc) · 1.15 KB
Breadcrumbs
browsercode
/
packages
/
codemode
/
src
/
stdlib
/
string.ts
Copy path
File metadata and controls
52 lines (50 loc) · 1.15 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
export
const
stringMethods
=
new
Set
(
[
"toLowerCase"
,
"toUpperCase"
,
"trim"
,
"trimStart"
,
"trimEnd"
,
"trimLeft"
,
"trimRight"
,
"split"
,
"slice"
,
"substring"
,
"substr"
,
"includes"
,
"startsWith"
,
"endsWith"
,
"indexOf"
,
"lastIndexOf"
,
"replace"
,
"replaceAll"
,
"repeat"
,
"padStart"
,
"padEnd"
,
"charAt"
,
"charCodeAt"
,
"codePointAt"
,
"at"
,
"concat"
,
"toString"
,
"match"
,
"matchAll"
,
"search"
,
"localeCompare"
,
"normalize"
,
]
)
export
const
stringStatics
=
new
Set
(
[
"fromCharCode"
,
"fromCodePoint"
]
)
export
const
invokeStringStatic
=
(
name
:
string
,
args
:
Array
<
unknown
>
,
node
:
AstNode
)
:
unknown
=>
{
const
codes
=
args
.
map
(
(
arg
)
=>
{
if
(
typeof
arg
!==
"number"
)
throw
new
InterpreterRuntimeError
(
`String.
${
name
}
expects number arguments.`
,
node
)
return
arg
}
)
switch
(
name
)
{
case
"fromCharCode"
:
return
String
.
fromCharCode
(
...
codes
)
case
"fromCodePoint"
:
return
String
.
fromCodePoint
(
...
codes
)
default
:
throw
new
InterpreterRuntimeError
(
`String.
${
name
}
is not available in CodeMode.`
,
node
)
}
}
import
{
type
AstNode
,
InterpreterRuntimeError
}
from
"../interpreter/model.js"
Back
|
FazBrowse Home
|
New Git URL