summaryrefslogtreecommitdiffhomepage
path: root/README.md
AgeCommit message (Collapse)Author
2022-01-07lib: implement uniq() functionJo-Philipp Wich
The uniq() function allows extracting all unique values from a given input array in an efficient manner. It is roughly equivalent to the following ucode idiom: let seen = {} let unique = filter(array, item => !seen[item]++); In contrast to the code above, `uniq()` does not rely on implicit stringification of item values but performs strict equality tests internally. If equivalence of stringified results is desired, the following code can be used: let unique = uniq(map(array, item => "" + item)); Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-08lib: implement b64enc() and b64dec() functionsJo-Philipp Wich
The new functions allow encoding and decoding base64 values respectively. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-07lib: implement min() and max() functionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-06-04lib: implement `sourcepath()` functionJo-Philipp Wich
The sourcepath() function allows querying the filesystem path of the source file currently being executed by ucode. The optional depth argument can be used to walk up the include stack to determine the path of the file that included the current file, the path of the parent file of the parent file and so on. By specifying a truish value as second argument, only the directory portion of the source file path is returned. This is useful to e.g. discover ressources relative to the current source file directory. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-18syntax: introduce `const` supportJo-Philipp Wich
Introduce support for declaring constant variables through the `const` keyword. Variables declared with `const` follow the same scoping rules as `let` declared ones. In contrast to normal variables, `const` ones may not be assigned to after their declaration. Any attempt to do so will result in a syntax error during compilation. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-18syntax: implement `delete` as proper operatorJo-Philipp Wich
Turn `delete` into a proper operator mimicking ECMAScript semantics. Also ensure to transparently turn deprecated `delete(obj, propname)` function calls into `delete obj.propname` expressions during compilation. When strict mode is active, legacy delete() calls throw a syntax error instead. Finally drop the `delete()` function from the stdlib as it is shadowed by the delete operator syntax now. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-18lib: implement wildcard() functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-11lib: implement regexp(), a function to construct regexp instances at runtimeJo-Philipp Wich
Provide a new ucode function regexp() which allows constructing regular expression instances from separate source and flag strings. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-10lib: implement render(), an include variant capturing output in a stringJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-04lib: implement assert()Jo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-05-04lib: add support for pretty printing JSON to printf() and sprintf()Jo-Philipp Wich
Honour precision specifiers when parsing `J` format strings to enable or disable JSON pretty printing. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-04-21lib: implement sleep(ms) functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08lib: retain prototype when passing scopes to include()Jo-Philipp Wich
Change uc_include() to retain the prototype of the given scope object when processing includes. Also change the default behaviour to register the current VM scope as prototype on the passed scope object so that included code has access to functions such as length(), print() etc. by default. To actually sandbox the included code, the new `proto()` function can be used to create a scope object with an empty prototype: `include(..., proto({ ... }, {}))` Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08lib: introduce new proto() ucode functionJo-Philipp Wich
The proto() function allows getting and setting the prototype value of array or object values, which is useful to build object instances. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-03-08README.md: document trace() functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-19treewide: rebrand to ucodeJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-16lib: extend length() to handle objectsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-16lib: extend ord() to allow reading byte values at arbitrary indexesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-16README.md: fix typosJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-11-16lib: add system() functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-06lib: add warn() functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-10-02lib: add include() functionJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-26lib: add json() functionJo-Philipp Wich
The json function allows parsing JSON strings into structured data. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-26lib: implement '%J' printf formatJo-Philipp Wich
The `%J` format allows outputting values as valid JSON string. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-09-24syntax: add regular expression supportJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-22lib.c: add printf and sprintf functionsJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-21README.md: add a couple of typo and syntax fixesJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-08-21Add README.mdJo-Philipp Wich
Signed-off-by: Jo-Philipp Wich <jo@mein.io>