@misterscan/sesi 1.1.1
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 +191 -0
- package/bin/sesi.js +56 -0
- package/dist/ai-runtime.d.ts +15 -0
- package/dist/ai-runtime.d.ts.map +1 -0
- package/dist/ai-runtime.js +214 -0
- package/dist/ai-runtime.js.map +1 -0
- package/dist/builtins.d.ts +7 -0
- package/dist/builtins.d.ts.map +1 -0
- package/dist/builtins.js +473 -0
- package/dist/builtins.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter.d.ts +36 -0
- package/dist/interpreter.d.ts.map +1 -0
- package/dist/interpreter.js +495 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/lexer.d.ts +26 -0
- package/dist/lexer.d.ts.map +1 -0
- package/dist/lexer.js +340 -0
- package/dist/lexer.js.map +1 -0
- package/dist/parser.d.ts +55 -0
- package/dist/parser.d.ts.map +1 -0
- package/dist/parser.js +1022 -0
- package/dist/parser.js.map +1 -0
- package/dist/types.d.ts +304 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +63 -0
- package/dist/types.js.map +1 -0
- package/docs/ARCHITECTURE.md +430 -0
- package/docs/BUILTINS.md +577 -0
- package/docs/COMPARISON.md +334 -0
- package/docs/DISTRIBUTED_SYSTEMS.md +71 -0
- package/docs/IMAGE_GENERATION.md +76 -0
- package/docs/IMPLEMENTATION_SUMMARY.md +533 -0
- package/docs/QUICKSTART.md +351 -0
- package/docs/README.md +191 -0
- package/docs/ROADMAP.md +408 -0
- package/docs/SPECIFICATION.md +462 -0
- package/docs/SYSTEMS_REASONING.md +522 -0
- package/examples/01_hello.sesi +2 -0
- package/examples/02_variables.sesi +11 -0
- package/examples/03_functions.sesi +6 -0
- package/examples/04_conditionals.sesi +6 -0
- package/examples/05_loops.sesi +12 -0
- package/examples/06_arrays_objects.sesi +18 -0
- package/examples/07_prompts.sesi +10 -0
- package/examples/08_model_call.sesi +5 -0
- package/examples/09_structured_output.sesi +7 -0
- package/examples/10_code_generation.sesi +5 -0
- package/examples/11_memory_conversation.sesi +16 -0
- package/examples/12_classification.sesi +8 -0
- package/examples/13_data_pipeline.sesi +35 -0
- package/examples/14_folder_explainer.sesi +58 -0
- package/examples/15_image_generation.sesi +17 -0
- package/main/atm_deposit.sesi +37 -0
- package/main/atm_withdraw.sesi +37 -0
- package/main/data.txt +1 -0
- package/main/math_aggregator.sesi +15 -0
- package/main/math_generator.sesi +7 -0
- package/main/math_processor.sesi +23 -0
- package/main/orchestrator.sesi +15 -0
- package/main/playground.sesi +1 -0
- package/main/setup_swarm.sesi +5 -0
- package/main/start.sesi +13 -0
- package/main/tax_calculator.sesi +15 -0
- package/main/tests/compare.sesi +23 -0
- package/main/tests/compare.ts +104 -0
- package/main/tests/debug.sesi +1 -0
- package/main/tests/demo.sesi +24 -0
- package/main/tests/primitive_validation.sesi +18 -0
- package/main/tests/test_connection.sesi +4 -0
- package/main/tests/test_failure_debug.sesi +2 -0
- package/main/tests/test_image.sesi +3 -0
- package/main/tests/test_parser_config.sesi +2 -0
- package/main/tests/test_syntax.sesi +3 -0
- package/main/tests/test_tool_call.sesi +14 -0
- package/main/tests/try.sesi +7 -0
- package/main/vault.sesi +15 -0
- package/package.json +50 -0
package/docs/BUILTINS.md
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
# Sesi Built-in Functions Reference
|
|
2
|
+
|
|
3
|
+
## I/O Functions
|
|
4
|
+
|
|
5
|
+
### print(...args)
|
|
6
|
+
|
|
7
|
+
Print values to standard output, separated by spaces.
|
|
8
|
+
|
|
9
|
+
```sesi
|
|
10
|
+
print "Hello"
|
|
11
|
+
print 42
|
|
12
|
+
print "Value:", 10 + 20
|
|
13
|
+
print [1, 2, 3]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
**Returns**: `null`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Type Functions
|
|
21
|
+
|
|
22
|
+
### type(value) -> string
|
|
23
|
+
|
|
24
|
+
Get the type name of a value.
|
|
25
|
+
|
|
26
|
+
```sesi
|
|
27
|
+
type(42) // "number"
|
|
28
|
+
type("hello") // "string"
|
|
29
|
+
type(true) // "bool"
|
|
30
|
+
type(null) // "null"
|
|
31
|
+
type([1, 2, 3]) // "array"
|
|
32
|
+
type({}) // "object"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Returns**: `string` - one of: `"number"`, `"string"`, `"bool"`, `"null"`, `"array"`, `"object"`, `"unknown"`
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
### str(value) -> string
|
|
40
|
+
|
|
41
|
+
Convert any value to a string.
|
|
42
|
+
|
|
43
|
+
```sesi
|
|
44
|
+
str(42) // "42"
|
|
45
|
+
str(3.14) // "3.14"
|
|
46
|
+
str(true) // "true"
|
|
47
|
+
str([1, 2, 3]) // "[1, 2, 3]"
|
|
48
|
+
str({ "a": 1 }) // "{'a': 1}"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Returns**: `string`
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
### to_json(value) -> string
|
|
56
|
+
|
|
57
|
+
Convert an array or object into a valid, formatted JSON string.
|
|
58
|
+
|
|
59
|
+
```sesi
|
|
60
|
+
to_json({ "a": 1, "b": [1, 2] })
|
|
61
|
+
/*
|
|
62
|
+
{
|
|
63
|
+
"a": 1,
|
|
64
|
+
"b": [1, 2]
|
|
65
|
+
}
|
|
66
|
+
*/
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Returns**: `string` (valid JSON)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
### num(value) -> number
|
|
74
|
+
|
|
75
|
+
Convert a value to a number.
|
|
76
|
+
|
|
77
|
+
```sesi
|
|
78
|
+
num("42") // 42
|
|
79
|
+
num("3.14") // 3.14
|
|
80
|
+
num(true) // 1
|
|
81
|
+
num(false) // 0
|
|
82
|
+
num("hello") // null (can't convert)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Returns**: `number` or `null` if conversion fails
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### bool(value) -> bool
|
|
90
|
+
|
|
91
|
+
Convert a value to boolean.
|
|
92
|
+
|
|
93
|
+
```sesi
|
|
94
|
+
bool(1) // true
|
|
95
|
+
bool(0) // false
|
|
96
|
+
bool("") // false
|
|
97
|
+
bool("hello") // true
|
|
98
|
+
bool([]) // true
|
|
99
|
+
bool(null) // false
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Returns**: `bool` - Uses truthiness rules
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Collection Functions
|
|
107
|
+
|
|
108
|
+
### len(collection) -> number
|
|
109
|
+
|
|
110
|
+
Get the length of a string, array, or object.
|
|
111
|
+
|
|
112
|
+
```sesi
|
|
113
|
+
len("hello") // 5
|
|
114
|
+
len([1, 2, 3]) // 3
|
|
115
|
+
len({ "a": 1, "b": 2 }) // 2
|
|
116
|
+
len(null) // null (invalid)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Returns**: `number` or `null` if not a collection
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
### range(n) -> array
|
|
124
|
+
|
|
125
|
+
Create an array of numbers from 0 up to (but not including) n.
|
|
126
|
+
|
|
127
|
+
```sesi
|
|
128
|
+
range(5) // [0, 1, 2, 3, 4]
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Returns**: `array<number>`
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### push(array, value) -> array
|
|
136
|
+
|
|
137
|
+
Add an element to the end of an array.
|
|
138
|
+
|
|
139
|
+
```sesi
|
|
140
|
+
let arr = [1, 2, 3]
|
|
141
|
+
push(arr, 4)
|
|
142
|
+
print arr // [1, 2, 3, 4]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Note**: Modifies array in-place and returns it.
|
|
146
|
+
|
|
147
|
+
**Returns**: `array`
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### pop(array) -> any
|
|
152
|
+
|
|
153
|
+
Remove and return the last element of an array.
|
|
154
|
+
|
|
155
|
+
```sesi
|
|
156
|
+
let arr = [1, 2, 3]
|
|
157
|
+
let last = pop(arr)
|
|
158
|
+
print last // 3
|
|
159
|
+
print arr // [1, 2]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Returns**: The removed element, or `null` if array is empty
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
### join(array, separator) -> string
|
|
167
|
+
|
|
168
|
+
Join array elements into a string with separator.
|
|
169
|
+
|
|
170
|
+
```sesi
|
|
171
|
+
let arr = [1, 2, 3]
|
|
172
|
+
join(arr, "-") // "1-2-3"
|
|
173
|
+
join(["a", "b"], ", ") // "a, b"
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Returns**: `string`
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
### split(string, separator) -> array
|
|
181
|
+
|
|
182
|
+
Split a string into an array by separator.
|
|
183
|
+
|
|
184
|
+
```sesi
|
|
185
|
+
split("a,b,c", ",") // ["a", "b", "c"]
|
|
186
|
+
split("hello world", " ") // ["hello", "world"]
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Returns**: `array<string>`
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### keys(object) -> array
|
|
194
|
+
|
|
195
|
+
Get all keys of an object.
|
|
196
|
+
|
|
197
|
+
```sesi
|
|
198
|
+
let obj = { "name": "Alice", "age": 30 }
|
|
199
|
+
keys(obj) // ["name", "age"]
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Returns**: `array<string>` or `null` if not an object
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### values(object) -> array
|
|
207
|
+
|
|
208
|
+
Get all values of an object.
|
|
209
|
+
|
|
210
|
+
```sesi
|
|
211
|
+
let obj = {"name": "Alice", "age": 30}
|
|
212
|
+
values(obj) // ["Alice", 30]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Returns**: `array<any>` or `null` if not an object
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## File System Functions
|
|
220
|
+
|
|
221
|
+
### read_file(path) -> string
|
|
222
|
+
|
|
223
|
+
Read the contents of a file as a string.
|
|
224
|
+
|
|
225
|
+
```sesi
|
|
226
|
+
let text = read_file("input.txt")
|
|
227
|
+
print text
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Note**: Paths are resolved relative to the current working directory.
|
|
231
|
+
|
|
232
|
+
**Returns**: `string`
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
### write_file(path, content) -> bool
|
|
237
|
+
|
|
238
|
+
Write string content to a file. Overwrites the file if it exists.
|
|
239
|
+
|
|
240
|
+
```sesi
|
|
241
|
+
let success = write_file("output.txt", "Hello, Sesi!")
|
|
242
|
+
if success {print "File written successfully"}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Note**: Paths are resolved relative to the current working directory.
|
|
246
|
+
|
|
247
|
+
**Returns**: `bool` (true on success, throws on error)
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
### write_image(path, base64_content) -> bool
|
|
252
|
+
|
|
253
|
+
Write base64 encoded string content as an image file. Overwrites the file if it exists.
|
|
254
|
+
|
|
255
|
+
```sesi
|
|
256
|
+
let success = write_image("logo.png", logo_data)
|
|
257
|
+
if success {print "Image safely stored"}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Note**: Paths are resolved relative to the current working directory.
|
|
261
|
+
|
|
262
|
+
**Returns**: `bool` (true on success, throws on error)
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
### list_dir(path) -> array
|
|
267
|
+
|
|
268
|
+
List the contents of a directory as an array of strings.
|
|
269
|
+
|
|
270
|
+
```sesi
|
|
271
|
+
let files = list_dir(".")
|
|
272
|
+
print files
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Note**: Paths are resolved relative to the current working directory.
|
|
276
|
+
|
|
277
|
+
**Returns**: `array<string>`
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
### make_dir(path) -> bool
|
|
282
|
+
|
|
283
|
+
Create a new directory recursively. Returns `true` on success, `false` or throws on failure.
|
|
284
|
+
|
|
285
|
+
```sesi
|
|
286
|
+
let success = make_dir("new_directory")
|
|
287
|
+
if success {print "Directory created successfully"}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Note**: Paths are resolved relative to the current working directory.
|
|
291
|
+
|
|
292
|
+
**Returns**: `bool` (true on success, throws on error)
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## System Functions
|
|
297
|
+
|
|
298
|
+
### spawn(path) -> number
|
|
299
|
+
|
|
300
|
+
Launch a Sesi script as a concurrent background process. Returns the process ID (PID).
|
|
301
|
+
|
|
302
|
+
```sesi
|
|
303
|
+
let pid = spawn("worker.sesi")
|
|
304
|
+
print "Launched worker with PID:" pid
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
**Returns**: `number` (PID)
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
### exec(command) -> string
|
|
312
|
+
|
|
313
|
+
Execute a shell command synchronously and return its output.
|
|
314
|
+
|
|
315
|
+
```sesi
|
|
316
|
+
let files = exec("ls -la")
|
|
317
|
+
print files
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Returns**: `string` (stdout)
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
### time() -> number
|
|
325
|
+
|
|
326
|
+
Returns the current Unix timestamp in milliseconds.
|
|
327
|
+
|
|
328
|
+
```sesi
|
|
329
|
+
let start = time()
|
|
330
|
+
// ... do work ...
|
|
331
|
+
print "Elapsed time:" time() - start "ms"
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
**Returns**: `number`
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
### random() -> number
|
|
339
|
+
|
|
340
|
+
Returns a random floating-point number between 0 (inclusive) and 1 (exclusive).
|
|
341
|
+
|
|
342
|
+
```sesi
|
|
343
|
+
let rand = random()
|
|
344
|
+
if rand > 0.5 {print "Heads"} else {print "Tails"}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Returns**: `number`
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## Math-like Functions (v2 planned)
|
|
354
|
+
|
|
355
|
+
These are not yet implemented in v1.1 but will be added:
|
|
356
|
+
|
|
357
|
+
```sesi
|
|
358
|
+
// Planned for v2:
|
|
359
|
+
floor(n)
|
|
360
|
+
ceil(n)
|
|
361
|
+
round(n)
|
|
362
|
+
abs(n)
|
|
363
|
+
min(a, b)
|
|
364
|
+
max(a, b)
|
|
365
|
+
sqrt(n)
|
|
366
|
+
pow(a, b)
|
|
367
|
+
sin(n), cos(n), tan(n)
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Function Introspection (v2 planned)
|
|
371
|
+
|
|
372
|
+
These are planned for v2:
|
|
373
|
+
|
|
374
|
+
```sesi
|
|
375
|
+
// Get function name
|
|
376
|
+
name(func) -> string
|
|
377
|
+
|
|
378
|
+
// Get function arity (parameter count)
|
|
379
|
+
arity(func) -> number
|
|
380
|
+
|
|
381
|
+
// Check if value is a function
|
|
382
|
+
is_function(value) -> bool
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
---
|
|
386
|
+
|
|
387
|
+
## Collection Checks (v2 planned)
|
|
388
|
+
|
|
389
|
+
```sesi
|
|
390
|
+
// Planned for v2:
|
|
391
|
+
is_array(value) -> bool
|
|
392
|
+
is_object(value) -> bool
|
|
393
|
+
is_string(value) -> bool
|
|
394
|
+
is_number(value) -> bool
|
|
395
|
+
is_bool(value) -> bool
|
|
396
|
+
is_null(value) -> bool
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## String Functions (v2 planned)
|
|
402
|
+
|
|
403
|
+
```sesi
|
|
404
|
+
// Planned for v2:
|
|
405
|
+
length(string) -> number // Alias for len()
|
|
406
|
+
upper(string) -> string // Uppercase
|
|
407
|
+
lower(string) -> string // Lowercase
|
|
408
|
+
trim(string) -> string // Remove whitespace
|
|
409
|
+
contains(string, substring) -> bool
|
|
410
|
+
starts_with(string, prefix) -> bool
|
|
411
|
+
ends_with(string, suffix) -> bool
|
|
412
|
+
index_of(string, substring) -> number
|
|
413
|
+
slice(string, start, end?) -> string
|
|
414
|
+
replace(string, from, to) -> string
|
|
415
|
+
repeat(string, count) -> string
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## Array Functions (v2 planned)
|
|
421
|
+
|
|
422
|
+
```sesi
|
|
423
|
+
// Planned for v2:
|
|
424
|
+
map(array, fn) -> array // Transform elements
|
|
425
|
+
filter(array, fn) -> array // Keep matching elements
|
|
426
|
+
reduce(array, fn, initial) -> any
|
|
427
|
+
find(array, fn) -> any // First match
|
|
428
|
+
includes(array, value) -> bool
|
|
429
|
+
index_of(array, value) -> number
|
|
430
|
+
reverse(array) -> array
|
|
431
|
+
sort(array, compareFn?) -> array
|
|
432
|
+
unique(array) -> array // Remove duplicates
|
|
433
|
+
flatten(array) -> array // Flatten one level
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Error Handling
|
|
439
|
+
|
|
440
|
+
Sesi supports structured error handling via `try/catch` blocks.
|
|
441
|
+
|
|
442
|
+
```sesi
|
|
443
|
+
try
|
|
444
|
+
{let data = read_file("missing.txt")
|
|
445
|
+
}catch (e) {
|
|
446
|
+
print "Caught error:", e}
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
## Tips & Tricks
|
|
454
|
+
|
|
455
|
+
### Converting values
|
|
456
|
+
|
|
457
|
+
```sesi
|
|
458
|
+
// To string
|
|
459
|
+
str(value)
|
|
460
|
+
value + "" // Works for most types
|
|
461
|
+
|
|
462
|
+
// To number
|
|
463
|
+
num(string)
|
|
464
|
+
string + 0 // Doesn't work (concatenation)
|
|
465
|
+
|
|
466
|
+
// To bool
|
|
467
|
+
bool(value)
|
|
468
|
+
!(!value) // Double negation
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### Checking types
|
|
472
|
+
|
|
473
|
+
```sesi
|
|
474
|
+
type(value) == "array"
|
|
475
|
+
type(value) == "object"
|
|
476
|
+
type(value) == "null"
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### Working with arrays
|
|
480
|
+
|
|
481
|
+
```sesi
|
|
482
|
+
let arr = [1, 2, 3]
|
|
483
|
+
|
|
484
|
+
// Length
|
|
485
|
+
len(arr)
|
|
486
|
+
|
|
487
|
+
// Last element
|
|
488
|
+
arr[len(arr) - 1]
|
|
489
|
+
|
|
490
|
+
// Add element
|
|
491
|
+
push(arr, 4)
|
|
492
|
+
|
|
493
|
+
// Remove last
|
|
494
|
+
pop(arr)
|
|
495
|
+
|
|
496
|
+
// Join
|
|
497
|
+
join(arr, ", ")
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### Working with objects
|
|
501
|
+
|
|
502
|
+
```sesi
|
|
503
|
+
let obj = { "a": 1, "b": 2 }
|
|
504
|
+
|
|
505
|
+
// Get keys
|
|
506
|
+
keys(obj)
|
|
507
|
+
|
|
508
|
+
// Get values
|
|
509
|
+
values(obj)
|
|
510
|
+
|
|
511
|
+
// Check key
|
|
512
|
+
keys(obj) contains "a" // Future: not yet supported
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
---
|
|
516
|
+
|
|
517
|
+
## Standard Library Modules (v2 planned)
|
|
518
|
+
|
|
519
|
+
### std/math
|
|
520
|
+
|
|
521
|
+
```sesi
|
|
522
|
+
import { PI, E, sqrt, sin, cos } from "std/math"
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
### std/time
|
|
526
|
+
|
|
527
|
+
```sesi
|
|
528
|
+
import { now, sleep } from "std/time"
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
### std/json
|
|
532
|
+
|
|
533
|
+
```sesi
|
|
534
|
+
import { parse, stringify } from "std/json"
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
### std/http
|
|
538
|
+
|
|
539
|
+
```sesi
|
|
540
|
+
import { get, post } from "std/http"
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
---
|
|
544
|
+
|
|
545
|
+
## Performance Notes
|
|
546
|
+
|
|
547
|
+
- **print()** is unbuffered (each call flushes)
|
|
548
|
+
- **Array operations** are O(n) for most functions
|
|
549
|
+
- **Object operations** are O(1) for key access
|
|
550
|
+
- **String concatenation** with + is O(n) (consider pre-allocating)
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
## Return Value Reference
|
|
555
|
+
|
|
556
|
+
| Function | Return Value on Error |
|
|
557
|
+
| ------------- | --------------------------------- |
|
|
558
|
+
| num(value) | `null` |
|
|
559
|
+
| len(value) | `null` |
|
|
560
|
+
| keys(value) | `null` |
|
|
561
|
+
| values(value) | `null` |
|
|
562
|
+
| pop([]) | `null` |
|
|
563
|
+
| type(value) | `"unknown"` |
|
|
564
|
+
| str(value) | `"null"` or string representation |
|
|
565
|
+
|
|
566
|
+
---
|
|
567
|
+
|
|
568
|
+
## See Also
|
|
569
|
+
|
|
570
|
+
- [Quick Start](QUICKSTART.md)
|
|
571
|
+
- [Compare to other languages](COMPARISON.md)
|
|
572
|
+
- [Specification](SPECIFICATION.md)
|
|
573
|
+
- [Systems Reasoning Guide](SYSTEMS_REASONING.md)
|
|
574
|
+
- [Image Generation](IMAGE_GENERATION.md)
|
|
575
|
+
- [Roadmap](ROADMAP.md)
|
|
576
|
+
- [Distributed Systems](DISTRIBUTED_SYSTEMS.md)
|
|
577
|
+
- [Examples](../examples/)
|