diff --git a/.gitignore b/.gitignore index 5bd05d6..9fb6367 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ target -.idea \ No newline at end of file +.idea + +.DS_Store +./out +out diff --git a/Cargo.lock b/Cargo.lock index fd57148..601cc13 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -39,9 +39,9 @@ dependencies = [ [[package]] name = "amq-protocol" -version = "7.2.2" +version = "7.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a41c091e49edfcc098b4f90d4d7706a8cf9158034e84ebfee7ff346092f67c" +checksum = "587d313f3a8b4a40f866cc84b6059fe83133bf172165ac3b583129dd211d8e1c" dependencies = [ "amq-protocol-tcp", "amq-protocol-types", @@ -53,9 +53,9 @@ dependencies = [ [[package]] name = "amq-protocol-tcp" -version = "7.2.2" +version = "7.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed7a4a662472f88823ed2fc81babb0b00562f2c54284e3e7bffc02b6df649bf" +checksum = "dc707ab9aa964a85d9fc25908a3fdc486d2e619406883b3105b48bf304a8d606" dependencies = [ "amq-protocol-uri", "tcp-stream", @@ -64,9 +64,9 @@ dependencies = [ [[package]] name = "amq-protocol-types" -version = "7.2.2" +version = "7.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6484fdc918c1b6e2ae8eda2914d19a5873e1975f93ad8d33d6a24d1d98df05" +checksum = "bf99351d92a161c61ec6ecb213bc7057f5b837dd4e64ba6cb6491358efd770c4" dependencies = [ "cookie-factory", "nom", @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "amq-protocol-uri" -version = "7.2.2" +version = "7.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7f2da69e0e1182765bf33407cd8a843f20791b5af2b57a2645818c4776c56c" +checksum = "f89f8273826a676282208e5af38461a07fe939def57396af6ad5997fcf56577d" dependencies = [ "amq-protocol-types", "percent-encoding", @@ -91,12 +91,6 @@ version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" -[[package]] -name = "arc-swap" -version = "1.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457" - [[package]] name = "asn1-rs" version = "0.7.1" @@ -477,9 +471,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.21" +version = "1.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691782945451c1c383942c4874dbe63814f61cb57ef773cda2972682b7bb3c0" +checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" dependencies = [ "shlex", ] @@ -514,9 +508,9 @@ dependencies = [ [[package]] name = "code0-flow" -version = "0.0.10" +version = "0.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b691df7fa5e48beb1e4de29bf5928a286a5bfe4f1bb6ae6b13804d257197e0c7" +checksum = "7cf7a86a2ba2b0428289b0dc14b6a78d60ff94f84b80eb970e64382acac70319" dependencies = [ "async-trait", "futures-lite 2.6.0", @@ -1836,11 +1830,10 @@ dependencies = [ [[package]] name = "redis" -version = "0.30.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "438a4e5f8e9aa246d6f3666d6978441bf1b37d5f417b50c4dd220be09f5fcc17" +checksum = "0bc1ea653e0b2e097db3ebb5b7f678be339620b8041f66b30a308c1d45d36a7f" dependencies = [ - "arc-swap", "async-std", "bytes", "cfg-if", @@ -2027,9 +2020,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.2" +version = "0.103.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7149975849f1abb3832b246010ef62ccc80d3a76169517ada7188252b9cfb437" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" dependencies = [ "ring", "rustls-pki-types", @@ -2280,7 +2273,11 @@ name = "taurus" version = "0.1.0" dependencies = [ "code0-flow", + "futures-lite 2.6.0", "lapin", + "log", + "proc-macro2", + "quote", "serde", "serde_json", "tempfile", @@ -2580,9 +2577,9 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tucana" -version = "0.0.24" +version = "0.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cb09367cc920fc735409a26a9f7494df3c6aaa5681d6a5e06424413071c759a" +checksum = "db7694d43cff47f6464cf502b67f7f5c6da1b1e05f0693dda755e5eff8deeeaa" dependencies = [ "prost", "prost-types", @@ -2922,9 +2919,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.7.7" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cb8234a863ea0e8cd7284fcdd4f145233eb00fee02bbdd9861aec44e6477bc5" +checksum = "c06928c8748d81b05c9be96aad92e1b6ff01833332f281e8cfca3be4b35fc9ec" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 7cea124..a87ebfc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,14 +4,22 @@ version = "0.1.0" edition = "2021" [dependencies] -code0-flow = { version = "0.0.10", features = ["all"] } -tucana = { version = "0.0.24", features = ["aquila"] } +code0-flow = { version = "0.0.12", features = ["all"] } +tucana = { version = "0.0.28", features = ["aquila"] } lapin = "2.5.3" serde = "1.0.219" serde_json = "1.0.140" tokio = { version = "1.44.1", features = ["rt-multi-thread"] } -tucana = "0.0.20" toml = "0.8.0" +log = "0.4.27" +futures-lite = "2.6.0" [dev-dependencies] tempfile = "3.19.1" + +[build-dependencies] +serde = "1.0.219" +serde_json = "1.0.140" +tucana = { version = "0.0.28" } +quote = "1.0" +proc-macro2 = "1.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..72c03ba --- /dev/null +++ b/build.rs @@ -0,0 +1,242 @@ +use proc_macro2::TokenStream; +use quote::{quote, ToTokens}; +use std::fs::{read_to_string, File}; +use std::io::Write; +use std::process::Command; +use tucana::shared::value::Kind; + +use tucana::shared::{RuntimeFunctionDefinition, RuntimeParameterDefinition, Translation, Value}; + +macro_rules! print_on_build { + ($($tokens: tt)*) => { + println!("cargo::warning={}", format!($($tokens)*)) + } +} + +/// Given an actual `Value`, emit the tokens to *reconstruct* it in code. +pub fn value_to_tokens(value: Value) -> TokenStream { + todo!("correct struct imports & strings"); + match &value.kind { + Some(Kind::BoolValue(b)) => { + quote! { + Value { + kind: Some(Kind::BoolValue(#b)) + } + } + } + Some(Kind::NumberValue(n)) => { + quote! { + Value { + kind: Some(Kind::NumberValue(#n)) + } + } + } + Some(Kind::StringValue(s)) => { + quote! { + Value { kind: Some(Kind::StringValue(#s.to_string())) } + } + } + Some(Kind::StructValue(str)) => { + let list_item_tokens: Vec = str + .fields + .iter() + .map(|(k, v)| { + let v_ts = value_to_tokens(v.clone()); + quote! { + (#k.to_string(), #v_ts) + } + }) + .collect(); + + quote! { + Value { + kind: Some(ValueKind::ListValue(Struct { + fields: { + ::std::collections::HashMap::from_iter(vec![ #(#list_item_tokens),* ]) + } + })) + } + } + } + Some(Kind::ListValue(lv)) => { + // embed each item of the real list + let item_tokens: Vec<_> = lv + .values + .iter() + .map(|f| value_to_tokens(f.clone())) + .collect(); + quote! { + Value { + kind: Some(ValueKind::ListValue(vec![ + #(#item_tokens),* + ])) + } + } + } + Some(Kind::NullValue(_)) | None => { + quote! { + Value { kind: Some(ValueKind::NullValue(NullValue::NullValue as i32)) } + } + } + } +} + +fn translation_to_token(translations: Vec) -> Vec { + let mut result: Vec = Vec::new(); + + for trans in translations { + let code = trans.code; + let content = trans.content; + + let token = quote! { + tucana::shared::Translation { + code: String::from(#code), + content: String::from(#content), + } + }; + + result.push(token); + } + result +} + +fn runtime_function_parameter_to_token( + paramter: Vec, +) -> Vec { + let mut result: Vec = Vec::new(); + + for param in paramter { + let runtime_name = param.runtime_name; + let data_type_identifier = param.data_type_identifier; + let default_value = match param.default_value { + Some(value) => value_to_tokens(value), + None => quote! { None }, + }; + let name = translation_to_token(param.name); + let description = translation_to_token(param.description); + let documentation = translation_to_token(param.documentation); + + let quote = quote! { + /* + tucana::shared::RuntimeParameterDefinition { + runtime_name: String::from(#runtime_name), + data_type_identifier: String::from(#data_type_identifier), + default_value: #default_value, + name: vec![#(#name),*], + description: vec![#(#description),*], + documentation: vec![#(#documentation),*] + } + */ + }; + + result.push(quote); + } + result +} + +fn runtime_function_definition_to_token(definition: RuntimeFunctionDefinition) -> TokenStream { + let runtime_name = definition.runtime_name; + let runtime_parameter_definitions = + runtime_function_parameter_to_token(definition.runtime_parameter_definitions); + + // let return_type_identifier = definition.return_type_identifier.into_token_stream(); + + let error_type_identifiers = definition + .error_type_identifiers + .into_iter() + .map(|f| { + quote! { + #f + } + }) + .into_iter() + .collect::>(); + + let name = translation_to_token(definition.name); + let description = translation_to_token(definition.description); + let documentation = translation_to_token(definition.documentation); + let deprecation_message = translation_to_token(definition.deprecation_message); + + quote! { + tucana::shared::RuntimeFunctionDefinition { + runtime_name: String::from(#runtime_name), + runtime_parameter_definitions: vec![#(#runtime_parameter_definitions),*], + // return_type_identifier: Option::Some(String::from(#return_type_identifier)), + error_type_identifiers: vec![#(#error_type_identifiers),*], + name: vec![#(#name),*], + description: vec![#(#description),*], + documentation: vec![#(#documentation),*], + deprecation_message: vec![#(#deprecation_message),*], + } + } +} +fn main() { + // let mut file = File::create("./out/output.rs").expect("msg"); + + let path = "./definitions/runtime_functions/array/array.md"; + let file_content = read_to_string(path).unwrap(); + let mut lines = file_content.split("\n"); + let mut inside_code_block = false; + let mut code_blocks: Vec = Vec::new(); + let mut current_code_block: String = String::from(""); + + while let Some(line) = lines.next() { + if line.contains("```") { + if inside_code_block { + code_blocks.push(current_code_block.clone()); + } else { + current_code_block = String::from("") + } + + inside_code_block = !inside_code_block; + } + + if inside_code_block { + if line.starts_with("```") { + continue; + } + + current_code_block.push_str(line); + } + } + + for code in code_blocks { + match serde_json::from_str::(&code) { + Ok(def) => { + // let quote = runtime_function_definition_to_token(def); + // write!(file, "{},", quote).expect("Cannot write to file"); + } + Err(err) => { + print_on_build!("Error parsing JSON: {:?}", err); + print_on_build!("JSON: {:?}", code); + } + } + } + + /* + write!( + file, + "pub mod output {{ fn getDefinitions() -> Vec {{ vec![" + ) + .expect("Cannot write to file"); + + for res in results { + match res { + Ok(def) => { + let quote = runtime_function_definition_to_token(def); + write!(file, "{},", quote).expect("Cannot write to file"); + } + Err(err) => { + print_on_build!("Error parsing JSON: {}", err); + } + } + } + + write!(file, "] }} }}").expect("Cannot write to file"); + + Command::new("rustfmt") + .arg("./out/output.rs") + .arg("--edition") + .arg("2024"); + */ +} diff --git a/definitions/data_types/array.md b/definitions/data_types/array.md index a64af33..84f2e14 100644 --- a/definitions/data_types/array.md +++ b/definitions/data_types/array.md @@ -3,7 +3,7 @@ ## ARRAY ```json { - "variant": "ARRAY", + "variant": 5, "identifier": "ARRAY", "name": [ { @@ -14,79 +14,13 @@ "rules": [ { "contains_type": { - "data_type_identifier": "GENERIC" + "data_type_identifier": { + "generic_key": "T" + } } } ], + "generic_keys": ["T"], "parent_type_identifier": null } - -``` -## NUMBER_ARRAY - -```json -{ - "variant": "ARRAY", - "identifier": "NUMBER_ARRAY", - "name": [ - { - "code": "en-US", - "content": "Number Array" - } - ], - "rules": [ - { - "contains_type": { - "data_type_identifier": "NUMBER" - } - } - ], - "parent_type_identifier": "ARRAY" -} -``` - -## TEXT_ARRAY - -```json -{ - "variant": "ARRAY", - "identifier": "TEXT_ARRAY", - "name": [ - { - "code": "en-US", - "content": "Text Array" - } - ], - "rules": [ - { - "contains_type": { - "data_type_identifier": "TEXT" - } - } - ], - "parent_type_identifier": "ARRAY" -} -``` - -## BOOLEAN_ARRAY - -```json -{ - "variant": "ARRAY", - "identifier": "BOOLEAN_ARRAY", - "name": [ - { - "code": "en-US", - "content": "Boolean Array" - } - ], - "rules": [ - { - "contains_type": { - "data_type_identifier": "BOOLEAN" - } - } - ], - "parent_type_identifier": "ARRAY" -} ``` diff --git a/definitions/data_types/node.md b/definitions/data_types/node.md index 3da1d87..5e5d03c 100644 --- a/definitions/data_types/node.md +++ b/definitions/data_types/node.md @@ -1,51 +1,133 @@ -## Input Node - +## PREDICATE ```json { - "variant": "NODE", - "identifier": "FILTER_GENERIC_INPUT_NODE", - "name": [ - { - "code": "en-US", - "content": "Input" - } - ], + "identifier": "PREDICATE", + "variant": 7, "rules": [ { - "input_type": { - "identifier": "GENERIC" + "return_type": { + "data_type_identifier": "BOOLEAN" } }, { - "return_type": { - "identifier": "BOOLEAN" - } + "input_type": [ + { + "data_type_identifier": { + "generic_key": "T" + }, + "input_identifier": "predicate" + } + ] + } + ], + "generic_keys": ["T"], + "name": [ + { + "code": "en-US", + "content": "Predicate" } ] } ``` -## Input Node +## CONSUMER ```json { - "variant": "NODE", - "identifier": "MAP_GENERIC_INPUT_NODE", + "identifier": "CONSUMER", + "variant": 7, + "rules": [ + { + "input_type": [ + { + "data_type_identifier": { + "generic_key": "T" + }, + "input_identifier": "consumer" + } + ] + } + ], + "generic_keys": ["T"], "name": [ { "code": "en-US", - "content": "Input" + "content": "Consumer" } - ], + ] + +} +``` + +## TRANSFORM +```json +{ + "identifier": "TRANSFORM", + "variant": 7, "rules": [ { - "input_type": { - "identifier": "A_GENERIC" + "return_type": { + "data_type_identifier": { + "generic_key": "R" + } } }, + { + "input_type": [ + { + "data_type_identifier": { + "generic_key": "I" + }, + "input_identifier": "transform" + } + ] + } + ], + "generic_keys": ["I", "R"], + "name": [ + { + "code": "en-US", + "content": "Transform" + } + ] + +} +``` + +## COMPARITOR +```json +{ + "identifier": "COMPARITOR", + "variant": 7, + "rules": [ { "return_type": { - "identifier": "B_GENERIC" + "data_type_identifier": { + "data_type_identifier": "NUMBER" + } } + }, + { + "input_type": [ + { + "data_type_identifier": { + "generic_key": "I" + }, + "input_identifier": "left" + }, + { + "data_type_identifier": { + "generic_key": "I" + }, + "input_identifier": "right" + } + ] + } + ], + "generic_keys": ["I"], + "name": [ + { + "code": "en-US", + "content": "Comparitor" } ] } diff --git a/definitions/data_types/primitive.md b/definitions/data_types/primitive.md index 1e7420f..5366129 100644 --- a/definitions/data_types/primitive.md +++ b/definitions/data_types/primitive.md @@ -4,7 +4,7 @@ ```json { - "variant": "PRIMITIVE", + "variant": 1, "identifier": "NUMBER", "name": [ { @@ -18,7 +18,8 @@ "pattern": "/^(?:-(?:[1-9](?:\d{0,2}(?:,\d{3})+|\d*))|(?:0|(?:[1-9](?:\d{0,2}(?:,\d{3})+|\d*))))(?:.\d+|)$/" } } - ] + ], + "generic_keys": [] } ``` @@ -27,7 +28,7 @@ ```json { - "variant": "PRIMITIVE", + "variant": 1, "identifier": "TEXT", "name": [ { @@ -41,7 +42,8 @@ "pattern": "[\s\S]*" } } - ] + ], + "generic_keys": [] } ``` @@ -49,7 +51,7 @@ ```json { - "variant": "PRIMITIVE", + "variant": 1, "identifier": "BOOLEAN", "name": [ { @@ -63,6 +65,7 @@ "pattern": "^(true|false)$" } } - ] + ], + "generic_keys": [] } ``` diff --git a/definitions/data_types/type.md b/definitions/data_types/type.md index 73dc2b3..feda618 100644 --- a/definitions/data_types/type.md +++ b/definitions/data_types/type.md @@ -4,7 +4,7 @@ ```json { - "variant": "Type", + "variant": 2, "identifier": "TEXT_ENCODING", "name": [ { @@ -23,6 +23,7 @@ ] } } - ] + ], + "generic_keys": [] } ``` diff --git a/definitions/functions/array/array.md b/definitions/functions/array/array.md deleted file mode 100644 index 355b1be..0000000 --- a/definitions/functions/array/array.md +++ /dev/null @@ -1,161 +0,0 @@ -## at -Will return the value at the index of the array. - -```json -{ - "runtime_name": "std::array::at", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "index" - } - ], - "return_type_identifier": "GENERIC" -} -``` - -## concat -Will merge to arrays together and return a new one - -```json -{ - "runtime_name": "std::array::concat", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "ARRAY", - "runtime_name": "first" - }, - { - "data_type_identifier": "ARRAY", - "runtime_name": "second" - } - ], - "return_type_identifier": "ARRAY" -} -``` - -## filter -Will filter the function by the given function - -```json -{ - "runtime_name": "std::array::filter", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "ARRAY", - "runtime_name": "array" - }, - { - "data_type_identifier": "FILTER_INPUT_GENERIC_NODE", - "runtime_name": "fitler" - } - ], - "return_type_identifier": "ARRAY" -} -``` - -## find -idk how to do functions - -some node with a boolean as return type??? - -## findIndex -idk how to do functions - -some node with a boolean as return type??? - -## first -idk how to do functions - -some node with a boolean as return type??? - -## last -idk how to do functions - -some node with a boolean as return type??? - -## forEach -idk how to do functions - -some node with a boolean as return type??? - -## map -idk how to do functions - -some node with a boolean as return type??? - -## push -Will add the given entry to the array and returns the new length of the array - -```json -{ - "runtime_name": "std::array::filter", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "ARRAY", - "runtime_name": "array" - }, - { - "data_type_identifier": "", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -[Ref](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) - -## pop -Will remove the last entry of the array and return it - -```json -{ - "runtime_name": "std::array::pop", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "ARRAY", - "runtime_name": "array" - } - ], - "return_type_identifier": "GENERIC" -} -``` - -[Ref](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) - -## remove - -## isEmpty - -## size - -## indexOf - -## toUnique - -## sort - -## sortASC - -## sortDESC - -## reverse - -## flat - -## clear - -## replace - -move to number_arry - - -min - -max - -sum - -## join -will join every entry by a given text diff --git a/definitions/functions/primitive/boolean.md b/definitions/functions/primitive/boolean.md deleted file mode 100644 index 5cbb25f..0000000 --- a/definitions/functions/primitive/boolean.md +++ /dev/null @@ -1,118 +0,0 @@ -# std for PRIMITIVE: BOOLEAN - -## asNumber -Will convert the boolean to a number. - -```json -{ - "runtime_name": "std::boolean::as_number", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "BOOLEAN", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -false --> 0 - -true --> 1 - -## asText -Will convert the boolean to a string. - -```json -{ - "runtime_name": "std::boolean::as_text", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "BOOLEAN", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -false --> "false" - -true --> "true" - - -## fromNumber -Will convert the number to a boolean. - -```json -{ - "runtime_name": "std::boolean::from_number", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -0 --> false - -1 --> true - - -## fromText -Will convert the string to a boolean. - -```json -{ - "runtime_name": "std::boolean::from_text", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -"false" --> false - -"true" --> true - - -## isEqual -Will compare one boolean to another. - -```json -{ - "runtime_name": "std::boolean::isEqual", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "BOOLEAN", - "runtime_name": "first" - }, - { - "data_type_identifier": "BOOLEAN", - "runtime_name": "second" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -false, false --> true - -true, false --> false diff --git a/definitions/functions/primitive/number.md b/definitions/functions/primitive/number.md deleted file mode 100644 index 6e89afb..0000000 --- a/definitions/functions/primitive/number.md +++ /dev/null @@ -1,859 +0,0 @@ -# std for PRIMITIVE: NUMBER - -## add -Adds two numbers together. - -```json -{ - "runtime_name": "std::number::add", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -3 + 2 --> 5 - -## multiply -Multiplies two numbers together. - -```json -{ - "runtime_name": "std::number::multiply", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -3 * 2 --> 6 - -## subtract -Subtracts the second number from the first. - -```json -{ - "runtime_name": "std::number::subtract", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -5 - 2 --> 3 - -## divide -Divides the first number by the second. - -```json -{ - "runtime_name": "std::number::divide", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -6 / 2 --> 3 - -## modulo -Returns the remainder after division of the first number by the second. - -```json -{ - "runtime_name": "std::number::modulo", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -7 % 3 --> 1 - -## abs -Converts a number to its absolute value. - -```json -{ - "runtime_name": "std::number::abs", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - --5 --> 5 - -## isPositive -Checks if a number is positive. - -```json -{ - "runtime_name": "std::number::is_positive", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -5 --> true --2 --> false - -## isGreater -Checks if the first number is greater than the second. - -```json -{ - "runtime_name": "std::number::is_greater", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -5 > 3 --> true -2 > 4 --> false - -## isLess -Checks if the first number is less than the second. - -```json -{ - "runtime_name": "std::number::is_less", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -3 < 5 --> true -4 < 2 --> false - -## isZero -Checks if a number is zero. - -```json -{ - "runtime_name": "std::number::is_zero", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -0 --> true -5 --> false - -## square -Multiplies a number by itself. - -```json -{ - "runtime_name": "std::number::square", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -4 --> 16 - -## exponential -Raises a number to the specified power. - -```json -{ - "runtime_name": "std::number::exponential", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "base" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "exponent" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -2^3 --> 8 - -## PI -Returns the mathematical constant Pi. - -```json -{ - "runtime_name": "std::number::pi", - "runtime_parameter_definitions": [], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -PI --> 3.14159265359... - -## EULER -Returns the mathematical constant e (Euler's number). - -```json -{ - "runtime_name": "std::number::euler", - "runtime_parameter_definitions": [], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -EULER --> 2.71828182846... - -## INFINITY -Returns the representation of infinity. - -```json -{ - "runtime_name": "std::number::infinity", - "runtime_parameter_definitions": [], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -INFINITY --> ∞ - -## roundUp -Rounds a number up to the nearest integer. - -```json -{ - "runtime_name": "std::number::round_up", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "decimals" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -3.2 (0) --> 4 -3.8 (0) --> 4 -3.008 (3) --> 3.009 -3.008 (1) --> 3.1 - -## roundDown -Rounds a number down to the nearest integer. - -```json -{ - "runtime_name": "std::number::round_down", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "decimals" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -3.2 (0) --> 3 -3.8 (0) --> 3 - -3.002 (1) --> 3 -3.778 (2) --> 3.7 - -## round -Rounds a number to the nearest integer. - -```json -{ - "runtime_name": "std::number::round", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "decimals" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -3.2 (0) --> 3 -3.8 (0) --> 4 - -3.002 (1) --> 3 -3.778 (2) --> 3.78 - -## squareRoot -Calculates the square root of a number. - -```json -{ - "runtime_name": "std::number::square_root", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -16 --> 4 - -## root -Calculates the nth root of a number. - -```json -{ - "runtime_name": "std::number::root", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "root_exponent" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -27, 3 --> 3 (cube root of 27) - -## log -Calculates the logarithm of a number with the specified base. - -```json -{ - "runtime_name": "std::number::log", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "base" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -100, 10 --> 2 (log base 10 of 100) - -## ln -Calculates the natural logarithm (base e) of a number. - -```json -{ - "runtime_name": "std::number::ln", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -2.71828... --> 1 (ln of e) - -## fromText -Converts a string to a number. - -```json -{ - "runtime_name": "std::number::from_text", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "text" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -"123" --> 123 -"3.14" --> 3.14 - -## asText -Converts a number to a text. - -```json -{ - "runtime_name": "std::number::as_text", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "number" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -123 --> "123" -3.14 --> "3.14" - - -## min -Returns the smaller of two numbers. - -```json -{ - "runtime_name": "std::number::min", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -5, 3 --> 3 --1, 2 --> -1 - -## max -Returns the larger of two numbers. - -```json -{ - "runtime_name": "std::number::max", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -5, 3 --> 5 --1, 2 --> 2 - -## negate -Returns the additive inverse of a number. - -```json -{ - "runtime_name": "std::number::negate", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -5 --> -5 --3 --> 3 - -## randomNumber -Generates a random number between the specified minimum and maximum values. - -```json -{ - "runtime_name": "std::number::random_number", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "min" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "max" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -1, 6 --> 3 (random number between 1 and 6, inclusive) - -## sin -Calculates the sine of an angle (in radians). - -```json -{ - "runtime_name": "std::number::sin", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "radians" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 0 -1.5708 (π/2) --> 1 - -## cos -Calculates the cosine of an angle (in radians). - -```json -{ - "runtime_name": "std::number::cos", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "radians" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 1 -3.14159 (π) --> -1 - -## tan -Calculates the tangent of an angle (in radians). - -```json -{ - "runtime_name": "std::number::tan", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "radians" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 0 -0.7854 (π/4) --> 1 - -## arcsin -Calculates the inverse sine (in radians). - -```json -{ - "runtime_name": "std::number::arcsin", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 0 -1 --> 1.5708 (π/2) - -## arccos -Calculates the inverse cosine (in radians). - -```json -{ - "runtime_name": "std::number::arccos", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -1 --> 0 --1 --> 3.14159 (π) - -## arctan -Calculates the inverse tangent (in radians). - -```json -{ - "runtime_name": "std::number::arctan", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 0 -1 --> 0.7854 (π/4) - -## sinh -Calculates the hyperbolic sine of a number. - -```json -{ - "runtime_name": "std::number::sinh", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 0 -1 --> 1.1752 - -## cosh -Calculates the hyperbolic cosine of a number. - -```json -{ - "runtime_name": "std::number::cosh", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -0 --> 1 -1 --> 1.5431 - -## clamp -Constrains a number to be within a specified range. - -```json -{ - "runtime_name": "std::number::clamp", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "min" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "max" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -10, 0, 5 --> 5 (clamped to max) --3, 0, 5 --> 0 (clamped to min) -3, 0, 5 --> 3 (within range, unchanged) - -## isEqual -Will compare one boolean to another. - -```json -{ - "runtime_name": "std::number::isEqual", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER", - "runtime_name": "first" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "second" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -1, 1 --> true - -1, 2 --> false - -# Additions: -- isGreaterOrEqual -- isLessOrEqual diff --git a/definitions/functions/primitive/text.md b/definitions/functions/primitive/text.md deleted file mode 100644 index 345e03e..0000000 --- a/definitions/functions/primitive/text.md +++ /dev/null @@ -1,710 +0,0 @@ -# std for PRIMITIVE: TEXT - -## asBytes -Converts the text to a number array. - -```json -{ - "runtime_name": "std::text::as_bytes", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER_ARRAY" -} -``` - -**Example**: - -"hello" --> [104, 101, 108, 108, 111] - -## byteSize -Returns the size of the text in bytes. - -```json -{ - "runtime_name": "std::text::byte_size", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -"hello" --> 5 - -## capitalize -Capitalizes the first character of the text. - -```json -{ - "runtime_name": "std::text::capitalize", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello" --> "Hello" - -"world wide web" --> "World wide web" - -## uppercase -Converts all characters in the text to uppercase. - -```json -{ - "runtime_name": "std::text::uppercase", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello" --> "HELLO" - -"Hello World" --> "HELLO WORLD" - -## lowercase -Converts all characters in the text to lowercase. - -```json -{ - "runtime_name": "std::text::lowercase", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"HELLO" --> "hello" - -"Hello World" --> "hello world" - -## swapcase -Swaps the case of all characters in the text. - -```json -{ - "runtime_name": "std::text::swapcase", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"Hello" --> "hELLO" - -"Hello World" --> "hELLO wORLD" - -## chars -Splits the text into an array of characters. - -```json -{ - "runtime_name": "std::text::chars", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT_ARRAY" -} -``` - -**Example**: - -"hello" --> ["h", "e", "l", "l", "o"] - -## at -Returns the character at the specified index. - -```json -{ - "runtime_name": "std::text::at", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "index" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello", 1 --> "e" - -"world", 0 --> "w" - -## trim -Removes whitespace from both ends of the text. - -```json -{ - "runtime_name": "std::text::trim", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -" hello " --> "hello" - -" hello world " --> "hello world" - -## apped -Concatenates two strings together. - -```json -{ - "runtime_name": "std::text::append", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "suffix" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello", " world" --> "hello world" - -"abc", "123" --> "abc123" - -## prepend -Adds text to the beginning of the string. - -```json -{ - "runtime_name": "std::text::prepend", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "prefix" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"world", "hello " --> "hello world" - -"123", "abc" --> "abc123" - -## insert -Inserts text at the specified position. - -```json -{ - "runtime_name": "std::text::insert", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "position" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "text" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"helloworld", 5, " " --> "hello world" - -"abcdef", 3, "123" --> "abc123def" - -## length -Returns the length of the text. - -```json -{ - "runtime_name": "std::text::length", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -"hello" --> 5 - -"hello world" --> 11 - -## remove -Removes a portion of text from the specified start index to end index. - -```json -{ - "runtime_name": "std::text::remove", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "start" - }, - { - "data_type_identifier": "NUMBER", - "runtime_name": "end" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello world", 5, 6 --> "helloworld" - -"abcdefg", 2, 5 --> "abfg" - -## replace -Replaces all occurrences of a substring with another string. - -```json -{ - "runtime_name": "std::text::replace", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "old" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "new" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello world", "world", "universe" --> "hello universe" - -"ababab", "a", "c" --> "cbcbcb" - -## replaceFirst -Replaces the first occurrence of a substring with another string. - -```json -{ - "runtime_name": "std::text::replace_first", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "old" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "new" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello hello", "hello", "hi" --> "hi hello" - -"ababab", "a", "c" --> "cbabab" - -## replaceLast -Replaces the last occurrence of a substring with another string. - -```json -{ - "runtime_name": "std::text::replace_last", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "old" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "new" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello hello", "hello", "hi" --> "hello hi" - -"ababab", "a", "c" --> "ababcb" - -## hex -Converts the text to a hexadecimal representation. - -```json -{ - "runtime_name": "std::text::hex", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello" --> "68656c6c6f" - -"ABC" --> "414243" - -## octal -Converts the text to an octal representation. - -```json -{ - "runtime_name": "std::text::octal", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello" --> "150145154154157" - -"ABC" --> "101102103" - -## indexOf -Returns the index of the first occurrence of a substring, or -1 if not found. - -```json -{ - "runtime_name": "std::text::index_of", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "substring" - } - ], - "return_type_identifier": "NUMBER" -} -``` - -**Example**: - -"hello world", "world" --> 6 - -"hello world", "not found" --> -1 - -## contains -Checks if the text contains a specified substring. - -```json -{ - "runtime_name": "std::text::contains", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "substring" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -"hello world", "world" --> true - -"hello world", "not found" --> false - -## split -Splits the text into an array of strings based on a delimiter. - -```json -{ - "runtime_name": "std::text::split", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "delimiter" - } - ], - "return_type_identifier": "TEXT_ARRAY" -} -``` - -**Example**: - -"hello world", " " --> ["hello", "world"] - -"a,b,c", "," --> ["a", "b", "c"] - -## reverse -Reverses the text. - -```json -{ - "runtime_name": "std::text::reverse", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello" --> "olleh" - -"world" --> "dlrow" - -## startWith -Checks if the text starts with a specified prefix. - -```json -{ - "runtime_name": "std::text::start_with", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "prefix" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -"hello world", "hello" --> true - -"hello world", "world" --> false - -## endsWith -Checks if the text ends with a specified suffix. - -```json -{ - "runtime_name": "std::text::ends_with", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "suffix" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -"hello world", "world" --> true - -"hello world", "hello" --> false - -## toASCII -Converts each character to its ASCII code as an array of numbers. - -```json -{ - "runtime_name": "std::text::to_ascii", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - } - ], - "return_type_identifier": "NUMBER_ARRAY" -} -``` - -**Example**: - -"hello" --> [104, 101, 108, 108, 111] - -"ABC" --> [65, 66, 67] - -## fromASCII -Converts an array of ASCII codes to a text string. - -```json -{ - "runtime_name": "std::text::from_ascii", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "NUMBER_ARRAY", - "runtime_name": "value" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -[104, 101, 108, 108, 111] --> "hello" - -[65, 66, 67] --> "ABC" - -## encode -Encodes the text using a specified encoding. - -```json -{ - "runtime_name": "std::text::encode", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "value" - }, - { - "data_type_identifier": "TEXT_ENCODING", - "runtime_name": "encoding" - } - ], - "return_type_identifier": "TEXT" -} -``` - -**Example**: - -"hello", "base64" --> "aGVsbG8=" - -## isEqual - -```json -{ - "runtime_name": "std::text::isEqual", - "runtime_parameter_definitions": [ - { - "data_type_identifier": "TEXT", - "runtime_name": "first" - }, - { - "data_type_identifier": "TEXT", - "runtime_name": "second" - } - ], - "return_type_identifier": "BOOLEAN" -} -``` - -**Example**: - -"TEXT", "TEXT" --> true - -"TEXT", "WORD" --> false diff --git a/definitions/runtime_functions/array/array-audit.md b/definitions/runtime_functions/array/array-audit.md new file mode 100644 index 0000000..201f448 --- /dev/null +++ b/definitions/runtime_functions/array/array-audit.md @@ -0,0 +1,12 @@ +# 23.05.2025 + +## Added +- find last + +## Removed +- sortASC +- clear (Doesnt make sense because taurus works with immutable variables) +- replace (Doesnt make sense because taurus works with immutable variables) + +## Renamed: +- sortDEC --> sortReverse diff --git a/definitions/runtime_functions/array/array.md b/definitions/runtime_functions/array/array.md new file mode 100644 index 0000000..ab6fc37 --- /dev/null +++ b/definitions/runtime_functions/array/array.md @@ -0,0 +1,2142 @@ +## at +Will return the value at the index of the array. + +```json +{ + "runtime_name": "std::array::at", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array from which to retrieve an element." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array containing elements of any type. The element at the specified index will be returned." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "index", + "name": [ + { + "code": "en-US", + "content": "Index" + } + ], + "description": [ + { + "code": "en-US", + "content": "The zero-based index of the element to retrieve." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the position of the element in the array to return. Must be within the bounds of the array." + } + ] + } + ], + "return_type_identifier": { + "generic_key": "R" + }, + "name": [ + { + "code": "en-US", + "content": "Get Array Element" + } + ], + "description": [ + { + "code": "en-US", + "content": "Retrieves the element at a specified index from an array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the element located at the given zero-based index within the input array." + } + ], + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## concat +Will merge to arrays together and return a new one. +```json +{ + "runtime_name": "std::array::concat", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first array to concatenate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The first input array whose elements will appear at the beginning of the resulting array." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second array to concatenate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The second input array whose elements will be appended after the elements of the first array." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "name": [ + { + "code": "en-US", + "content": "Concatenate Arrays" + } + ], + "description": [ + { + "code": "en-US", + "content": "Concatenates two arrays into a single array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array containing all elements of the first array followed by all elements of the second array." + } + ], + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "first", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "second", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## filter +Will filter the array by the given node and return all values, the filter node returned true. + +```json +{ + "runtime_name": "std::array::filter", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to be filtered." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The original array from which elements will be selected based on the predicate." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "PREDICATE" + }, + "runtime_name": "predicate", + "name": [ + { + "code": "en-US", + "content": "Filter Predicate" + } + ], + "description": [ + { + "code": "en-US", + "content": "A predicate function to test each element for inclusion in the result." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "A function that takes an element of the array and returns a boolean indicating whether the element should be included in the output array." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "name": [ + { + "code": "en-US", + "content": "Filter Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Filters elements of an array based on a predicate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array containing only the elements from the input array for which the predicate returns true." + } + ], + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "predicate", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## find +Will return the first item of an array that match the predicate. + +```json +{ + "runtime_name": "std::array::find", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to search through." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The array in which an element satisfying the predicate will be searched." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "PREDICATE" + }, + "runtime_name": "predicate", + "name": [ + { + "code": "en-US", + "content": "Search Predicate" + } + ], + "description": [ + { + "code": "en-US", + "content": "A predicate function used to test each element for a match." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "A function that takes an element of the array and returns a boolean indicating if the element matches the search criteria." + } + ] + } + ], + "generic_keys": ["R"], + "return_type_identifier": { + "generic_key": "R" + }, + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "predicate", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Find Element in Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the first element in the array that satisfies the predicate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the first element from the input array for which the predicate returns true. If no element matches, returns null or equivalent." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## findLast +Will return the last item of an array that match the predicate. + +```json +{ + "runtime_name": "std::array::find_last", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to search through." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The array in which an element satisfying the predicate will be searched." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "PREDICATE" + }, + "runtime_name": "predicate", + "name": [ + { + "code": "en-US", + "content": "Search Predicate" + } + ], + "description": [ + { + "code": "en-US", + "content": "A predicate function used to test each element for a match." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "A function that takes an element of the array and returns a boolean indicating if the element matches the search criteria." + } + ] + } + ], + "generic_keys": ["R"], + "return_type_identifier": { + "generic_key": "R" + }, + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "predicate", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Find Last Element in Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the last element in the array that satisfies the predicate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the last element from the input array for which the predicate returns true. If no element matches, returns null or equivalent." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## findIndex +Will return the index of the first item that matches the predicate. + +```json +{ + "runtime_name": "std::array::find_index", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to search through." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The array in which to find the index of an element that satisfies the predicate." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "PREDICATE" + }, + "runtime_name": "predicate", + "name": [ + { + "code": "en-US", + "content": "Search Predicate" + } + ], + "description": [ + { + "code": "en-US", + "content": "A predicate function used to test each element for a match." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "A function that takes an element of the array and returns a boolean indicating if the element satisfies the search criteria." + } + ] + } + ], + "generic_keys": ["R"], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "predicate", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Find Index in Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the index of the first element in the array that satisfies the predicate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the zero-based index of the first element for which the predicate returns true. If no element matches, returns -1." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## first +Will return the first item of the array. + +```json +{ + "runtime_name": "std::array::first", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array from which to retrieve the first element." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the first element of the provided array. If the array is empty, behavior depends on the implementation." + } + ] + } + ], + "return_type_identifier": { + "generic_key": "R" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "First Element of Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Retrieves the first element from the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This runtime returns the first element in the given array, if any." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## last +Will return the last item of the array. + +```json +{ + "runtime_name": "std::array::last", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array from which to retrieve the last element." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the last element of the provided array. If the array is empty, behavior depends on the implementation." + } + ] + } + ], + "return_type_identifier": { + "generic_key": "R" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Last Element of Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Retrieves the last element from the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This runtime returns the last element in the given array, if any." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## forEach +Will call a consumer on every item in the array. No return value. + +```json +{ + "runtime_name": "std::array::for_each", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array of elements to iterate over." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Each element of this array will be passed to the provided consumer function for processing." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "CONSUMER" + }, + "runtime_name": "consumer", + "name": [ + { + "code": "en-US", + "content": "Consumer Function" + } + ], + "description": [ + { + "code": "en-US", + "content": "A function that consumes each element of the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This function is invoked once for each element in the array. It is not expected to return a value." + } + ] + } + ], + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "consumer", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "For Each Element" + } + ], + "description": [ + { + "code": "en-US", + "content": "Executes a consumer function for each element in the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This runtime executes the given consumer function on each item in the array without returning a result." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## map +Will call a node on each value and expect a return value of the node, collect all return values and returns a new array of all collected return values. + +```json +{ + "runtime_name": "std::array::map", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Input Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to be transformed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Each element of this array will be passed through the transform function." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TRANSFORM" + }, + "runtime_name": "transform", + "name": [ + { + "code": "en-US", + "content": "Transform Function" + } + ], + "description": [ + { + "code": "en-US", + "content": "A function that transforms each item in the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The transform function is applied to every element of the array to produce a new array." + } + ] + } + ], + "generic_keys": ["IN", "OUT"], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "IN" + }, + "target": "T" + }, + { + "parameter_id": "transform", + "source": { + "generic_key": "IN" + }, + "target": "I" + }, + { + "parameter_id": "transform", + "source": { + "generic_key": "OUT" + }, + "target": "R" + }, + { + "source": { + "generic_key": "OUT" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Map Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Transforms each element in the array using the provided function." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This runtime applies the transform function to each element in the array, producing a new array of the results." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## push +Will add the given item to the array and returns the new length of the array. + +```json +{ + "runtime_name": "std::array::push", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to which an item will be added." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The array that the new item will be appended to." + } + ] + }, + { + "data_type_identifier": { + "generic_key": "I" + }, + "runtime_name": "item", + "name": [ + { + "code": "en-US", + "content": "Item" + } + ], + "description": [ + { + "code": "en-US", + "content": "The item to add to the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The value to be added at the end of the array." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "generic_keys": ["I"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "T" + }, + "target": "I" + } + ], + "name": [ + { + "code": "en-US", + "content": "Push to Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Appends an item to the end of an array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Adds a new element to the end of the array and returns the new length of the array." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +[Ref](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) + +## pop +Will remove the last entry of the array and return the item. + +```json +{ + "runtime_name": "std::array::pop", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to remove the last item from." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the array from which the last element will be removed and returned." + } + ] + } + ], + "return_type_identifier": { + "generic_key": "R" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Pop from Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Removes and returns the last item from the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Removes the last element from the specified array and returns it. The array is modified in place." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +[Ref](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) + +## remove +Will remove the given item of the array and return the array without it. + +```json +{ + "runtime_name": "std::array::remove", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array from which the item will be removed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array to process by removing the first occurrence of the specified item." + } + ] + }, + { + "data_type_identifier": { + "generic_key": "R" + }, + "runtime_name": "item", + "name": [ + { + "code": "en-US", + "content": "Item" + } + ], + "description": [ + { + "code": "en-US", + "content": "The item to remove from the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The value to search for and remove from the array. Only the first matching item is removed." + } + ] + } + ], + "generic_keys": ["R"], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Remove from Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Removes the first occurrence of the specified item from the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Removes the first matching item from the given array and returns the resulting array." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## isEmpty +Will check if the array is empty or not. Will return true if its empty. + +```json +{ + "runtime_name": "std::array::is_empty", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to check for emptiness." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The array whose length will be evaluated to determine if it contains any elements." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Is Array Empty" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks if the array has no elements." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the array contains no elements, otherwise returns false." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## size +Will return the amount of items inside the array. + +```json +{ + "runtime_name": "std::array::size", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array whose number of elements is to be returned." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the array for which the total number of elements will be calculated and returned." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Array Size" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the number of elements in the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This function returns the count of elements present in the given array." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## indexOf +Will return the index of the given item. + +```json +{ + "runtime_name": "std::array::index_of", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The array to search within." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array of elements in which the specified item will be searched for to determine its index." + } + ] + }, + { + "data_type_identifier": { + "generic_key": "R" + }, + "runtime_name": "item", + "name": [ + { + "code": "en-US", + "content": "Item" + } + ], + "description": [ + { + "code": "en-US", + "content": "The item whose index is to be found in the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The item for which the function searches in the array and returns the index of its first occurrence." + } + ] + } + ], + "generic_keys": ["R"], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "generic_mapper": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Index of Item" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the index of the first occurrence of the specified item in the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the zero-based index of the first occurrence of a given item in the specified array. If the item is not found, it typically returns -1." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_mappers": [] +} +``` + +## toUnique +Will remove all duplicated items of the array. + +```json +{ + "runtime_name": "std::array::to_unique", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input array from which duplicates will be removed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array of elements that may contain duplicates. This function will remove any duplicate items and return a new array with unique values only." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "To Unique" + } + ], + "description": [ + { + "code": "en-US", + "content": "Removes duplicate elements from the input array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array containing only the unique elements from the input array. The original order may or may not be preserved depending on the implementation." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## sort +Will sort the array by the given COMPARATOR. + +```json +{ + "runtime_name": "std::array::sort", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input array to be sorted." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array of elements that will be sorted using the provided comparator function." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "COMPARATOR" + }, + "runtime_name": "comparator", + "name": [ + { + "code": "en-US", + "content": "Comparator" + } + ], + "description": [ + { + "code": "en-US", + "content": "A comparator function used to determine the sort order of elements." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "A function that takes two elements and returns a negative, zero, or positive number to indicate their ordering." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "comparator", + "source": { + "generic_key": "R" + }, + "target": "I" + } + ], + "name": [ + { + "code": "en-US", + "content": "Sort Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Sorts the elements of the array using the specified comparator." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array with the elements sorted according to the comparator function provided." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## sortReverse + +```json +{ + "runtime_name": "std::array::sort_reverse", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input array to be sorted in reverse order." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array of elements that will be sorted in descending order using the provided comparator." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "COMPARATOR" + }, + "runtime_name": "comparator", + "name": [ + { + "code": "en-US", + "content": "Comparator" + } + ], + "description": [ + { + "code": "en-US", + "content": "A comparator function used to determine the sort order of elements." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "A function that takes two elements and returns a negative, zero, or positive number to indicate their ordering." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + }, + { + "parameter_id": "comparator", + "source": { + "generic_key": "R" + }, + "target": "I" + } + ], + "name": [ + { + "code": "en-US", + "content": "Sort Array in Reverse" + } + ], + "description": [ + { + "code": "en-US", + "content": "Sorts the elements of the array in reverse order using the specified comparator." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array with the elements sorted in descending order according to the comparator function provided." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## reverse + +```json +{ + "runtime_name": "std::array::reverse", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input array to be reversed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array of elements whose order will be reversed." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "generic_key": "R" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Reverse Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Reverses the order of elements in the array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array with the elements of the input array in reverse order." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## flat +Will turn a 2 dimensional array into a one dimensional array. + +Input: +[ [1, 2, 3], [3, 4, 5] ] + +Result: +[ 1, 2, 3, 3, 4, 5 ] + +```json +{ + "runtime_name": "std::array::flat", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Nested Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "The nested array to be flattened." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "An array containing sub-arrays that will be flattened into a single-level array." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "parameter_id": "filter", + "target": "R", + "soruce": "T" + }, + { + "parameter_id": "array", + "source": { + "data_type_identifier": "ARRAY" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Flatten Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Flattens a nested array into a single-level array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new array by concatenating all sub-arrays of the input nested array into one flat array." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## min +Returns the smallest number in the array + +```json +{ + "runtime_name": "std::array::min", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Number Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "An array of numbers to find the minimum value from." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the smallest number in the given array of numbers." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Find Minimum Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the minimum value in a numeric array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the smallest number contained in the provided array." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "data_type_identifier": "NUMBER" + }, + "target": "T" + } + ] +} +``` + +## max +Returns the largest number in the array + +```json +{ + "runtime_name": "std::array::max", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Number Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "An array of numbers to find the maximum value from." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the largest number in the given array of numbers." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Find Maximum Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the maximum value in a numeric array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the largest number contained in the provided array." + } + ], + "deprecation_message": [], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "data_type_identifier": "NUMBER" + }, + "target": "T" + } + ], + "generic_keys": [], + "error_type_identifiers": [] +} +``` + + +## sum +Returns the sum of all the numbers in the array + +```json +{ + "runtime_name": "std::array::sum", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Number Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "An array of numbers to be summed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the sum of all numbers in the given array." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Sum of Numbers" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the total sum of the elements in the numeric array." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Adds up all numbers in the input array and returns their sum." + } + ], + "deprecation_message": [], + "generic_keys": [], + "error_type_identifiers": [], + "generic_mappers": [ + { + "parameter_id": "array", + "source": { + "data_type_identifier": "NUMBER" + }, + "target": "T" + } + ] +} +``` + +## join +Will join every item by a given text + +```json +{ + "runtime_name": "std::array::join", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_mappers": [ + { + "source": { + "data_type_identifier": "TEXT" + }, + "target": "T" + } + ] + }, + "runtime_name": "array", + "name": [ + { + "code": "en-US", + "content": "Text Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "An array of text elements to be filtered." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Input array containing text elements for filtering." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "join_text", + "name": [ + { + "code": "en-US", + "content": "Join Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Text to join the filtered elements." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The delimiter or text that will be used to join the filtered array elements into a single string." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Filter and Join Text Array" + } + ], + "description": [ + { + "code": "en-US", + "content": "Filters the input text array and joins the filtered elements into a single string separated by the specified join text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Applies a filter operation on the input text array and returns a single concatenated string of filtered elements joined by the provided join text." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [], + "error_type_identifiers": [] +} +``` diff --git a/definitions/runtime_functions/object/object-audit.md b/definitions/runtime_functions/object/object-audit.md new file mode 100644 index 0000000..29ea06e --- /dev/null +++ b/definitions/runtime_functions/object/object-audit.md @@ -0,0 +1,19 @@ +# 26.05.2024 - First Iteration + +## Removed: + - concat + - entries + - any + - forEach + - containsValue + - values + - flter + +# 27.05.2024 + +## Removed: + - at + - replace + +## Renamed: + - put -> set diff --git a/definitions/runtime_functions/object/object.md b/definitions/runtime_functions/object/object.md new file mode 100644 index 0000000..39b793f --- /dev/null +++ b/definitions/runtime_functions/object/object.md @@ -0,0 +1,401 @@ +## remove +```json +{ + "runtime_name": "std::object::remove", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "runtime_name": "object", + "name": [ + { + "code": "en-US", + "content": "Original Object" + } + ], + "description": [ + { + "code": "en-US", + "content": "The original object from which a key-value pair will be removed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The object to be modified by removing the specified key." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "key", + "name": [ + { + "code": "en-US", + "content": "Key" + } + ], + "description": [ + { + "code": "en-US", + "content": "The key identifying the property to remove from the object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The property key that will be removed from the original object." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "name": [ + { + "code": "en-US", + "content": "Remove Key from Object" + } + ], + "description": [ + { + "code": "en-US", + "content": "Removes a property identified by the specified key from the given object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new object that contains all properties from the original object except the one specified by the key." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [], + "error_type_identifiers": [] +} +``` + +## containsKey +```json +{ + "runtime_name": "std::object::contains_key", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "runtime_name": "object", + "name": [ + { + "code": "en-US", + "content": "Object" + } + ], + "description": [ + { + "code": "en-US", + "content": "The object to check for the presence of a key." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The object within which the existence of the specified key will be checked." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "key", + "name": [ + { + "code": "en-US", + "content": "Key" + } + ], + "description": [ + { + "code": "en-US", + "content": "The key to check for existence in the object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The property key whose presence in the object is being tested." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "Contains Key" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether the specified key exists in the object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the given key is a property of the object; otherwise, returns false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [], + "error_type_identifiers": [] +} +``` + + +## keys +```json +{ + "runtime_name": "std::object::keys", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "runtime_name": "object", + "name": [ + { + "code": "en-US", + "content": "Object" + } + ], + "description": [ + { + "code": "en-US", + "content": "The object whose keys will be retrieved." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns an array of all the keys (property names) of the given object." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["T"], + "generic_mappers": [ + { + "source": { + "data_type_identifier": "TEXT" + }, + "target": "T" + } + ], + "name": [ + { + "code": "en-US", + "content": "Get Object Keys" + } + ], + "description": [ + { + "code": "en-US", + "content": "Retrieves all the keys from the given object as an array of text values." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns an array containing all enumerable property names (keys) of the specified object." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +## size +```json +{ + "runtime_name": "std::object::size", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "runtime_name": "object", + "name": [ + { + "code": "en-US", + "content": "Object" + } + ], + "description": [ + { + "code": "en-US", + "content": "The object whose size (number of keys) will be calculated." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the number of enumerable keys (properties) present in the given object." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Get Object Size" + } + ], + "description": [ + { + "code": "en-US", + "content": "Calculates the number of keys in the provided object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns an integer count of all enumerable property keys in the specified object." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [], + "error_type_identifiers": [] +} +``` + +## set +```json +{ + "runtime_name": "std::object::set", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "runtime_name": "object", + "name": [ + { + "code": "en-US", + "content": "Object" + } + ], + "description": [ + { + "code": "en-US", + "content": "The object in which the key-value pair will be set." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The original object that will be modified with the specified key-value pair." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "key", + "name": [ + { + "code": "en-US", + "content": "Key" + } + ], + "description": [ + { + "code": "en-US", + "content": "The key to set or update in the object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The property name under which the value will be stored in the object." + } + ] + }, + { + "data_type_identifier": { + "generic_key": "I" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The value to set for the specified key." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The value to assign to the object property identified by the key." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "OBJECT" + }, + "name": [ + { + "code": "en-US", + "content": "Set Object Key" + } + ], + "description": [ + { + "code": "en-US", + "content": "Sets or updates a key-value pair in the given object." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new object with the specified key set to the given value." + } + ], + "generic_keys": ["I"], + "generic_mappers": [ + { + "parameter_id": "value", + "source": { + "generic_key": "I" + }, + "target": "I" + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` diff --git a/definitions/functions/primitive/boolean-audit.md b/definitions/runtime_functions/primitive/boolean-audit.md similarity index 100% rename from definitions/functions/primitive/boolean-audit.md rename to definitions/runtime_functions/primitive/boolean-audit.md diff --git a/definitions/runtime_functions/primitive/boolean.md b/definitions/runtime_functions/primitive/boolean.md new file mode 100644 index 0000000..3722197 --- /dev/null +++ b/definitions/runtime_functions/primitive/boolean.md @@ -0,0 +1,358 @@ +# std for PRIMITIVE: BOOLEAN + +## asNumber +Will convert the boolean to a number. + +```json +{ + "runtime_name": "std::boolean::as_number", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The boolean value to convert." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a boolean value to a number." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "As Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Will convert the boolean to a number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a boolean value to a number." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +false --> 0 + +true --> 1 + +## asText +Will convert the boolean to a string. + +```json +{ + "runtime_name": "std::boolean::as_text", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The boolean value to convert." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a boolean value to a text string." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "As Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Will convert the boolean to text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a boolean value to a text string." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +false --> "false" + +true --> "true" + + +## fromNumber +Will convert the number to a boolean. + +```json +{ + "runtime_name": "std::boolean::from_number", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to convert." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a number to a boolean value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "From Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Will convert the number to a boolean." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a number to a boolean value. Typically, 0 maps to false and non-zero maps to true." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> false + +1 --> true + + +## fromText +Will convert the string to a boolean. + +```json +{ + "runtime_name": "std::boolean::from_text", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to convert." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a text string to a boolean value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "From Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Will convert the string to a boolean." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts a text string to a boolean value. Recognizes 'true' and 'false' (case-insensitive)." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"false" --> false + +"true" --> true + + +## isEqual +Will compare one boolean to another. + +```json +{ + "runtime_name": "std::boolean::isEqual", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first boolean value to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The first input to compare." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second boolean value to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The second input to compare." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "Is Equal" + } + ], + "description": [ + { + "code": "en-US", + "content": "Will check if the two booleans are equal." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Compares two boolean values for equality. Returns true if they are the same, false otherwise." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +false, false --> true + +true, false --> false diff --git a/definitions/functions/primitive/number-audit.md b/definitions/runtime_functions/primitive/number-audit.md similarity index 100% rename from definitions/functions/primitive/number-audit.md rename to definitions/runtime_functions/primitive/number-audit.md diff --git a/definitions/runtime_functions/primitive/number.md b/definitions/runtime_functions/primitive/number.md new file mode 100644 index 0000000..c56bf1f --- /dev/null +++ b/definitions/runtime_functions/primitive/number.md @@ -0,0 +1,2875 @@ +# std for PRIMITIVE: NUMBER + +## add +Adds two numbers together. + +```json +{ + "runtime_name": "std::number::add", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first number to add." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Adds two numbers together." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second number to add." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Adds two numbers together." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Adds two numbers together." + } + ], + "description": [ + { + "code": "en-US", + "content": "Adds two numbers together." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Adds two numbers together." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +3 + 2 --> 5 + +## multiply +Multiplies two numbers together. + +```json +{ + "runtime_name": "std::number::multiply", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first number to multiply." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the first operand in the multiplication operation." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second number to multiply." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the second operand in the multiplication operation." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Multiply" + } + ], + "description": [ + { + "code": "en-US", + "content": "Multiplies two numbers together." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Takes two numeric inputs and returns their product." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +3 * 2 --> 6 + +## subtract +Subtracts the second number from the first. + +```json +{ + "runtime_name": "std::number::subtract", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "Minuend" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number from which another number (the subtrahend) is to be subtracted." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number that will have the second value subtracted from it." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Subtrahend" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to subtract from the first number (the minuend)." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the value that will be subtracted from the first number." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Subtract" + } + ], + "description": [ + { + "code": "en-US", + "content": "Subtracts the second number from the first number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the result of subtracting the second numeric input from the first." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +5 - 2 --> 3 + +## divide +Divides the first number by the second. + +```json +{ + "runtime_name": "std::number::divide", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "Dividend" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be divided." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the numerator or the number that will be divided by the second value." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Divisor" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number by which to divide the first number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the denominator or the value that divides the first number." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Divide" + } + ], + "description": [ + { + "code": "en-US", + "content": "Divides the first number by the second number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the result of dividing the first numeric input (dividend) by the second (divisor)." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +6 / 2 --> 3 + +## modulo +Returns the remainder after division of the first number by the second. + +```json +{ + "runtime_name": "std::number::modulo", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "Dividend" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be divided to find the remainder." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number that will be divided by the second value to calculate the remainder." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Divisor" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number by which the first number is divided to get the remainder." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number used to divide the dividend and obtain the remainder." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Modulo" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the remainder after dividing the first number by the second." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the modulus (remainder) of dividing the first numeric input by the second." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +7 % 3 --> 1 + +## abs +Converts a number to its absolute value. + +```json +{ + "runtime_name": "std::number::abs", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number for which to compute the absolute value." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the numeric input. The result will be its absolute (non-negative) value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Absolute Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the absolute value of a number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Removes the sign from the input number, returning its non-negative value." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +-5 --> 5 + +## isPositive +Checks if a number is positive. + +```json +{ + "runtime_name": "std::number::is_positive", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to check for positivity." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the numeric input that will be evaluated to determine whether it is greater than zero." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Is Positive" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether a number is greater than zero." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Evaluates the input number and returns true if it is positive (greater than zero), otherwise false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +5 --> true +-2 --> false + +## isGreater +Checks if the first number is greater than the second. + +```json +{ + "runtime_name": "std::number::is_greater", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to compare against the second number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number that will be evaluated to determine if it is greater than the second number." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to compare with the first number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number that the first number will be compared to." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Is Greater" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether the first number is greater than the second number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the first numeric input is greater than the second; otherwise, returns false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +5 > 3 --> true +2 > 4 --> false + +## isLess +Checks if the first number is less than the second. + +```json +{ + "runtime_name": "std::number::is_less", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to compare with the second number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number that will be evaluated to determine if it is less than the second number." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to compare against the first number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the number that the first number will be compared to." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Is Less" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether the first number is less than the second number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the first numeric input is less than the second; otherwise, returns false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +3 < 5 --> true +4 < 2 --> false + +## isZero +Checks if a number is zero. + +```json +{ + "runtime_name": "std::number::is_zero", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to check if it is zero." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the numeric input evaluated to determine whether it equals zero." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Is Zero" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether the given number is exactly zero." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the input number is zero; otherwise, returns false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> true +5 --> false + +## square +Multiplies a number by itself. + +```json +{ + "runtime_name": "std::number::square", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be squared." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the numeric input that will be multiplied by itself." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Square" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the square of the given number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the value multiplied by itself, effectively raising it to the power of 2." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +4 --> 16 + +## exponential +Raises a number to the specified power. + +```json +{ + "runtime_name": "std::number::exponential", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "base", + "name": [ + { + "code": "en-US", + "content": "Base" + } + ], + "description": [ + { + "code": "en-US", + "content": "The base number to be raised to a power." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the numeric value that will be raised to the power of the exponent." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "exponent", + "name": [ + { + "code": "en-US", + "content": "Exponent" + } + ], + "description": [ + { + "code": "en-US", + "content": "The exponent to raise the base number by." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This numeric value indicates the power to which the base is raised." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Exponential" + } + ], + "description": [ + { + "code": "en-US", + "content": "Raises a base number to the power of an exponent." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the result of raising the base to the power specified by the exponent." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +2^3 --> 8 + +## PI +Returns the mathematical constant Pi. + +```json +{ + "runtime_name": "std::number::pi", + "runtime_parameter_definitions": [], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Pi" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the mathematical constant π (pi)." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Provides the constant value of pi, approximately 3.14159, used in many mathematical calculations." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +PI --> 3.14159265359... + +## EULER +Returns the mathematical constant e (Euler's number). + +```json +{ + "runtime_name": "std::number::euler", + "runtime_parameter_definitions": [], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Euler's Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the mathematical constant e (Euler's number)." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Provides the constant value of Euler's number, approximately 2.71828, which is the base of the natural logarithm." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +EULER --> 2.71828182846... + +## INFINITY +Returns the representation of infinity. + +```json +{ + "runtime_name": "std::number::infinity", + "runtime_parameter_definitions": [], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Infinity" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the mathematical concept of positive infinity." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Provides the representation of positive infinity, used to represent an unbounded value in computations." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +INFINITY --> ∞ + +## roundUp +Rounds a number up to the nearest integer. + +```json +{ + "runtime_name": "std::number::round_up", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be rounded up." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input that will be rounded upwards." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "decimals", + "name": [ + { + "code": "en-US", + "content": "Decimal Places" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number of decimal places to round up to." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies how many decimal digits to keep after rounding up." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Round Up" + } + ], + "description": [ + { + "code": "en-US", + "content": "Rounds a number upward to the specified number of decimal places." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Performs rounding on the given value, always rounding up to the nearest value at the given decimal precision." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +3.2 (0) --> 4 +3.8 (0) --> 4 +3.008 (3) --> 3.009 +3.008 (1) --> 3.1 + +## roundDown +Rounds a number down to the nearest integer. + +```json +{ + "runtime_name": "std::number::round_down", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be rounded down." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input that will be rounded downwards." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "decimals", + "name": [ + { + "code": "en-US", + "content": "Decimal Places" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number of decimal places to round down to." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies how many decimal digits to keep after rounding down." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Round Down" + } + ], + "description": [ + { + "code": "en-US", + "content": "Rounds a number downward to the specified number of decimal places." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Performs rounding on the given value, always rounding down to the nearest value at the given decimal precision." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +3.2 (0) --> 3 +3.8 (0) --> 3 + +3.002 (1) --> 3 +3.778 (2) --> 3.7 + +## round +Rounds a number to the nearest integer. + +```json +{ + "runtime_name": "std::number::round", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be rounded." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input that will be rounded to the nearest value." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "decimals", + "name": [ + { + "code": "en-US", + "content": "Decimal Places" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number of decimal places to round to." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies how many decimal digits to keep after rounding." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Round" + } + ], + "description": [ + { + "code": "en-US", + "content": "Rounds a number to the nearest value at the specified number of decimal places." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Performs standard rounding on the given value, rounding up or down depending on the fractional component." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +3.2 (0) --> 3 +3.8 (0) --> 4 + +3.002 (1) --> 3 +3.778 (2) --> 3.78 + +## squareRoot +Calculates the square root of a number. + +```json +{ + "runtime_name": "std::number::square_root", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to find the square root of." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input for which the square root will be calculated." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Square Root" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the square root of the given number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the positive square root of the input number." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +16 --> 4 + +## root +Calculates the nth root of a number. + +```json +{ + "runtime_name": "std::number::root", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number from which the root will be extracted." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input for which the root will be calculated." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "root_exponent", + "name": [ + { + "code": "en-US", + "content": "Root Exponent" + } + ], + "description": [ + { + "code": "en-US", + "content": "The degree of the root to extract." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies which root to calculate (e.g., 2 for square root, 3 for cube root)." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Root" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the root of a number given a root exponent." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the nth root of the input number, where n is specified by the root exponent." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +27, 3 --> 3 (cube root of 27) + +## log +Calculates the logarithm of a number with the specified base. + +```json +{ + "runtime_name": "std::number::log", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to compute the logarithm for." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input whose logarithm is to be calculated." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "base", + "name": [ + { + "code": "en-US", + "content": "Base" + } + ], + "description": [ + { + "code": "en-US", + "content": "The base of the logarithm." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the logarithmic base to use (e.g., 10 for common log, e for natural log)." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Logarithm" + } + ], + "description": [ + { + "code": "en-US", + "content": "Calculates the logarithm of a number with respect to a specified base." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the logarithm of the given value using the specified base." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +100, 10 --> 2 (log base 10 of 100) + +## ln +Calculates the natural logarithm (base e) of a number. + +```json +{ + "runtime_name": "std::number::ln", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to compute the natural logarithm for." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input whose natural logarithm (log base e) will be calculated." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Natural Logarithm" + } + ], + "description": [ + { + "code": "en-US", + "content": "Calculates the natural logarithm (log base e) of a number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the natural logarithm of the given value." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +2.71828... --> 1 (ln of e) + +## fromText +Converts a string to a number. + +```json +{ + "runtime_name": "std::number::from_text", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "text", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to convert to a number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Parses the input text and attempts to convert it to a numeric value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Number from Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts a text string into a number if possible." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Attempts to parse the provided text input and return its numeric equivalent." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"123" --> 123 +"3.14" --> 3.14 + +## asText +Converts a number to a text. + +```json +{ + "runtime_name": "std::number::as_text", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "number", + "name": [ + { + "code": "en-US", + "content": "Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to convert to text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input that will be converted to its text representation." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Number as Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts a number into its textual representation." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Transforms the given numeric value into a string format." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +123 --> "123" +3.14 --> "3.14" + + +## min +Returns the smaller of two numbers. + +```json +{ + "runtime_name": "std::number::min", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first number to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "One of the two numbers for which the minimum value will be determined." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second number to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The other number involved in the minimum value comparison." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Minimum" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the smaller of two numbers." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Compares two numbers and returns the minimum value." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +5, 3 --> 3 +-1, 2 --> -1 + +## max +Returns the larger of two numbers. + +```json +{ + "runtime_name": "std::number::max", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first number to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "One of the two numbers for which the maximum value will be determined." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second number to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The other number involved in the maximum value comparison." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Maximum" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the larger of two numbers." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Compares two numbers and returns the maximum value." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +5, 3 --> 5 +-1, 2 --> 2 + +## negate +Returns the additive inverse of a number. + +```json +{ + "runtime_name": "std::number::negate", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to negate." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The numeric input whose sign will be inverted." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Negate" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the negation of a number (multiplies by -1)." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the additive inverse of the given number." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +5 --> -5 +-3 --> 3 + +## randomNumber +Generates a random number between the specified minimum and maximum values. + +```json +{ + "runtime_name": "std::number::random_number", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "min", + "name": [ + { + "code": "en-US", + "content": "Minimum" + } + ], + "description": [ + { + "code": "en-US", + "content": "The minimum value in the random number range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Defines the lower bound (inclusive) for the random number generation." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "max", + "name": [ + { + "code": "en-US", + "content": "Maximum" + } + ], + "description": [ + { + "code": "en-US", + "content": "The maximum value in the random number range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Defines the upper bound (inclusive) for the random number generation." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Random Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Generates a random number between the specified minimum and maximum values." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a randomly generated number within the given range, inclusive of both minimum and maximum." + } + ], + "error_type_identifiers": [], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +1, 6 --> 3 (random number between 1 and 6, inclusive) + +## sin +Calculates the sine of an angle (in radians). + +```json +{ + "runtime_name": "std::number::random_number", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "min", + "name": [ + { + "code": "en-US", + "content": "Minimum Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The lower bound of the random number range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Defines the minimum value (inclusive) for the random number generation." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "max", + "name": [ + { + "code": "en-US", + "content": "Maximum Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The upper bound of the random number range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Defines the maximum value (inclusive) for the random number generation." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Random Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "Generates a random number within the specified range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a pseudo-random number between the given minimum and maximum values." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 0 +1.5708 (π/2) --> 1 + +## cos +Calculates the cosine of an angle (in radians). + +```json +{ + "runtime_name": "std::number::cos", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "radians", + "name": [ + { + "code": "en-US", + "content": "Radians" + } + ], + "description": [ + { + "code": "en-US", + "content": "The angle in radians to compute the cosine of." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the cosine of the given angle in radians." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Cosine" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the cosine of the specified angle in radians." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the cosine value of the input angle measured in radians." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 1 +3.14159 (π) --> -1 + +## tan +Calculates the tangent of an angle (in radians). + +```json +{ + "runtime_name": "std::number::tan", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "radians", + "name": [ + { + "code": "en-US", + "content": "Radians" + } + ], + "description": [ + { + "code": "en-US", + "content": "The angle in radians to compute the tangent of." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the tangent of the given angle in radians." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Tangent" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the tangent of the specified angle in radians." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the tangent value of the input angle measured in radians." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 0 +0.7854 (π/4) --> 1 + +## arcsin +Calculates the inverse sine (in radians). + +```json +{ + "runtime_name": "std::number::arcsin", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number representing the sine value, must be between -1 and 1." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the arcsine (inverse sine) of the input value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Arcsine" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the arcsine of a number, in radians." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the angle in radians whose sine is the given number." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 0 +1 --> 1.5708 (π/2) + +## arccos +Calculates the inverse cosine (in radians). + +```json +{ + "runtime_name": "std::number::arccos", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number representing the cosine value, must be between -1 and 1." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the arccosine (inverse cosine) of the input value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Arccosine" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the arccosine of a number, in radians." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the angle in radians whose cosine is the given number." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +1 --> 0 +-1 --> 3.14159 (π) + +## arctan +Calculates the inverse tangent (in radians). + +```json +{ + "runtime_name": "std::number::arctan", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number representing the tangent value." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the arctangent (inverse tangent) of the input value." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Arctangent" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the arctangent of a number, in radians." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the angle in radians whose tangent is the given number." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 0 +1 --> 0.7854 (π/4) + +## sinh +Calculates the hyperbolic sine of a number. + +```json +{ + "runtime_name": "std::number::sinh", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number for which to calculate the hyperbolic sine." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the hyperbolic sine of the given number." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Hyperbolic Sine" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the hyperbolic sine of a number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the hyperbolic sine (sinh) of the input value." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 0 +1 --> 1.1752 + +## cosh +Calculates the hyperbolic cosine of a number. + +```json +{ + "runtime_name": "std::number::cosh", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number for which to calculate the hyperbolic cosine." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the hyperbolic cosine of the given number." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Hyperbolic Cosine" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the hyperbolic cosine of a number." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the hyperbolic cosine (cosh) of the input value." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +0 --> 1 +1 --> 1.5431 + +## clamp +Constrains a number to be within a specified range. + +```json +{ + "runtime_name": "std::number::clamp", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The number to be clamped within the range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input number that will be limited to the specified range." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "min", + "name": [ + { + "code": "en-US", + "content": "Minimum" + } + ], + "description": [ + { + "code": "en-US", + "content": "The lower bound of the clamping range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The minimum allowed value in the clamping operation." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "max", + "name": [ + { + "code": "en-US", + "content": "Maximum" + } + ], + "description": [ + { + "code": "en-US", + "content": "The upper bound of the clamping range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The maximum allowed value in the clamping operation." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Clamp" + } + ], + "description": [ + { + "code": "en-US", + "content": "Limits a number to be within a specified range." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the given number clamped between the minimum and maximum bounds." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +10, 0, 5 --> 5 (clamped to max) +-3, 0, 5 --> 0 (clamped to min) +3, 0, 5 --> 3 (within range, unchanged) + +## isEqual +Will compare one boolean to another. + +```json +{ + "runtime_name": "std::number::isEqual", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first number to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The first operand in the equality check." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Number" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second number to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The second operand in the equality check." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Is Equal" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether two numbers are equal." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the first number is equal to the second number, otherwise false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +1, 1 --> true + +1, 2 --> false + +# Additions: +- isGreaterOrEqual +- isLessOrEqual diff --git a/definitions/functions/primitive/text-audit.md b/definitions/runtime_functions/primitive/text-audit.md similarity index 100% rename from definitions/functions/primitive/text-audit.md rename to definitions/runtime_functions/primitive/text-audit.md diff --git a/definitions/runtime_functions/primitive/text.md b/definitions/runtime_functions/primitive/text.md new file mode 100644 index 0000000..7290f1b --- /dev/null +++ b/definitions/runtime_functions/primitive/text.md @@ -0,0 +1,2422 @@ +# std for PRIMITIVE: TEXT + +## asBytes +Converts the text to a number array. + +```json +{ + "runtime_name": "std::text::as_bytes", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text to convert into bytes." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts the input text string into an array of byte values." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_mappers": [ + { + "source": { + "data_type_identifier": "NUMBER" + }, + "target": "T" + } + ], + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "As Bytes" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts a text string into an array of byte values." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns an array of bytes representing the UTF-8 encoding of the given text." + } + ], + "deprecation_message": [], + "generic_keys": [] +} +``` + +**Example**: + +"hello" --> [104, 101, 108, 108, 111] + +## byteSize +Returns the size of the text in bytes. + +```json +{ + "runtime_name": "std::text::byte_size", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text whose byte size is to be calculated." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Calculates the size in bytes of the given text, typically its UTF-8 encoding length." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Byte Size" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the number of bytes required to encode the given text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the size in bytes of the provided text string, typically by counting UTF-8 encoded bytes." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello" --> 5 + +## capitalize +Capitalizes the first character of the text. + +```json +{ + "runtime_name": "std::text::capitalize", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to capitalize." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Capitalizes the first letter of the input text string." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Capitalize" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts the first character of the text to uppercase and leaves the rest unchanged." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new text string with the first letter capitalized." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello" --> "Hello" + +"world wide web" --> "World wide web" + +## uppercase +Converts all characters in the text to uppercase. + +```json +{ + "runtime_name": "std::text::uppercase", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to convert to uppercase." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts all characters in the input text string to uppercase." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Uppercase" + } + ], + "description": [ + { + "code": "en-US", + "content": "Transforms all letters in the text to their uppercase equivalents." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new text string with all characters converted to uppercase." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello" --> "HELLO" + +"Hello World" --> "HELLO WORLD" + +## lowercase +Converts all characters in the text to lowercase. + +```json +{ + "runtime_name": "std::text::lowercase", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to convert to lowercase." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Converts all characters in the input text string to lowercase." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Lowercase" + } + ], + "description": [ + { + "code": "en-US", + "content": "Transforms all letters in the text to their lowercase equivalents." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new text string with all characters converted to lowercase." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"HELLO" --> "hello" + +"Hello World" --> "hello world" + +## swapcase +Swaps the case of all characters in the text. + +```json +{ + "runtime_name": "std::text::swapcase", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string whose case will be swapped." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Swaps the case of each letter in the input text: uppercase letters become lowercase, and vice versa." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Swap Case" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts uppercase letters to lowercase and lowercase letters to uppercase in the given text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new text string with the case of each character inverted." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"Hello" --> "hELLO" + +"Hello World" --> "hELLO wORLD" + +## chars +Splits the text into an array of characters. + +```json +{ + "runtime_name": "std::text::chars", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to split into characters." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Splits the input text string into an array of its constituent characters." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "source": { + "data_type_identifier": "TEXT" + }, + "target": "R" + } + ], + "name": [ + { + "code": "en-US", + "content": "Characters" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns an array containing each character from the given text string." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Creates an array where each element is a single character from the original text." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +**Example**: + +"hello" --> ["h", "e", "l", "l", "o"] + +## at +Returns the character at the specified index. + +```json +{ + "runtime_name": "std::text::at", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string from which to extract the character." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text from which a character will be retrieved by index." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "index", + "name": [ + { + "code": "en-US", + "content": "Index" + } + ], + "description": [ + { + "code": "en-US", + "content": "The zero-based position of the character to extract." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies which character to return from the text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "error_type_identifiers": [], + "name": [ + { + "code": "en-US", + "content": "Character at Index" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the character at the specified index in the text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Retrieves a single character from the input text based on the provided zero-based index." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello", 1 --> "e" + +"world", 0 --> "w" + +## trim +Removes whitespace from both ends of the text. + +```json +{ + "runtime_name": "std::text::trim", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text Value" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to trim whitespace from." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text from which leading and trailing whitespace characters will be removed." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Trim Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Removes leading and trailing whitespace from the text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string with all leading and trailing whitespace characters removed from the input text." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +" hello " --> "hello" + +" hello world " --> "hello world" + +## apped +Concatenates two strings together. + +```json +{ + "runtime_name": "std::text::append", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Original Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The initial text to which the suffix will be appended." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The base text string that will have another string appended to its end." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "suffix", + "name": [ + { + "code": "en-US", + "content": "Suffix" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text to append to the original value." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The text string that will be concatenated to the end of the original text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Append Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Concatenates the suffix text to the end of the original text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new text string consisting of the original text followed by the specified suffix." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello", " world" --> "hello world" + +"abc", "123" --> "abc123" + +## prepend +Adds text to the beginning of the string. + +```json +{ + "runtime_name": "std::text::prepend", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Original Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The initial text to which the prefix will be added." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The base text string that will have another string prepended to its beginning." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "prefix", + "name": [ + { + "code": "en-US", + "content": "Prefix" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text to prepend before the original value." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The text string that will be concatenated to the start of the original text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Prepend Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Concatenates the prefix text to the beginning of the original text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new text string consisting of the specified prefix followed by the original text." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"world", "hello " --> "hello world" + +"123", "abc" --> "abc123" + +## insert +Inserts text at the specified position. + +```json +{ + "runtime_name": "std::text::insert", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Original Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The original text into which another text will be inserted." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the base string where the insertion happens." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "position", + "name": [ + { + "code": "en-US", + "content": "Position" + } + ], + "description": [ + { + "code": "en-US", + "content": "The index at which the text will be inserted." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Zero-based index indicating where the new text should be inserted." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "text", + "name": [ + { + "code": "en-US", + "content": "Text to Insert" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text that will be inserted into the original text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The substring to be inserted at the specified position." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Insert Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Inserts a given text into the original text at the specified position." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string where the provided text is inserted at the zero-based position index within the original text." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"helloworld", 5, " " --> "hello world" + +"abcdef", 3, "123" --> "abc123def" + +## length +Returns the length of the text. + +```json +{ + "runtime_name": "std::text::length", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text whose length will be calculated." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Input string to determine the number of characters it contains." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Length" + } + ], + "description": [ + { + "code": "en-US", + "content": "Returns the number of characters in the given text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Computes the length of the input string in terms of characters." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello" --> 5 + +"hello world" --> 11 + +## remove +Removes a portion of text from the specified start index to end index. + +```json +{ + "runtime_name": "std::text::remove", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The original text to remove a substring from." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text from which a substring will be removed." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "start", + "name": [ + { + "code": "en-US", + "content": "Start Index" + } + ], + "description": [ + { + "code": "en-US", + "content": "The zero-based index where removal begins." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The starting position for removing characters from the text." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "runtime_name": "end", + "name": [ + { + "code": "en-US", + "content": "End Index" + } + ], + "description": [ + { + "code": "en-US", + "content": "The zero-based index where removal ends (exclusive)." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The position just after the last character to be removed." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Remove Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "Removes the substring between the specified start and end indices from the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string with characters removed from start up to but not including end." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello world", 5, 6 --> "helloworld" + +"abcdefg", 2, 5 --> "abfg" + +## replace +Replaces all occurrences of a substring with another string. + +```json +{ + "runtime_name": "std::text::replace", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Original Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text where replacements will be made." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This is the text in which all occurrences of the old substring will be replaced." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "old", + "name": [ + { + "code": "en-US", + "content": "Old Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to be replaced." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "All occurrences of this substring in the original text will be replaced." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "new", + "name": [ + { + "code": "en-US", + "content": "New Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to replace with." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This substring will replace each occurrence of the old substring." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Replace Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "Replaces all occurrences of a specified substring with another substring in the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string where every instance of the old substring is replaced by the new substring." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello world", "world", "universe" --> "hello universe" + +"ababab", "a", "c" --> "cbcbcb" + +## replaceFirst +Replaces the first occurrence of a substring with another string. + +```json +{ + "runtime_name": "std::text::replace_first", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Original Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text where the first replacement will be made." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This text contains the substring that will be replaced only once—the first occurrence." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "old", + "name": [ + { + "code": "en-US", + "content": "Old Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to be replaced." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Only the first occurrence of this substring will be replaced in the original text." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "new", + "name": [ + { + "code": "en-US", + "content": "New Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to replace with." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This substring will replace only the first occurrence of the old substring." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Replace First Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "Replaces the first occurrence of a specified substring with another substring in the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string where only the first instance of the old substring is replaced by the new substring." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello hello", "hello", "hi" --> "hi hello" + +"ababab", "a", "c" --> "cbabab" + +## replaceLast +Replaces the last occurrence of a substring with another string. + +```json +{ + "runtime_name": "std::text::replace_last", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Original Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text where the last replacement will be made." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This text contains the substring that will be replaced only once—the last occurrence." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "old", + "name": [ + { + "code": "en-US", + "content": "Old Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to be replaced." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Only the last occurrence of this substring will be replaced in the original text." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "new", + "name": [ + { + "code": "en-US", + "content": "New Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to replace with." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This substring will replace only the last occurrence of the old substring." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Replace Last Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "Replaces the last occurrence of a specified substring with another substring in the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string where only the last instance of the old substring is replaced by the new substring." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello hello", "hello", "hi" --> "hello hi" + +"ababab", "a", "c" --> "ababcb" + +## hex +Converts the text to a hexadecimal representation. + +```json +{ + "runtime_name": "std::text::hex", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Input Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to be converted to its hexadecimal representation." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This function converts each character of the input text into its corresponding hexadecimal code, returning the concatenated hex string." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Text to Hexadecimal" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts a text string into a hexadecimal representation." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a string containing the hexadecimal values corresponding to each character of the input text." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello" --> "68656c6c6f" + +"ABC" --> "414243" + +## octal +Converts the text to an octal representation. + +```json +{ + "runtime_name": "std::text::octal", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Input Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to be converted to its octal representation." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "This function converts each character of the input text into its corresponding octal code, returning the concatenated octal string." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Text to Octal" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts a text string into an octal representation." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a string containing the octal values corresponding to each character of the input text." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello" --> "150145154154157" + +"ABC" --> "101102103" + +## indexOf +Returns the index of the first occurrence of a substring, or -1 if not found. + +```json +{ + "runtime_name": "std::text::index_of", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to search within." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The text string to search within." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "substring", + "name": [ + { + "code": "en-US", + "content": "Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The substring to find inside the text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The substring to find inside the text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "NUMBER" + }, + "name": [ + { + "code": "en-US", + "content": "Index Of" + } + ], + "description": [ + { + "code": "en-US", + "content": "Finds the first occurrence index of the substring within the text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns the zero-based index of the first occurrence of the substring in the text. Returns -1 if the substring is not found." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello world", "world" --> 6 + +"hello world", "not found" --> -1 + +## contains +Checks if the text contains a specified substring. + +```json +{ + "runtime_name": "std::text::contains", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The main text to search within." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The main text to search within." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "substring", + "name": [ + { + "code": "en-US", + "content": "Substring" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text to search for inside the main text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The text to search for inside the main text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "Contains" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks if the main text contains the specified substring." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the substring is found anywhere in the main text; otherwise, returns false." + } + ], + "deprecation_message": [], + "generic_keys": [], + "error_type_identifiers": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello world", "world" --> true + +"hello world", "not found" --> false + +## split +Splits the text into an array of strings based on a delimiter. + +```json +{ + "runtime_name": "std::text::split", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text to be split." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text to be split." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "delimiter", + "name": [ + { + "code": "en-US", + "content": "Delimiter" + } + ], + "description": [ + { + "code": "en-US", + "content": "The delimiter string to split the text by." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The delimiter string to split the text by." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "generic_keys": ["R"], + "generic_mappers": [ + { + "source": { + "data_type_identifier": "TEXT" + }, + "target": "R" + } + ], + "name": [ + { + "code": "en-US", + "content": "Split" + } + ], + "description": [ + { + "code": "en-US", + "content": "Splits the input text into an array of substrings based on the specified delimiter." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns an array of substrings obtained by splitting the input text at each occurrence of the delimiter." + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +**Example**: + +"hello world", " " --> ["hello", "world"] + +"a,b,c", "," --> ["a", "b", "c"] + +## reverse +Reverses the text. + +```json +{ + "runtime_name": "std::text::reverse", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text to be reversed." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text to be reversed." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Reverse" + } + ], + "description": [ + { + "code": "en-US", + "content": "Reverses the characters in the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns a new string with the characters of the input text in reverse order." + } + ], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [], + "error_type_identifiers": [] +} +``` + +**Example**: + +"hello" --> "olleh" + +"world" --> "dlrow" + +## startWith +Checks if the text starts with a specified prefix. + +```json +{ + "runtime_name": "std::text::start_with", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text to check." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text to check." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "prefix", + "name": [ + { + "code": "en-US", + "content": "Prefix" + } + ], + "description": [ + { + "code": "en-US", + "content": "The prefix to test against the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The prefix to test against the input text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "Starts With" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks if the input text starts with the specified prefix." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the input text begins with the given prefix; otherwise, returns false." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello world", "hello" --> true + +"hello world", "world" --> false + +## endsWith +Checks if the text ends with a specified suffix. + +```json +{ + "runtime_name": "std::text::ends_with", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The input text to check." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The input text to check." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "suffix", + "name": [ + { + "code": "en-US", + "content": "Suffix" + } + ], + "description": [ + { + "code": "en-US", + "content": "The suffix to test against the input text." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The suffix to test against the input text." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "Ends With" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks if the input text ends with the specified suffix." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns true if the input text ends with the given suffix; otherwise, returns false." + } + ], + "deprecation_message": [], + "error_type_identifiers": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"hello world", "world" --> true + +"hello world", "hello" --> false + +## toASCII +Converts each character to its ASCII code as an array of numbers. + +```json +{ + "runtime_name": "std::text::to_ascii", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Input text to convert to ASCII codes." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Input text to convert to ASCII codes." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "name": [ + { + "code": "en-US", + "content": "To ASCII" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts each character of the input text into its corresponding ASCII numerical code." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Returns an array of numbers where each number represents the ASCII code of the corresponding character in the input text." + } + ], + "generic_keys": ["R"], + "generic_mappers": [ + { + "source": { + "data_type_identifier": "NUMBER" + }, + "target": "R" + } + ], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +**Example**: + +"hello" --> [104, 101, 108, 108, 111] + +"ABC" --> [65, 66, 67] + +## fromASCII +Converts an array of ASCII codes to a text string. + +```json +{ + "runtime_name": "std::text::from_ascii", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "ARRAY" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "ASCII Codes" + } + ], + "description": [ + { + "code": "en-US", + "content": "Array of ASCII numeric codes representing characters." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Array of ASCII numeric codes representing characters." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "From ASCII" + } + ], + "description": [ + { + "code": "en-US", + "content": "Converts an array of ASCII codes back into the corresponding text string." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Takes an array of numbers where each number is an ASCII code, and returns the string they represent." + } + ], + "generic_mappers": [ + { + "parameter_id": "value", + "source": { + "data_type_identifier": "NUMBER" + }, + "target": "T" + } + ], + "generic_keys": [], + "deprecation_message": [], + "error_type_identifiers": [] +} +``` + +**Example**: + +[104, 101, 108, 108, 111] --> "hello" + +[65, 66, 67] --> "ABC" + +## encode +Encodes the text using a specified encoding. + +```json +{ + "runtime_name": "std::text::encode", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "value", + "name": [ + { + "code": "en-US", + "content": "Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The text string to encode." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The text string to encode." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT_ENCODING" + }, + "runtime_name": "encoding", + "name": [ + { + "code": "en-US", + "content": "Encoding Type" + } + ], + "description": [ + { + "code": "en-US", + "content": "The encoding scheme to apply (e.g., UTF-8, Base64)." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The encoding scheme to apply (e.g., UTF-8, Base64)." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "TEXT" + }, + "name": [ + { + "code": "en-US", + "content": "Encode Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "Encodes the input text into the specified encoding format." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Transforms the given text string into a representation encoded by the specified encoding scheme." + } + ], + "generic_keys": [], + "generic_mappers": [], + "error_type_identifiers": [], + "deprecation_message": [] +} +``` + +**Example**: + +"hello", "base64" --> "aGVsbG8=" + +## isEqual + +```json +{ + "runtime_name": "std::text::is_equal", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "first", + "name": [ + { + "code": "en-US", + "content": "First Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The first text string to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The first input text for equality comparison." + } + ] + }, + { + "data_type_identifier": { + "data_type_identifier": "TEXT" + }, + "runtime_name": "second", + "name": [ + { + "code": "en-US", + "content": "Second Text" + } + ], + "description": [ + { + "code": "en-US", + "content": "The second text string to compare." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "The second input text for equality comparison." + } + ] + } + ], + "return_type_identifier": { + "data_type_identifier": "BOOLEAN" + }, + "name": [ + { + "code": "en-US", + "content": "Is Equal" + } + ], + "description": [ + { + "code": "en-US", + "content": "Checks whether the two input text strings are equal." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Determines if the two given text inputs are exactly the same, returning true if equal, false otherwise." + } + ], + "error_type_identifiers": [], + "deprecation_message": [], + "generic_keys": [], + "generic_mappers": [] +} +``` + +**Example**: + +"TEXT", "TEXT" --> true + +"TEXT", "WORD" --> false diff --git a/src/context/mod.rs b/src/context/mod.rs index 87b9157..e858586 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -1,33 +1,142 @@ -/// A simple context that holds variable bindings in nested layers. -/// Each layer is a map from String identifiers to Values. -use std::collections::HashMap; +use crate::error::RuntimeError; +use std::{ + collections::{HashMap, VecDeque}, + ops::Index, +}; use tucana::shared::{ReferenceValue, Value}; -use crate::error::RuntimeError; +type NodeResult = Result; + +pub enum ContextResult { + // Will return the value / error if present of an executed node + NodeExecutionResult(NodeResult), + + // Will return the parameter of the node (indexed by the context) + ParameterResult(Value), +} + +#[derive(Clone)] +pub struct ContextEntry { + result: Result, + parameter: Vec, +} + +impl ContextEntry { + pub fn new(result: NodeResult, parameter: Vec) -> Self { + ContextEntry { + result: result, + parameter: parameter, + } + } +} -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq, Hash, Clone)] pub struct ContextReference { + // Level referencing the context depth (if a node will execute nodes in itself, e.g. foreach, map...) pub primary_level: i32, + + // Level of depth in the current context level (node after node starting_node -> next_node --> next_node --> ending_node) pub secondary_level: i32, + + // Index of parameters as input parameter of a node pub tertiary_level: Option, } -#[derive(Debug)] pub struct Context { + current_context_level: ContextReference, /// A stack of environments: layer 0 is the outermost. - layers: HashMap>, + layers: HashMap, + /// Context Snapshot of Past Context + context_history: VecDeque<(i32, i32)>, } impl Context { /// Create a new, empty context. pub fn new() -> Self { Context { + current_context_level: ContextReference { + primary_level: 0, + secondary_level: 0, + tertiary_level: None, + }, layers: HashMap::new(), + context_history: VecDeque::new(), + } + } + + pub fn write_to_context(&mut self, reference: ContextReference, entry: ContextEntry) { + self.layers.insert(reference, entry); + } + + pub fn write_to_current_context(&mut self, entry: ContextEntry) { + self.write_to_context(self.current_context_level.clone(), entry); + } + + pub fn set_current_context( + &mut self, + primary_level: i32, + seconday_level: i32, + tertiary_level: Option, + ) { + self.current_context_level.primary_level = primary_level; + self.current_context_level.secondary_level = seconday_level; + self.current_context_level.tertiary_level = tertiary_level; + } + + /// Will indent the context and save the past context + pub fn next_context(&mut self) { + let context_snapshot = ( + self.current_context_level.primary_level, + self.current_context_level.secondary_level, + ); + + self.context_history.push_back(context_snapshot); + + self.current_context_level.primary_level += 1; + self.current_context_level.secondary_level = 0; + } + + /// Will return to the parent context and increment the seconday level + pub fn leave_context(&mut self) { + let last_snapshot = match self.context_history.pop_back() { + Some(pair) => pair, + None => return, + }; + + self.current_context_level.primary_level = last_snapshot.0; + self.current_context_level.secondary_level = last_snapshot.1 + 1; + } + + pub fn next_node(&mut self) { + self.current_context_level.secondary_level += 1; + } + + // Looks up the current Context + pub fn get_current_context(&self) -> Option { + for (context, value) in self.layers.iter() { + if context.primary_level != self.current_context_level.primary_level { + continue; + } + + if context.secondary_level != self.current_context_level.secondary_level { + continue; + } + + if let Some(index) = self.current_context_level.tertiary_level { + let params = &value.parameter; + + let real_index = index as usize; + let value = params.index(real_index); + return Some(ContextResult::ParameterResult(value.clone())); + } + + return Some(ContextResult::NodeExecutionResult(value.result.clone())); } + None } - /// Look up a name, searching from innermost outward. - pub fn get(&self, reference: &ReferenceValue) -> Option<&Result> { + /// Looks up the context of a reference + pub fn get(&self, reference: &ReferenceValue) -> Option { for (context, value) in self.layers.iter() { if context.primary_level != reference.primary_level { continue; @@ -37,12 +146,20 @@ impl Context { continue; } - if context.tertiary_level != reference.tertiary_level { - continue; + if let Some(index) = reference.tertiary_level { + let params = &value.parameter; + + let real_index = index as usize; + let value = params.index(real_index); + return Some(ContextResult::ParameterResult(value.clone())); } - return Some(value); + return Some(ContextResult::NodeExecutionResult(value.result.clone())); } None } + + pub fn is_end(&self) -> bool { + self.current_context_level.primary_level == 0 + } } diff --git a/src/error/mod.rs b/src/error/mod.rs index e3f0593..8c5936f 100644 --- a/src/error/mod.rs +++ b/src/error/mod.rs @@ -3,7 +3,7 @@ use std::{ fmt::{Display, Formatter}, }; -#[derive(Debug)] +#[derive(Debug, Default, Clone)] pub struct RuntimeError {} impl Error for RuntimeError {} diff --git a/src/implementation/mod.rs b/src/implementation/mod.rs new file mode 100644 index 0000000..ccf41ce --- /dev/null +++ b/src/implementation/mod.rs @@ -0,0 +1,245 @@ +use tucana::shared::{Value, value::Kind}; + +use crate::{context::Context, error::RuntimeError, registry::HandlerFn}; + +pub fn collect() -> Vec<(&'static str, HandlerFn)> { + vec![ + ("std::number::add", add), + ("std::number::multiply", multiply), + ("std::number::substract", substract), + ("std::number::devide", devide), + ("std::number::modulo", modulo), + ("std::number::abs", abs), + ("std::number::is_positive", is_positive), + ("std::number::is_greater", is_greater), + ("std::number::is_less", is_less), + ("std::number::is_zero", is_zero), + ("std::number::from_text", from_text), + ("std::number::as_text", as_text), + ] +} + +fn add(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::NumberValue(lhs + rhs)), + }) +} + +fn multiply(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::NumberValue(lhs * rhs)), + }) +} + +fn substract(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::NumberValue(lhs - rhs)), + }) +} + +fn devide(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::NumberValue(lhs / rhs)), + }) +} + +fn modulo(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::NumberValue(lhs % rhs)), + }) +} + +fn abs(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(value)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::NumberValue(value.abs())), + }) +} + +fn is_positive(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(value)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::BoolValue(!value.is_sign_negative())), + }) +} + +fn is_greater(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::BoolValue(lhs > rhs)), + }) +} + +fn is_less(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(lhs)), + .. + }, + Value { + kind: Some(Kind::NumberValue(rhs)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::BoolValue(lhs < rhs)), + }) +} + +fn is_zero(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(value)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::BoolValue(value == &0.0)), + }) +} + +fn from_text(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::StringValue(string_value)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + let value: f64 = match string_value.parse() { + Ok(result) => result, + Err(_) => return Err(RuntimeError::default()), + }; + + Ok(Value { + kind: Some(Kind::NumberValue(value)), + }) +} + +fn as_text(values: &[Value], _ctx: &mut Context) -> Result { + let [ + Value { + kind: Some(Kind::NumberValue(value)), + .. + }, + ] = values + else { + return Err(RuntimeError::default()); + }; + + Ok(Value { + kind: Some(Kind::StringValue(value.to_string())), + }) +} diff --git a/src/locale/locale.rs b/src/locale/locale.rs index 468ed41..ad3a6ee 100644 --- a/src/locale/locale.rs +++ b/src/locale/locale.rs @@ -1,12 +1,12 @@ use std::{ collections::HashMap, - fs::{self, read_dir, DirEntry}, + fs::{self, DirEntry, read_dir}, }; use serde::Deserialize; use tucana::shared::Translation; -use super::code::{code_from_file_name, CountryCode}; +use super::code::{CountryCode, code_from_file_name}; #[derive(Debug)] pub struct Locale { diff --git a/src/main.rs b/src/main.rs index 61614b6..f7c78b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,159 @@ -pub mod locale; pub mod context; pub mod error; +pub mod implementation; +pub mod locale; pub mod registry; +use std::sync::Arc; + use code0_flow::flow_queue::service::{Message, RabbitmqClient}; +use context::{Context, ContextEntry, ContextResult}; +use error::RuntimeError; +use futures_lite::StreamExt; +use lapin::{options::BasicConsumeOptions, types::FieldTable}; use locale::locale::Locale; -use std::sync::Arc; +use registry::FunctionStore; +use tucana::shared::{Flow, NodeFunction, Value}; + +fn handle_node_function( + function: NodeFunction, + store: &FunctionStore, + context: &mut Context, +) -> Result { + let runtime_function = match store.get(function.runtime_function_id.as_str()) { + Some(fc) => fc, + None => todo!("Retrun if no funtion is present"), + }; + + let mut parameter_collection: Vec = vec![]; + + for parameter in function.parameters { + if let Some(value) = parameter.value { + match value { + // Its just a normal value, directly a paramter + tucana::shared::node_parameter::Value::LiteralValue(v) => { + parameter_collection.push(v) + } + + // Its a reference to an already executed function that returns value is the parameter of this function + tucana::shared::node_parameter::Value::ReferenceValue(reference) => { + let optional_value = context.get(&reference); + + // Look if its even present + let context_result = match optional_value { + Some(context_result) => context_result, + None => { + todo!("Required function that holds the parameter wasnt executed") + } + }; + + // A reference is present. Look up the real value + match context_result { + // The reference is a exeuction result of a node + ContextResult::NodeExecutionResult(node_result) => match node_result { + Ok(value) => { + parameter_collection.push(value.clone()); + } + Err(err) => return Err(err), + }, + // The reference is a parameter of a node + ContextResult::ParameterResult(parameter_result) => { + parameter_collection.push(parameter_result.clone()); + } + } + } + + // Its another function, that result is a direct parameter to this function + tucana::shared::node_parameter::Value::FunctionValue(another_node_function) => { + // As this is another new indent, a new context will be opened + context.next_context(); + let function_result = + handle_node_function(another_node_function, &store, context); + + let entry = + ContextEntry::new(function_result.clone(), parameter_collection.clone()); + context.write_to_current_context(entry); + + match function_result { + Ok(v) => { + // Add the value back to the main parameter + parameter_collection.push(v.clone()); + } + Err(_) => { + todo!("Reqired function that holds the paramter failed in execution") + } + } + } + } + } + + let result = runtime_function(¶meter_collection, context); + + // Result will be added to the current context + let entry = ContextEntry::new(result.clone(), parameter_collection.clone()); + context.write_to_current_context(entry); + + // Check if there is a next node, if not then this was the last one + match function.next_node { + Some(ref next_node_function) => { + let next = (**next_node_function).clone(); + + // Increment the context node! + context.next_node(); + + return handle_node_function(next, store, context); + } + None => { + if context.is_end() { + return result; + } + + context.leave_context(); + } + } + } + + Err(RuntimeError::default()) +} + +fn handle_message(message: Message, store: &FunctionStore) -> Result { + let mut context = Context::new(); + + let flow: Flow = match serde_json::from_str(&message.body) { + Ok(flow) => flow, + Err(_) => { + todo!() + } + }; + + if let Some(node) = flow.starting_node { + match handle_node_function(node, store, &mut context) { + Ok(result) => match serde_json::to_string(&result) { + Ok(res) => { + return Ok(Message { + message_id: message.message_id, + message_type: message.message_type, + timestamp: message.timestamp, + sender: message.sender, + body: res, + }); + } + Err(_) => { + todo!("") + } + }, + Err(runtime_error) => { + return Ok(Message { + message_id: message.message_id, + message_type: message.message_type, + timestamp: message.timestamp, + sender: message.sender, + body: runtime_error.to_string(), + }); + } + } + }; -fn handle_message(message: Message) -> Result { Ok(Message { message_id: message.message_id, message_type: message.message_type, @@ -19,14 +165,86 @@ fn handle_message(message: Message) -> Result { #[tokio::main] async fn main() { - let locale = Locale::default(); + let _locale = Locale::default(); + let store = FunctionStore::new(); + let rabbitmq_client = Arc::new(RabbitmqClient::new("amqp://localhost:5672").await); - // Receive messages from the send_queue - if let Err(e) = rabbitmq_client - .receive_messages("send_queue", handle_message) - .await - { - eprintln!("Failed to receive messages: {}", e); + let mut consumer = { + let channel = rabbitmq_client.channel.lock().await; + + let consumer_res = channel + .basic_consume( + "send_queue", + "consumer", + BasicConsumeOptions::default(), + FieldTable::default(), + ) + .await; + + match consumer_res { + Ok(consumer) => consumer, + Err(err) => panic!("Cannot consume messages: {}", err), + } + }; + + log::debug!("Starting to consume from send_queue"); + + while let Some(delivery) = consumer.next().await { + let delivery = match delivery { + Ok(del) => del, + Err(err) => { + log::error!("Error receiving message: {}", err); + return; + } + }; + + let data = &delivery.data; + let message_str = match std::str::from_utf8(&data) { + Ok(str) => { + log::info!("Received message: {}", str); + str + } + Err(err) => { + log::error!("Error decoding message: {}", err); + return; + } + }; + // Parse the messagey + let inc_message = match serde_json::from_str::(message_str) { + Ok(mess) => mess, + Err(err) => { + log::error!("Error parsing message: {}", err); + return; + } + }; + + let message = match handle_message(inc_message, &store) { + Ok(mess) => mess, + Err(err) => { + log::error!("Error handling message: {}", err); + return; + } + }; + + let message_json = match serde_json::to_string(&message) { + Ok(json) => json, + Err(err) => { + log::error!("Error serializing message: {}", err); + return; + } + }; + + { + let _ = rabbitmq_client + .send_message(message_json, "recieve_queue") + .await; + } + + // Acknowledge the message + delivery + .ack(lapin::options::BasicAckOptions::default()) + .await + .expect("Failed to acknowledge message"); } } diff --git a/src/registry/mod.rs b/src/registry/mod.rs index 7fea4b6..973f524 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -23,7 +23,7 @@ impl FunctionStore { } /// Execute all the registration closures to populate the map. - fn populate(&mut self, regs: Vec<(&'static str, HandlerFn)>) { + pub fn populate(&mut self, regs: Vec<(&'static str, HandlerFn)>) { for (id, func) in regs { self.functions.insert(id.to_string(), func); }