jsxpression 0.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/LICENSE +21 -0
- package/README.md +368 -0
- package/lib/analyze/analysis-error.d.ts.map +1 -0
- package/lib/analyze/analysis-report.d.ts +33 -0
- package/lib/analyze/analysis-report.d.ts.map +1 -0
- package/lib/analyze/analysis-report.js +194 -0
- package/lib/analyze/analysis-report.js.map +1 -0
- package/lib/analyze/analyze.d.ts.map +1 -0
- package/lib/analyze/analyze.test.d.ts.map +1 -0
- package/lib/analyze/analyze.test.js +765 -0
- package/lib/analyze/analyze.test.js.map +1 -0
- package/lib/analyze/data/analyze.d.ts.map +1 -0
- package/lib/analyze/data/data-access.d.ts.map +1 -0
- package/lib/analyze/data/index.d.ts.map +1 -0
- package/lib/analyze/data/method-calls.d.ts.map +1 -0
- package/lib/analyze/data/utils.d.ts.map +1 -0
- package/lib/analyze/index.d.ts.map +1 -0
- package/lib/analyze/jsx/analyze.d.ts.map +1 -0
- package/lib/analyze/jsx/element-attributes.d.ts.map +1 -0
- package/lib/analyze/jsx/element-attributes.js +89 -0
- package/lib/analyze/jsx/element-attributes.js.map +1 -0
- package/lib/analyze/jsx/element-children.d.ts.map +1 -0
- package/lib/analyze/jsx/element-tags.d.ts.map +1 -0
- package/lib/analyze/jsx/index.d.ts.map +1 -0
- package/lib/analyze/security/analyze.d.ts.map +1 -0
- package/lib/analyze/security/call-expressions.d.ts.map +1 -0
- package/lib/analyze/security/declarations.d.ts.map +1 -0
- package/lib/analyze/security/expressions.d.ts.map +1 -0
- package/lib/analyze/security/identifiers.d.ts.map +1 -0
- package/lib/analyze/security/index.d.ts.map +1 -0
- package/lib/analyze/security/member-access.d.ts.map +1 -0
- package/lib/builtins.d.ts +50 -0
- package/lib/builtins.d.ts.map +1 -0
- package/lib/builtins.js +1065 -0
- package/lib/builtins.js.map +1 -0
- package/lib/codegen/builtin-types.d.ts +11 -0
- package/lib/codegen/builtin-types.d.ts.map +1 -0
- package/lib/codegen/builtin-types.js +151 -0
- package/lib/codegen/builtin-types.js.map +1 -0
- package/lib/codegen/builtins/builtin-types.d.ts +2 -0
- package/lib/codegen/builtins/builtin-types.d.ts.map +1 -0
- package/lib/codegen/builtins/builtin-types.js +143 -0
- package/lib/codegen/builtins/builtin-types.js.map +1 -0
- package/lib/codegen/builtins/index.d.ts +2 -0
- package/lib/codegen/builtins/index.d.ts.map +1 -0
- package/lib/codegen/builtins/index.js +6 -0
- package/lib/codegen/builtins/index.js.map +1 -0
- package/lib/codegen/declare-types.d.ts +20 -0
- package/lib/codegen/declare-types.d.ts.map +1 -0
- package/lib/codegen/declare-types.js +299 -0
- package/lib/codegen/declare-types.js.map +1 -0
- package/lib/codegen/generate-typescript-definitions.d.ts +31 -0
- package/lib/codegen/generate-typescript-definitions.d.ts.map +1 -0
- package/lib/codegen/generate-typescript-definitions.js +37 -0
- package/lib/codegen/generate-typescript-definitions.js.map +1 -0
- package/lib/codegen/generate-typescript-definitions.test.d.ts +2 -0
- package/lib/codegen/generate-typescript-definitions.test.d.ts.map +1 -0
- package/lib/codegen/generate-typescript-definitions.test.js +587 -0
- package/lib/codegen/generate-typescript-definitions.test.js.map +1 -0
- package/lib/codegen/index.d.ts +2 -0
- package/lib/codegen/index.d.ts.map +1 -0
- package/lib/codegen/index.js +6 -0
- package/lib/codegen/index.js.map +1 -0
- package/lib/codegen/schema/component-types.d.ts +3 -0
- package/lib/codegen/schema/component-types.d.ts.map +1 -0
- package/lib/codegen/schema/component-types.js +118 -0
- package/lib/codegen/schema/component-types.js.map +1 -0
- package/lib/codegen/schema/data-types.d.ts +3 -0
- package/lib/codegen/schema/data-types.d.ts.map +1 -0
- package/lib/codegen/schema/data-types.js +98 -0
- package/lib/codegen/schema/data-types.js.map +1 -0
- package/lib/codegen/schema/index.d.ts +3 -0
- package/lib/codegen/schema/index.d.ts.map +1 -0
- package/lib/codegen/schema/index.js +8 -0
- package/lib/codegen/schema/index.js.map +1 -0
- package/lib/codegen/schema/utils.d.ts +4 -0
- package/lib/codegen/schema/utils.d.ts.map +1 -0
- package/lib/codegen/schema/utils.js +103 -0
- package/lib/codegen/schema/utils.js.map +1 -0
- package/lib/codegen/schema-to-types.d.ts +14 -0
- package/lib/codegen/schema-to-types.d.ts.map +1 -0
- package/lib/codegen/schema-to-types.js +203 -0
- package/lib/codegen/schema-to-types.js.map +1 -0
- package/lib/compile/compile.d.ts.map +1 -0
- package/lib/compile/compile.js +245 -0
- package/lib/compile/compile.js.map +1 -0
- package/lib/compile/compile.test.d.ts.map +1 -0
- package/lib/compile/compile.test.js +148 -0
- package/lib/compile/compile.test.js.map +1 -0
- package/lib/evaluate/evaluate.d.ts +26 -0
- package/lib/evaluate/evaluate.d.ts.map +1 -0
- package/lib/evaluate/evaluate.js +40 -0
- package/lib/evaluate/evaluation-error.d.ts +4 -0
- package/lib/evaluate/evaluation-error.d.ts.map +1 -0
- package/lib/evaluate/evaluation-error.js +6 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -0
- package/lib/index.js.map +1 -0
- package/lib/render.d.ts +58 -0
- package/lib/render.d.ts.map +1 -0
- package/lib/render.js +52 -0
- package/lib/render.test.d.ts.map +1 -0
- package/lib/schema.d.ts +68 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +106 -0
- package/lib/validate.d.ts +41 -0
- package/lib/validate.d.ts.map +1 -0
- package/lib/validate.js +42 -0
- package/package.json +27 -0
- package/src/analyze/analysis-error.ts +26 -0
- package/src/analyze/analysis-report.ts +228 -0
- package/src/analyze/analyze.test.ts +829 -0
- package/src/analyze/analyze.ts +10 -0
- package/src/analyze/data/analyze.ts +15 -0
- package/src/analyze/data/data-access.ts +349 -0
- package/src/analyze/data/index.ts +1 -0
- package/src/analyze/data/method-calls.ts +96 -0
- package/src/analyze/data/utils.ts +329 -0
- package/src/analyze/index.ts +3 -0
- package/src/analyze/jsx/analyze.ts +17 -0
- package/src/analyze/jsx/element-attributes.ts +143 -0
- package/src/analyze/jsx/element-children.ts +97 -0
- package/src/analyze/jsx/element-tags.ts +55 -0
- package/src/analyze/jsx/index.ts +1 -0
- package/src/analyze/security/analyze.ts +21 -0
- package/src/analyze/security/call-expressions.ts +41 -0
- package/src/analyze/security/declarations.ts +67 -0
- package/src/analyze/security/expressions.ts +100 -0
- package/src/analyze/security/identifiers.ts +113 -0
- package/src/analyze/security/index.ts +1 -0
- package/src/analyze/security/member-access.ts +35 -0
- package/src/analyze/utils.ts +118 -0
- package/src/analyze/validation-context.ts +32 -0
- package/src/builtins.ts +1149 -0
- package/src/codegen/builtins/builtin-types.ts +174 -0
- package/src/codegen/builtins/index.ts +1 -0
- package/src/codegen/generate-typescript-definitions.test.ts +676 -0
- package/src/codegen/generate-typescript-definitions.ts +35 -0
- package/src/codegen/index.ts +1 -0
- package/src/codegen/schema/component-types.ts +140 -0
- package/src/codegen/schema/data-types.ts +109 -0
- package/src/codegen/schema/index.ts +2 -0
- package/src/codegen/schema/utils.ts +111 -0
- package/src/compile/compilation-error.ts +37 -0
- package/src/compile/compile.test.ts +180 -0
- package/src/compile/compile.ts +282 -0
- package/src/compile/index.ts +2 -0
- package/src/evaluate/evaluate.test.ts +316 -0
- package/src/evaluate/evaluate.ts +81 -0
- package/src/evaluate/evaluation-error.ts +6 -0
- package/src/evaluate/index.ts +2 -0
- package/src/index.ts +10 -0
- package/src/jsx.ts +161 -0
- package/src/parse/index.ts +2 -0
- package/src/parse/parse-error.ts +14 -0
- package/src/parse/parse.test.ts +99 -0
- package/src/parse/parse.ts +40 -0
- package/src/render.test.ts +425 -0
- package/src/render.ts +75 -0
- package/src/schema.ts +195 -0
- package/src/traverse.test.ts +104 -0
- package/src/traverse.ts +78 -0
- package/src/types.ts +17 -0
- package/src/validate.ts +59 -0
package/src/builtins.ts
ADDED
|
@@ -0,0 +1,1149 @@
|
|
|
1
|
+
/* eslint-disable max-lines */
|
|
2
|
+
export interface BuiltinCallbackParamSchema {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface BuiltinParamBaseSchema {
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
variadic?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface BuiltinPrimitiveParamSchema extends BuiltinParamBaseSchema {
|
|
15
|
+
kind: "primitive";
|
|
16
|
+
types: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BuiltinFunctionParamSchema extends BuiltinParamBaseSchema {
|
|
20
|
+
kind: "function";
|
|
21
|
+
signature: {
|
|
22
|
+
params: BuiltinCallbackParamSchema[];
|
|
23
|
+
returnType: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type BuiltinParamSchema = BuiltinPrimitiveParamSchema | BuiltinFunctionParamSchema;
|
|
28
|
+
|
|
29
|
+
export interface BuiltinMethodSchema {
|
|
30
|
+
params: BuiltinParamSchema[];
|
|
31
|
+
returnType: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BuiltinPropertySchema {
|
|
36
|
+
type: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
readonly?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface BuiltinSchema {
|
|
42
|
+
methods?: Record<string, BuiltinMethodSchema>;
|
|
43
|
+
properties?: Record<string, BuiltinPropertySchema>;
|
|
44
|
+
global: boolean;
|
|
45
|
+
intrinsic?: boolean;
|
|
46
|
+
generic?: string; // Generic type parameters, e.g., "<T>" or "<K, V>"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const MATH = "Math";
|
|
50
|
+
const NUMBER = "Number";
|
|
51
|
+
const NUMBER_PROTOTYPE = "Number.prototype";
|
|
52
|
+
const ARRAY = "Array";
|
|
53
|
+
const ARRAY_PROTOTYPE = "Array.prototype";
|
|
54
|
+
const STRING_PROTOTYPE = "String.prototype";
|
|
55
|
+
|
|
56
|
+
const BUILTINS: Record<string, BuiltinSchema> = {
|
|
57
|
+
[MATH]: {
|
|
58
|
+
global: true,
|
|
59
|
+
intrinsic: false,
|
|
60
|
+
properties: {
|
|
61
|
+
PI: {
|
|
62
|
+
type: "number",
|
|
63
|
+
readonly: true,
|
|
64
|
+
description: "The mathematical constant π (pi), approximately 3.14159",
|
|
65
|
+
},
|
|
66
|
+
E: {
|
|
67
|
+
type: "number",
|
|
68
|
+
readonly: true,
|
|
69
|
+
description: "Euler's number, the base of natural logarithms, approximately 2.71828",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
methods: {
|
|
73
|
+
max: {
|
|
74
|
+
description: "Returns the larger of a set of supplied numeric expressions",
|
|
75
|
+
params: [
|
|
76
|
+
{
|
|
77
|
+
kind: "primitive" as const,
|
|
78
|
+
name: "values",
|
|
79
|
+
types: ["number"],
|
|
80
|
+
description: "Numeric expressions to be evaluated",
|
|
81
|
+
variadic: true,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
returnType: "number",
|
|
85
|
+
},
|
|
86
|
+
min: {
|
|
87
|
+
description: "Returns the smaller of a set of supplied numeric expressions",
|
|
88
|
+
params: [
|
|
89
|
+
{
|
|
90
|
+
kind: "primitive" as const,
|
|
91
|
+
name: "values",
|
|
92
|
+
types: ["number"],
|
|
93
|
+
description: "Numeric expressions to be evaluated",
|
|
94
|
+
variadic: true,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
returnType: "number",
|
|
98
|
+
},
|
|
99
|
+
floor: {
|
|
100
|
+
description: "Returns the largest integer less than or equal to a number",
|
|
101
|
+
params: [
|
|
102
|
+
{
|
|
103
|
+
kind: "primitive" as const,
|
|
104
|
+
name: "value",
|
|
105
|
+
types: ["number"],
|
|
106
|
+
description: "A numeric expression",
|
|
107
|
+
required: true,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
returnType: "number",
|
|
111
|
+
},
|
|
112
|
+
ceil: {
|
|
113
|
+
description: "Returns the smallest integer greater than or equal to a number",
|
|
114
|
+
params: [
|
|
115
|
+
{
|
|
116
|
+
kind: "primitive" as const,
|
|
117
|
+
name: "value",
|
|
118
|
+
types: ["number"],
|
|
119
|
+
description: "A numeric expression",
|
|
120
|
+
required: true,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
returnType: "number",
|
|
124
|
+
},
|
|
125
|
+
round: {
|
|
126
|
+
description: "Returns a supplied numeric expression rounded to the nearest integer",
|
|
127
|
+
params: [
|
|
128
|
+
{
|
|
129
|
+
kind: "primitive" as const,
|
|
130
|
+
name: "value",
|
|
131
|
+
types: ["number"],
|
|
132
|
+
description: "The value to be rounded to the nearest integer",
|
|
133
|
+
required: true,
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
returnType: "number",
|
|
137
|
+
},
|
|
138
|
+
abs: {
|
|
139
|
+
description: "Returns the absolute value of a number",
|
|
140
|
+
params: [
|
|
141
|
+
{
|
|
142
|
+
kind: "primitive" as const,
|
|
143
|
+
name: "value",
|
|
144
|
+
types: ["number"],
|
|
145
|
+
description: "A numeric expression for which the absolute value is needed",
|
|
146
|
+
required: true,
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
returnType: "number",
|
|
150
|
+
},
|
|
151
|
+
sqrt: {
|
|
152
|
+
description: "Returns the square root of a number",
|
|
153
|
+
params: [
|
|
154
|
+
{
|
|
155
|
+
kind: "primitive" as const,
|
|
156
|
+
name: "value",
|
|
157
|
+
types: ["number"],
|
|
158
|
+
description: "A numeric expression",
|
|
159
|
+
required: true,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
returnType: "number",
|
|
163
|
+
},
|
|
164
|
+
pow: {
|
|
165
|
+
description: "Returns the value of a base expression taken to a specified power",
|
|
166
|
+
params: [
|
|
167
|
+
{
|
|
168
|
+
kind: "primitive" as const,
|
|
169
|
+
name: "base",
|
|
170
|
+
types: ["number"],
|
|
171
|
+
description: "The base value of the expression",
|
|
172
|
+
required: true,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
kind: "primitive" as const,
|
|
176
|
+
name: "exponent",
|
|
177
|
+
types: ["number"],
|
|
178
|
+
description: "The exponent value of the expression",
|
|
179
|
+
required: true,
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
returnType: "number",
|
|
183
|
+
},
|
|
184
|
+
sign: {
|
|
185
|
+
description: "Returns the sign of a number, indicating whether the number is positive, negative, or zero",
|
|
186
|
+
params: [
|
|
187
|
+
{
|
|
188
|
+
kind: "primitive" as const,
|
|
189
|
+
name: "value",
|
|
190
|
+
types: ["number"],
|
|
191
|
+
description: "A numeric expression",
|
|
192
|
+
required: true,
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
returnType: "number",
|
|
196
|
+
},
|
|
197
|
+
sin: {
|
|
198
|
+
description: "Returns the sine of a number",
|
|
199
|
+
params: [
|
|
200
|
+
{
|
|
201
|
+
kind: "primitive" as const,
|
|
202
|
+
name: "value",
|
|
203
|
+
types: ["number"],
|
|
204
|
+
description: "A numeric expression that contains an angle measured in radians",
|
|
205
|
+
required: true,
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
returnType: "number",
|
|
209
|
+
},
|
|
210
|
+
cos: {
|
|
211
|
+
description: "Returns the cosine of a number",
|
|
212
|
+
params: [
|
|
213
|
+
{
|
|
214
|
+
kind: "primitive" as const,
|
|
215
|
+
name: "value",
|
|
216
|
+
types: ["number"],
|
|
217
|
+
description: "A numeric expression that contains an angle measured in radians",
|
|
218
|
+
required: true,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
returnType: "number",
|
|
222
|
+
},
|
|
223
|
+
atan2: {
|
|
224
|
+
description: "Returns the angle in radians between the positive x-axis and the point (x, y)",
|
|
225
|
+
params: [
|
|
226
|
+
{
|
|
227
|
+
kind: "primitive" as const,
|
|
228
|
+
name: "y",
|
|
229
|
+
types: ["number"],
|
|
230
|
+
description: "The y coordinate of the point",
|
|
231
|
+
required: true,
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
kind: "primitive" as const,
|
|
235
|
+
name: "x",
|
|
236
|
+
types: ["number"],
|
|
237
|
+
description: "The x coordinate of the point",
|
|
238
|
+
required: true,
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
returnType: "number",
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
|
|
246
|
+
[NUMBER]: {
|
|
247
|
+
global: true,
|
|
248
|
+
intrinsic: false,
|
|
249
|
+
methods: {
|
|
250
|
+
isNaN: {
|
|
251
|
+
description: "Determines whether the passed value is NaN (Not-A-Number)",
|
|
252
|
+
params: [
|
|
253
|
+
{
|
|
254
|
+
kind: "primitive" as const,
|
|
255
|
+
name: "value",
|
|
256
|
+
types: ["any"],
|
|
257
|
+
description: "The value to be tested for NaN",
|
|
258
|
+
required: true,
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
returnType: "boolean",
|
|
262
|
+
},
|
|
263
|
+
isFinite: {
|
|
264
|
+
description: "Determines whether the passed value is a finite number",
|
|
265
|
+
params: [
|
|
266
|
+
{
|
|
267
|
+
kind: "primitive" as const,
|
|
268
|
+
name: "value",
|
|
269
|
+
types: ["any"],
|
|
270
|
+
description: "The value to be tested for finiteness",
|
|
271
|
+
required: true,
|
|
272
|
+
},
|
|
273
|
+
],
|
|
274
|
+
returnType: "boolean",
|
|
275
|
+
},
|
|
276
|
+
parseInt: {
|
|
277
|
+
description: "Parses a string argument and returns an integer of the specified radix",
|
|
278
|
+
params: [
|
|
279
|
+
{
|
|
280
|
+
kind: "primitive" as const,
|
|
281
|
+
name: "string",
|
|
282
|
+
types: ["string"],
|
|
283
|
+
description: "The value to parse",
|
|
284
|
+
required: true,
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
kind: "primitive" as const,
|
|
288
|
+
name: "radix",
|
|
289
|
+
types: ["number"],
|
|
290
|
+
description: "An integer between 2 and 36 that represents the radix of the string. Defaults to 10",
|
|
291
|
+
required: false,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
returnType: "number",
|
|
295
|
+
},
|
|
296
|
+
parseFloat: {
|
|
297
|
+
description: "Parses a string argument and returns a floating point number",
|
|
298
|
+
params: [
|
|
299
|
+
{
|
|
300
|
+
kind: "primitive" as const,
|
|
301
|
+
name: "string",
|
|
302
|
+
types: ["string"],
|
|
303
|
+
description: "The value to parse",
|
|
304
|
+
required: true,
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
returnType: "number",
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
[NUMBER_PROTOTYPE]: {
|
|
313
|
+
global: false,
|
|
314
|
+
intrinsic: true,
|
|
315
|
+
methods: {
|
|
316
|
+
toFixed: {
|
|
317
|
+
description: "Returns a string representation of a number in fixed-point notation",
|
|
318
|
+
params: [
|
|
319
|
+
{
|
|
320
|
+
kind: "primitive" as const,
|
|
321
|
+
name: "fractionDigits",
|
|
322
|
+
types: ["number"],
|
|
323
|
+
description: "Number of digits after the decimal point. Must be in the range 0 - 20",
|
|
324
|
+
required: false,
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
returnType: "string",
|
|
328
|
+
},
|
|
329
|
+
toPrecision: {
|
|
330
|
+
description:
|
|
331
|
+
"Returns a string representation of a number in fixed-point or exponential notation with a specified number of significant digits",
|
|
332
|
+
params: [
|
|
333
|
+
{
|
|
334
|
+
kind: "primitive" as const,
|
|
335
|
+
name: "precision",
|
|
336
|
+
types: ["number"],
|
|
337
|
+
description: "Number of significant digits. Must be in the range 1 - 21",
|
|
338
|
+
required: false,
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
returnType: "string",
|
|
342
|
+
},
|
|
343
|
+
toExponential: {
|
|
344
|
+
description: "Returns a string representation of a number in exponential notation",
|
|
345
|
+
params: [
|
|
346
|
+
{
|
|
347
|
+
kind: "primitive" as const,
|
|
348
|
+
name: "fractionDigits",
|
|
349
|
+
types: ["number"],
|
|
350
|
+
description: "Number of digits after the decimal point. Must be in the range 0 - 20",
|
|
351
|
+
required: false,
|
|
352
|
+
},
|
|
353
|
+
],
|
|
354
|
+
returnType: "string",
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
[ARRAY]: {
|
|
360
|
+
global: true,
|
|
361
|
+
intrinsic: false,
|
|
362
|
+
methods: {
|
|
363
|
+
isArray: {
|
|
364
|
+
description: "Determines whether the passed value is an Array",
|
|
365
|
+
params: [
|
|
366
|
+
{
|
|
367
|
+
kind: "primitive" as const,
|
|
368
|
+
name: "value",
|
|
369
|
+
types: ["any"],
|
|
370
|
+
description: "The value to be checked",
|
|
371
|
+
required: true,
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
returnType: "boolean",
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
|
|
379
|
+
[ARRAY_PROTOTYPE]: {
|
|
380
|
+
global: false,
|
|
381
|
+
intrinsic: true,
|
|
382
|
+
generic: "<T>",
|
|
383
|
+
methods: {
|
|
384
|
+
map: {
|
|
385
|
+
description:
|
|
386
|
+
"Calls a defined callback function on each element of an array, and returns an array that contains the results",
|
|
387
|
+
params: [
|
|
388
|
+
{
|
|
389
|
+
kind: "function" as const,
|
|
390
|
+
name: "callback",
|
|
391
|
+
description:
|
|
392
|
+
"A function that accepts up to three arguments. The map method calls the callback function one time for each element in the array",
|
|
393
|
+
required: true,
|
|
394
|
+
signature: {
|
|
395
|
+
params: [
|
|
396
|
+
{ name: "value", type: "T" },
|
|
397
|
+
{ name: "index", type: "number" },
|
|
398
|
+
{ name: "array", type: "T[]" },
|
|
399
|
+
],
|
|
400
|
+
returnType: "U",
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
kind: "primitive" as const,
|
|
405
|
+
name: "thisArg",
|
|
406
|
+
types: ["any"],
|
|
407
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
408
|
+
required: false,
|
|
409
|
+
},
|
|
410
|
+
],
|
|
411
|
+
returnType: "U[]",
|
|
412
|
+
},
|
|
413
|
+
filter: {
|
|
414
|
+
description: "Returns the elements of an array that meet the condition specified in a callback function",
|
|
415
|
+
params: [
|
|
416
|
+
{
|
|
417
|
+
kind: "function" as const,
|
|
418
|
+
name: "callback",
|
|
419
|
+
description:
|
|
420
|
+
"A function that accepts up to three arguments. The filter method calls the callback function one time for each element in the array",
|
|
421
|
+
required: true,
|
|
422
|
+
signature: {
|
|
423
|
+
params: [
|
|
424
|
+
{ name: "value", type: "T" },
|
|
425
|
+
{ name: "index", type: "number" },
|
|
426
|
+
{ name: "array", type: "T[]" },
|
|
427
|
+
],
|
|
428
|
+
returnType: "boolean",
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
kind: "primitive" as const,
|
|
433
|
+
name: "thisArg",
|
|
434
|
+
types: ["any"],
|
|
435
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
436
|
+
required: false,
|
|
437
|
+
},
|
|
438
|
+
],
|
|
439
|
+
returnType: "T[]",
|
|
440
|
+
},
|
|
441
|
+
reduce: {
|
|
442
|
+
description:
|
|
443
|
+
"Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function",
|
|
444
|
+
params: [
|
|
445
|
+
{
|
|
446
|
+
kind: "function" as const,
|
|
447
|
+
name: "callback",
|
|
448
|
+
description:
|
|
449
|
+
"A function that accepts up to four arguments. The reduce method calls the callback function one time for each element in the array",
|
|
450
|
+
required: true,
|
|
451
|
+
signature: {
|
|
452
|
+
params: [
|
|
453
|
+
{ name: "previousValue", type: "U" },
|
|
454
|
+
{ name: "currentValue", type: "T" },
|
|
455
|
+
{ name: "currentIndex", type: "number" },
|
|
456
|
+
{ name: "array", type: "T[]" },
|
|
457
|
+
],
|
|
458
|
+
returnType: "U",
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
kind: "primitive" as const,
|
|
463
|
+
name: "initialValue",
|
|
464
|
+
types: ["any"],
|
|
465
|
+
description: "If initialValue is specified, it is used as the initial value to start the accumulation",
|
|
466
|
+
required: false,
|
|
467
|
+
},
|
|
468
|
+
],
|
|
469
|
+
returnType: "U",
|
|
470
|
+
},
|
|
471
|
+
find: {
|
|
472
|
+
description:
|
|
473
|
+
"Returns the value of the first element in the array where predicate is true, and undefined otherwise",
|
|
474
|
+
params: [
|
|
475
|
+
{
|
|
476
|
+
kind: "function" as const,
|
|
477
|
+
name: "callback",
|
|
478
|
+
description:
|
|
479
|
+
"A function that accepts up to three arguments. The find method calls the callback function one time for each element in the array, in ascending order, until it finds one where callback returns true",
|
|
480
|
+
required: true,
|
|
481
|
+
signature: {
|
|
482
|
+
params: [
|
|
483
|
+
{ name: "value", type: "T" },
|
|
484
|
+
{ name: "index", type: "number" },
|
|
485
|
+
{ name: "array", type: "T[]" },
|
|
486
|
+
],
|
|
487
|
+
returnType: "boolean",
|
|
488
|
+
},
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
kind: "primitive" as const,
|
|
492
|
+
name: "thisArg",
|
|
493
|
+
types: ["any"],
|
|
494
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
495
|
+
required: false,
|
|
496
|
+
},
|
|
497
|
+
],
|
|
498
|
+
returnType: "T | undefined",
|
|
499
|
+
},
|
|
500
|
+
some: {
|
|
501
|
+
description: "Determines whether the specified callback function returns true for any element of an array",
|
|
502
|
+
params: [
|
|
503
|
+
{
|
|
504
|
+
kind: "function" as const,
|
|
505
|
+
name: "callback",
|
|
506
|
+
description:
|
|
507
|
+
"A function that accepts up to three arguments. The some method calls the callback function for each element in the array until the callback returns true, or until the end of the array",
|
|
508
|
+
required: true,
|
|
509
|
+
signature: {
|
|
510
|
+
params: [
|
|
511
|
+
{ name: "value", type: "T" },
|
|
512
|
+
{ name: "index", type: "number" },
|
|
513
|
+
{ name: "array", type: "T[]" },
|
|
514
|
+
],
|
|
515
|
+
returnType: "boolean",
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
{
|
|
519
|
+
kind: "primitive" as const,
|
|
520
|
+
name: "thisArg",
|
|
521
|
+
types: ["any"],
|
|
522
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
523
|
+
required: false,
|
|
524
|
+
},
|
|
525
|
+
],
|
|
526
|
+
returnType: "boolean",
|
|
527
|
+
},
|
|
528
|
+
every: {
|
|
529
|
+
description: "Determines whether all the members of an array satisfy the specified test",
|
|
530
|
+
params: [
|
|
531
|
+
{
|
|
532
|
+
kind: "function" as const,
|
|
533
|
+
name: "callback",
|
|
534
|
+
description:
|
|
535
|
+
"A function that accepts up to three arguments. The every method calls the callback function for each element in the array until the callback returns false, or until the end of the array",
|
|
536
|
+
required: true,
|
|
537
|
+
signature: {
|
|
538
|
+
params: [
|
|
539
|
+
{ name: "value", type: "T" },
|
|
540
|
+
{ name: "index", type: "number" },
|
|
541
|
+
{ name: "array", type: "T[]" },
|
|
542
|
+
],
|
|
543
|
+
returnType: "boolean",
|
|
544
|
+
},
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
kind: "primitive" as const,
|
|
548
|
+
name: "thisArg",
|
|
549
|
+
types: ["any"],
|
|
550
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
551
|
+
required: false,
|
|
552
|
+
},
|
|
553
|
+
],
|
|
554
|
+
returnType: "boolean",
|
|
555
|
+
},
|
|
556
|
+
slice: {
|
|
557
|
+
description:
|
|
558
|
+
"Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array",
|
|
559
|
+
params: [
|
|
560
|
+
{
|
|
561
|
+
kind: "primitive" as const,
|
|
562
|
+
name: "start",
|
|
563
|
+
types: ["number"],
|
|
564
|
+
description: "The beginning index of the specified portion of the array",
|
|
565
|
+
required: false,
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
kind: "primitive" as const,
|
|
569
|
+
name: "end",
|
|
570
|
+
types: ["number"],
|
|
571
|
+
description:
|
|
572
|
+
"The end index of the specified portion of the array. This is exclusive of the element at the index 'end'",
|
|
573
|
+
required: false,
|
|
574
|
+
},
|
|
575
|
+
],
|
|
576
|
+
returnType: "T[]",
|
|
577
|
+
},
|
|
578
|
+
includes: {
|
|
579
|
+
description: "Determines whether an array includes a certain element, returning true or false as appropriate",
|
|
580
|
+
params: [
|
|
581
|
+
{
|
|
582
|
+
kind: "primitive" as const,
|
|
583
|
+
name: "searchElement",
|
|
584
|
+
types: ["T"],
|
|
585
|
+
description: "The value to locate in the array",
|
|
586
|
+
required: true,
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
kind: "primitive" as const,
|
|
590
|
+
name: "fromIndex",
|
|
591
|
+
types: ["number"],
|
|
592
|
+
description:
|
|
593
|
+
"The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0",
|
|
594
|
+
required: false,
|
|
595
|
+
},
|
|
596
|
+
],
|
|
597
|
+
returnType: "boolean",
|
|
598
|
+
},
|
|
599
|
+
indexOf: {
|
|
600
|
+
description: "Returns the index of the first occurrence of a value in an array, or -1 if it is not present",
|
|
601
|
+
params: [
|
|
602
|
+
{
|
|
603
|
+
kind: "primitive" as const,
|
|
604
|
+
name: "searchElement",
|
|
605
|
+
types: ["T"],
|
|
606
|
+
description: "The value to locate in the array",
|
|
607
|
+
required: true,
|
|
608
|
+
},
|
|
609
|
+
{
|
|
610
|
+
kind: "primitive" as const,
|
|
611
|
+
name: "fromIndex",
|
|
612
|
+
types: ["number"],
|
|
613
|
+
description:
|
|
614
|
+
"The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0",
|
|
615
|
+
required: false,
|
|
616
|
+
},
|
|
617
|
+
],
|
|
618
|
+
returnType: "number",
|
|
619
|
+
},
|
|
620
|
+
join: {
|
|
621
|
+
description: "Adds all the elements of an array into a string, separated by the specified separator string",
|
|
622
|
+
params: [
|
|
623
|
+
{
|
|
624
|
+
kind: "primitive" as const,
|
|
625
|
+
name: "separator",
|
|
626
|
+
types: ["string"],
|
|
627
|
+
description:
|
|
628
|
+
"A string used to separate one element of the array from the next in the resulting string. If omitted, the array elements are separated with a comma",
|
|
629
|
+
required: false,
|
|
630
|
+
},
|
|
631
|
+
],
|
|
632
|
+
returnType: "string",
|
|
633
|
+
},
|
|
634
|
+
at: {
|
|
635
|
+
description: "Returns the item located at the specified index",
|
|
636
|
+
params: [
|
|
637
|
+
{
|
|
638
|
+
kind: "primitive" as const,
|
|
639
|
+
name: "index",
|
|
640
|
+
types: ["number"],
|
|
641
|
+
description:
|
|
642
|
+
"The zero-based index of the desired code unit. A negative index will count back from the last item",
|
|
643
|
+
required: true,
|
|
644
|
+
},
|
|
645
|
+
],
|
|
646
|
+
returnType: "T | undefined",
|
|
647
|
+
},
|
|
648
|
+
concat: {
|
|
649
|
+
description: "Combines two or more arrays into a single array",
|
|
650
|
+
params: [
|
|
651
|
+
{
|
|
652
|
+
kind: "primitive" as const,
|
|
653
|
+
name: "arrays",
|
|
654
|
+
types: ["T[]"],
|
|
655
|
+
description: "Additional arrays to add to the end of the array",
|
|
656
|
+
variadic: true,
|
|
657
|
+
},
|
|
658
|
+
],
|
|
659
|
+
returnType: "T[]",
|
|
660
|
+
},
|
|
661
|
+
findIndex: {
|
|
662
|
+
description: "Returns the index of the first element in the array where predicate is true, and -1 otherwise",
|
|
663
|
+
params: [
|
|
664
|
+
{
|
|
665
|
+
kind: "function" as const,
|
|
666
|
+
name: "callback",
|
|
667
|
+
description:
|
|
668
|
+
"A function that accepts up to three arguments. The findIndex method calls the callback function one time for each element in the array until it finds one where callback returns true",
|
|
669
|
+
required: true,
|
|
670
|
+
signature: {
|
|
671
|
+
params: [
|
|
672
|
+
{ name: "value", type: "T" },
|
|
673
|
+
{ name: "index", type: "number" },
|
|
674
|
+
{ name: "array", type: "T[]" },
|
|
675
|
+
],
|
|
676
|
+
returnType: "boolean",
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
kind: "primitive" as const,
|
|
681
|
+
name: "thisArg",
|
|
682
|
+
types: ["any"],
|
|
683
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
684
|
+
required: false,
|
|
685
|
+
},
|
|
686
|
+
],
|
|
687
|
+
returnType: "number",
|
|
688
|
+
},
|
|
689
|
+
flat: {
|
|
690
|
+
description:
|
|
691
|
+
"Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth",
|
|
692
|
+
params: [
|
|
693
|
+
{
|
|
694
|
+
kind: "primitive" as const,
|
|
695
|
+
name: "depth",
|
|
696
|
+
types: ["number"],
|
|
697
|
+
description: "The maximum recursion depth. Defaults to 1",
|
|
698
|
+
required: false,
|
|
699
|
+
},
|
|
700
|
+
],
|
|
701
|
+
returnType: "T[]",
|
|
702
|
+
},
|
|
703
|
+
flatMap: {
|
|
704
|
+
description:
|
|
705
|
+
"Calls a defined callback function on each element of an array, then flattens the result into a new array",
|
|
706
|
+
params: [
|
|
707
|
+
{
|
|
708
|
+
kind: "function" as const,
|
|
709
|
+
name: "callback",
|
|
710
|
+
description:
|
|
711
|
+
"A function that accepts up to three arguments. The flatMap method calls the callback function one time for each element in the array",
|
|
712
|
+
required: true,
|
|
713
|
+
signature: {
|
|
714
|
+
params: [
|
|
715
|
+
{ name: "value", type: "T" },
|
|
716
|
+
{ name: "index", type: "number" },
|
|
717
|
+
{ name: "array", type: "T[]" },
|
|
718
|
+
],
|
|
719
|
+
returnType: "U",
|
|
720
|
+
},
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
kind: "primitive" as const,
|
|
724
|
+
name: "thisArg",
|
|
725
|
+
types: ["any"],
|
|
726
|
+
description: "An object to which the this keyword can refer in the callback function",
|
|
727
|
+
required: false,
|
|
728
|
+
},
|
|
729
|
+
],
|
|
730
|
+
returnType: "U[]",
|
|
731
|
+
},
|
|
732
|
+
},
|
|
733
|
+
properties: {
|
|
734
|
+
length: {
|
|
735
|
+
type: "number",
|
|
736
|
+
readonly: true,
|
|
737
|
+
description: "Gets the length of the array. This is a number one higher than the highest index in the array",
|
|
738
|
+
},
|
|
739
|
+
},
|
|
740
|
+
},
|
|
741
|
+
|
|
742
|
+
[STRING_PROTOTYPE]: {
|
|
743
|
+
global: false,
|
|
744
|
+
intrinsic: true,
|
|
745
|
+
methods: {
|
|
746
|
+
charAt: {
|
|
747
|
+
description: "Returns the character at the specified index",
|
|
748
|
+
params: [
|
|
749
|
+
{
|
|
750
|
+
kind: "primitive" as const,
|
|
751
|
+
name: "index",
|
|
752
|
+
types: ["number"],
|
|
753
|
+
description: "The zero-based index of the desired character",
|
|
754
|
+
required: true,
|
|
755
|
+
},
|
|
756
|
+
],
|
|
757
|
+
returnType: "string",
|
|
758
|
+
},
|
|
759
|
+
charCodeAt: {
|
|
760
|
+
description: "Returns the Unicode value of the character at the specified location",
|
|
761
|
+
params: [
|
|
762
|
+
{
|
|
763
|
+
kind: "primitive" as const,
|
|
764
|
+
name: "index",
|
|
765
|
+
types: ["number"],
|
|
766
|
+
description:
|
|
767
|
+
"The zero-based index of the desired character. If there is no character at the specified index, NaN is returned",
|
|
768
|
+
required: true,
|
|
769
|
+
},
|
|
770
|
+
],
|
|
771
|
+
returnType: "number",
|
|
772
|
+
},
|
|
773
|
+
concat: {
|
|
774
|
+
description: "Returns a string that contains the concatenation of two or more strings",
|
|
775
|
+
params: [
|
|
776
|
+
{
|
|
777
|
+
kind: "primitive" as const,
|
|
778
|
+
name: "strings",
|
|
779
|
+
types: ["string"],
|
|
780
|
+
description: "The strings to append to the end of the string",
|
|
781
|
+
variadic: true,
|
|
782
|
+
},
|
|
783
|
+
],
|
|
784
|
+
returnType: "string",
|
|
785
|
+
},
|
|
786
|
+
endsWith: {
|
|
787
|
+
description:
|
|
788
|
+
"Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at endPosition – length(this). Otherwise returns false",
|
|
789
|
+
params: [
|
|
790
|
+
{
|
|
791
|
+
kind: "primitive" as const,
|
|
792
|
+
name: "searchString",
|
|
793
|
+
types: ["string"],
|
|
794
|
+
description: "The characters to be searched for at the end of this string",
|
|
795
|
+
required: true,
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
kind: "primitive" as const,
|
|
799
|
+
name: "length",
|
|
800
|
+
types: ["number"],
|
|
801
|
+
description: "If provided, it is used as the length of this string. Defaults to this string's length",
|
|
802
|
+
required: false,
|
|
803
|
+
},
|
|
804
|
+
],
|
|
805
|
+
returnType: "boolean",
|
|
806
|
+
},
|
|
807
|
+
includes: {
|
|
808
|
+
description:
|
|
809
|
+
"Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false",
|
|
810
|
+
params: [
|
|
811
|
+
{
|
|
812
|
+
kind: "primitive" as const,
|
|
813
|
+
name: "searchString",
|
|
814
|
+
types: ["string"],
|
|
815
|
+
description: "The string to search for",
|
|
816
|
+
required: true,
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
kind: "primitive" as const,
|
|
820
|
+
name: "position",
|
|
821
|
+
types: ["number"],
|
|
822
|
+
description: "The position in this string at which to begin searching for searchString. Defaults to 0",
|
|
823
|
+
required: false,
|
|
824
|
+
},
|
|
825
|
+
],
|
|
826
|
+
returnType: "boolean",
|
|
827
|
+
},
|
|
828
|
+
indexOf: {
|
|
829
|
+
description: "Returns the position of the first occurrence of a substring",
|
|
830
|
+
params: [
|
|
831
|
+
{
|
|
832
|
+
kind: "primitive" as const,
|
|
833
|
+
name: "searchString",
|
|
834
|
+
types: ["string"],
|
|
835
|
+
description: "The substring to search for in the string",
|
|
836
|
+
required: true,
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
kind: "primitive" as const,
|
|
840
|
+
name: "position",
|
|
841
|
+
types: ["number"],
|
|
842
|
+
description:
|
|
843
|
+
"The index at which to begin searching the String object. If omitted, search starts at the beginning of the string",
|
|
844
|
+
required: false,
|
|
845
|
+
},
|
|
846
|
+
],
|
|
847
|
+
returnType: "number",
|
|
848
|
+
},
|
|
849
|
+
lastIndexOf: {
|
|
850
|
+
description: "Returns the last occurrence of a substring in the string",
|
|
851
|
+
params: [
|
|
852
|
+
{
|
|
853
|
+
kind: "primitive" as const,
|
|
854
|
+
name: "searchString",
|
|
855
|
+
types: ["string"],
|
|
856
|
+
description: "The substring to search for",
|
|
857
|
+
required: true,
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
kind: "primitive" as const,
|
|
861
|
+
name: "position",
|
|
862
|
+
types: ["number"],
|
|
863
|
+
description:
|
|
864
|
+
"The index at which to begin searching. If omitted, the search begins at the end of the string",
|
|
865
|
+
required: false,
|
|
866
|
+
},
|
|
867
|
+
],
|
|
868
|
+
returnType: "number",
|
|
869
|
+
},
|
|
870
|
+
slice: {
|
|
871
|
+
description: "Returns a section of a string",
|
|
872
|
+
params: [
|
|
873
|
+
{
|
|
874
|
+
kind: "primitive" as const,
|
|
875
|
+
name: "start",
|
|
876
|
+
types: ["number"],
|
|
877
|
+
description: "The index to the beginning of the specified portion of stringObj",
|
|
878
|
+
required: false,
|
|
879
|
+
},
|
|
880
|
+
{
|
|
881
|
+
kind: "primitive" as const,
|
|
882
|
+
name: "end",
|
|
883
|
+
types: ["number"],
|
|
884
|
+
description:
|
|
885
|
+
"The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end",
|
|
886
|
+
required: false,
|
|
887
|
+
},
|
|
888
|
+
],
|
|
889
|
+
returnType: "string",
|
|
890
|
+
},
|
|
891
|
+
split: {
|
|
892
|
+
description: "Split a string into substrings using the specified separator and return them as an array",
|
|
893
|
+
params: [
|
|
894
|
+
{
|
|
895
|
+
kind: "primitive" as const,
|
|
896
|
+
name: "separator",
|
|
897
|
+
types: ["string", "RegExp"],
|
|
898
|
+
description:
|
|
899
|
+
"A string or Regular Expression that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned",
|
|
900
|
+
required: false,
|
|
901
|
+
},
|
|
902
|
+
{
|
|
903
|
+
kind: "primitive" as const,
|
|
904
|
+
name: "limit",
|
|
905
|
+
types: ["number"],
|
|
906
|
+
description: "A value used to limit the number of elements returned in the array",
|
|
907
|
+
required: false,
|
|
908
|
+
},
|
|
909
|
+
],
|
|
910
|
+
returnType: "string[]",
|
|
911
|
+
},
|
|
912
|
+
startsWith: {
|
|
913
|
+
description:
|
|
914
|
+
"Returns true if the sequence of elements of searchString converted to a String is the same as the corresponding elements of this object (converted to a String) starting at position. Otherwise returns false",
|
|
915
|
+
params: [
|
|
916
|
+
{
|
|
917
|
+
kind: "primitive" as const,
|
|
918
|
+
name: "searchString",
|
|
919
|
+
types: ["string"],
|
|
920
|
+
description: "The characters to be searched for at the start of this string",
|
|
921
|
+
required: true,
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
kind: "primitive" as const,
|
|
925
|
+
name: "position",
|
|
926
|
+
types: ["number"],
|
|
927
|
+
description: "The position in this string at which to begin searching for searchString. Defaults to 0",
|
|
928
|
+
required: false,
|
|
929
|
+
},
|
|
930
|
+
],
|
|
931
|
+
returnType: "boolean",
|
|
932
|
+
},
|
|
933
|
+
substring: {
|
|
934
|
+
description: "Returns the substring at the specified location within a String object",
|
|
935
|
+
params: [
|
|
936
|
+
{
|
|
937
|
+
kind: "primitive" as const,
|
|
938
|
+
name: "start",
|
|
939
|
+
types: ["number"],
|
|
940
|
+
description: "The zero-based index number indicating the beginning of the substring",
|
|
941
|
+
required: true,
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
kind: "primitive" as const,
|
|
945
|
+
name: "end",
|
|
946
|
+
types: ["number"],
|
|
947
|
+
description:
|
|
948
|
+
"Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end",
|
|
949
|
+
required: false,
|
|
950
|
+
},
|
|
951
|
+
],
|
|
952
|
+
returnType: "string",
|
|
953
|
+
},
|
|
954
|
+
toLowerCase: {
|
|
955
|
+
description: "Converts all the alphabetic characters in a string to lowercase",
|
|
956
|
+
params: [],
|
|
957
|
+
returnType: "string",
|
|
958
|
+
},
|
|
959
|
+
toUpperCase: {
|
|
960
|
+
description: "Converts all the alphabetic characters in a string to uppercase",
|
|
961
|
+
params: [],
|
|
962
|
+
returnType: "string",
|
|
963
|
+
},
|
|
964
|
+
trim: {
|
|
965
|
+
description: "Removes the leading and trailing white space and line terminator characters from a string",
|
|
966
|
+
params: [],
|
|
967
|
+
returnType: "string",
|
|
968
|
+
},
|
|
969
|
+
trimStart: {
|
|
970
|
+
description: "Removes the leading white space and line terminator characters from a string",
|
|
971
|
+
params: [],
|
|
972
|
+
returnType: "string",
|
|
973
|
+
},
|
|
974
|
+
trimEnd: {
|
|
975
|
+
description: "Removes the trailing white space and line terminator characters from a string",
|
|
976
|
+
params: [],
|
|
977
|
+
returnType: "string",
|
|
978
|
+
},
|
|
979
|
+
replace: {
|
|
980
|
+
description: "Replaces text in a string, using a search string",
|
|
981
|
+
params: [
|
|
982
|
+
{
|
|
983
|
+
kind: "primitive" as const,
|
|
984
|
+
name: "searchValue",
|
|
985
|
+
types: ["string"],
|
|
986
|
+
description: "A string to search for",
|
|
987
|
+
required: true,
|
|
988
|
+
},
|
|
989
|
+
{
|
|
990
|
+
kind: "primitive" as const,
|
|
991
|
+
name: "replaceValue",
|
|
992
|
+
types: ["string"],
|
|
993
|
+
description:
|
|
994
|
+
"A string containing the text to replace for every successful match of searchValue in this string",
|
|
995
|
+
required: true,
|
|
996
|
+
},
|
|
997
|
+
],
|
|
998
|
+
returnType: "string",
|
|
999
|
+
},
|
|
1000
|
+
repeat: {
|
|
1001
|
+
description: "Returns a string value that is made from count copies concatenated together",
|
|
1002
|
+
params: [
|
|
1003
|
+
{
|
|
1004
|
+
kind: "primitive" as const,
|
|
1005
|
+
name: "count",
|
|
1006
|
+
types: ["number"],
|
|
1007
|
+
description: "The number of times to repeat the string",
|
|
1008
|
+
required: true,
|
|
1009
|
+
},
|
|
1010
|
+
],
|
|
1011
|
+
returnType: "string",
|
|
1012
|
+
},
|
|
1013
|
+
padStart: {
|
|
1014
|
+
description:
|
|
1015
|
+
"Pads the current string with another string until the resulting string reaches the given length, applied from the start of the current string",
|
|
1016
|
+
params: [
|
|
1017
|
+
{
|
|
1018
|
+
kind: "primitive" as const,
|
|
1019
|
+
name: "targetLength",
|
|
1020
|
+
types: ["number"],
|
|
1021
|
+
description: "The length of the resulting string once the current string has been padded",
|
|
1022
|
+
required: true,
|
|
1023
|
+
},
|
|
1024
|
+
{
|
|
1025
|
+
kind: "primitive" as const,
|
|
1026
|
+
name: "padString",
|
|
1027
|
+
types: ["string"],
|
|
1028
|
+
description: "The string to pad the current string with. Defaults to space",
|
|
1029
|
+
required: false,
|
|
1030
|
+
},
|
|
1031
|
+
],
|
|
1032
|
+
returnType: "string",
|
|
1033
|
+
},
|
|
1034
|
+
padEnd: {
|
|
1035
|
+
description:
|
|
1036
|
+
"Pads the current string with another string until the resulting string reaches the given length, applied from the end of the current string",
|
|
1037
|
+
params: [
|
|
1038
|
+
{
|
|
1039
|
+
kind: "primitive" as const,
|
|
1040
|
+
name: "targetLength",
|
|
1041
|
+
types: ["number"],
|
|
1042
|
+
description: "The length of the resulting string once the current string has been padded",
|
|
1043
|
+
required: true,
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
kind: "primitive" as const,
|
|
1047
|
+
name: "padString",
|
|
1048
|
+
types: ["string"],
|
|
1049
|
+
description: "The string to pad the current string with. Defaults to space",
|
|
1050
|
+
required: false,
|
|
1051
|
+
},
|
|
1052
|
+
],
|
|
1053
|
+
returnType: "string",
|
|
1054
|
+
},
|
|
1055
|
+
replaceAll: {
|
|
1056
|
+
description: "Replaces all occurrences of a search string with a replacement string",
|
|
1057
|
+
params: [
|
|
1058
|
+
{
|
|
1059
|
+
kind: "primitive" as const,
|
|
1060
|
+
name: "searchValue",
|
|
1061
|
+
types: ["string"],
|
|
1062
|
+
description: "The string to search for",
|
|
1063
|
+
required: true,
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
kind: "primitive" as const,
|
|
1067
|
+
name: "replaceValue",
|
|
1068
|
+
types: ["string"],
|
|
1069
|
+
description: "The string to replace all occurrences of searchValue with",
|
|
1070
|
+
required: true,
|
|
1071
|
+
},
|
|
1072
|
+
],
|
|
1073
|
+
returnType: "string",
|
|
1074
|
+
},
|
|
1075
|
+
},
|
|
1076
|
+
properties: {
|
|
1077
|
+
length: {
|
|
1078
|
+
type: "number",
|
|
1079
|
+
readonly: true,
|
|
1080
|
+
description: "Returns the length of a String object",
|
|
1081
|
+
},
|
|
1082
|
+
},
|
|
1083
|
+
},
|
|
1084
|
+
} as const;
|
|
1085
|
+
|
|
1086
|
+
export function getBuiltins(): Record<string, BuiltinSchema> {
|
|
1087
|
+
return structuredClone(BUILTINS);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
export function getBuiltinGlobals(): string[] {
|
|
1091
|
+
return Object.keys(BUILTINS).filter((name) => BUILTINS[name].global === true);
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
export function isAllowedOnArray(prop: string): boolean {
|
|
1095
|
+
const arrayMethods = BUILTINS[ARRAY_PROTOTYPE]?.methods || {};
|
|
1096
|
+
const arrayProperties = BUILTINS[ARRAY_PROTOTYPE]?.properties || {};
|
|
1097
|
+
return prop in arrayMethods || prop in arrayProperties;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
export function isAllowedOnString(prop: string): boolean {
|
|
1101
|
+
const stringMethods = BUILTINS[STRING_PROTOTYPE]?.methods || {};
|
|
1102
|
+
const stringProperties = BUILTINS[STRING_PROTOTYPE]?.properties || {};
|
|
1103
|
+
return prop in stringMethods || prop in stringProperties;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
export function isMethodAllowed(methodName: string): boolean {
|
|
1107
|
+
for (const schema of Object.values(BUILTINS)) {
|
|
1108
|
+
if (schema.methods?.[methodName]) {
|
|
1109
|
+
return true;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
export function getMethodDefinition(methodName: string): BuiltinMethodSchema | null {
|
|
1116
|
+
for (const schema of Object.values(BUILTINS)) {
|
|
1117
|
+
if (schema.methods?.[methodName]) {
|
|
1118
|
+
return schema.methods[methodName];
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return null;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
export function getAvailableArrayMembers(): string[] {
|
|
1125
|
+
const arrayNamespace = BUILTINS[ARRAY_PROTOTYPE];
|
|
1126
|
+
const methods = Object.keys(arrayNamespace?.methods || {});
|
|
1127
|
+
const properties = Object.keys(arrayNamespace?.properties || {});
|
|
1128
|
+
return [...methods, ...properties];
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
export function getAvailableStringMembers(): string[] {
|
|
1132
|
+
const stringNamespace = BUILTINS[STRING_PROTOTYPE];
|
|
1133
|
+
const methods = Object.keys(stringNamespace?.methods || {});
|
|
1134
|
+
const properties = Object.keys(stringNamespace?.properties || {});
|
|
1135
|
+
return [...methods, ...properties];
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
export function getMethodDisplayName(methodName: string): string {
|
|
1139
|
+
for (const [namespace, schema] of Object.entries(BUILTINS)) {
|
|
1140
|
+
if (schema.methods?.[methodName]) {
|
|
1141
|
+
if (schema.global) {
|
|
1142
|
+
return [namespace, methodName].join(".");
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
return methodName;
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
return methodName;
|
|
1149
|
+
}
|