jexl-extended
Version:
Extended grammar for Javascript Expression Language (JEXL)
950 lines • 122 kB
JSON
[
{
"type": "Function",
"name": "string",
"description": "Casts the input to a string.",
"args": "input, prettify",
"returns": "string",
"code": "(input, prettify = false) => {\n return JSON.stringify(input, null, prettify ? 2 : 0);\n}"
},
{
"type": "Function",
"name": "$string",
"description": "Casts the input to a string.",
"args": "input, prettify",
"returns": "string",
"code": "(input, prettify = false) => {\n return JSON.stringify(input, null, prettify ? 2 : 0);\n}"
},
{
"type": "Function",
"name": "json",
"description": "Parses the string and returns a JSON object.",
"args": "input",
"returns": "any",
"code": "(input) => {\n return JSON.parse(input);\n}"
},
{
"type": "Function",
"name": "$json",
"description": "Parses the string and returns a JSON object.",
"args": "input",
"returns": "any",
"code": "(input) => {\n return JSON.parse(input);\n}"
},
{
"type": "Function",
"name": "parseJson",
"description": "Parses the string and returns a JSON object.",
"args": "input",
"returns": "any",
"code": "(input) => {\n return JSON.parse(input);\n}"
},
{
"type": "Function",
"name": "$parseJson",
"description": "Parses the string and returns a JSON object.",
"args": "input",
"returns": "any",
"code": "(input) => {\n return JSON.parse(input);\n}"
},
{
"type": "Function",
"name": "length",
"description": "Returns the number of characters in a string, or the length of an array.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return input.length;\n }\n if (Array.isArray(input)) {\n return input.length;\n }\n if (typeof input === 'object' && input !== null) {\n return Object.keys(input).length;\n }\n return 0;\n}"
},
{
"type": "Function",
"name": "$length",
"description": "Returns the number of characters in a string, or the length of an array.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return input.length;\n }\n if (Array.isArray(input)) {\n return input.length;\n }\n if (typeof input === 'object' && input !== null) {\n return Object.keys(input).length;\n }\n return 0;\n}"
},
{
"type": "Function",
"name": "count",
"description": "Returns the number of characters in a string, or the length of an array.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return input.length;\n }\n if (Array.isArray(input)) {\n return input.length;\n }\n if (typeof input === 'object' && input !== null) {\n return Object.keys(input).length;\n }\n return 0;\n}"
},
{
"type": "Function",
"name": "$count",
"description": "Returns the number of characters in a string, or the length of an array.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return input.length;\n }\n if (Array.isArray(input)) {\n return input.length;\n }\n if (typeof input === 'object' && input !== null) {\n return Object.keys(input).length;\n }\n return 0;\n}"
},
{
"type": "Function",
"name": "size",
"description": "Returns the number of characters in a string, or the length of an array.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return input.length;\n }\n if (Array.isArray(input)) {\n return input.length;\n }\n if (typeof input === 'object' && input !== null) {\n return Object.keys(input).length;\n }\n return 0;\n}"
},
{
"type": "Function",
"name": "$size",
"description": "Returns the number of characters in a string, or the length of an array.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return input.length;\n }\n if (Array.isArray(input)) {\n return input.length;\n }\n if (typeof input === 'object' && input !== null) {\n return Object.keys(input).length;\n }\n return 0;\n}"
},
{
"type": "Function",
"name": "substring",
"description": "Gets a substring of a string.",
"args": "input, start, length",
"returns": "string",
"code": "(input, start, length) => {\n let str = input;\n if (typeof str !== 'string') {\n str = JSON.stringify(str);\n }\n if (typeof str === 'string') {\n let startNum = start;\n let len = length !== null && length !== void 0 ? length : str.length;\n if (startNum < 0) {\n startNum = str.length + start;\n if (startNum < 0) {\n startNum = 0;\n }\n }\n if (startNum + len > str.length) {\n len = str.length - startNum;\n }\n if (len < 0) {\n len = 0;\n }\n return str.substring(startNum, startNum + len);\n }\n return '';\n}"
},
{
"type": "Function",
"name": "$substring",
"description": "Gets a substring of a string.",
"args": "input, start, length",
"returns": "string",
"code": "(input, start, length) => {\n let str = input;\n if (typeof str !== 'string') {\n str = JSON.stringify(str);\n }\n if (typeof str === 'string') {\n let startNum = start;\n let len = length !== null && length !== void 0 ? length : str.length;\n if (startNum < 0) {\n startNum = str.length + start;\n if (startNum < 0) {\n startNum = 0;\n }\n }\n if (startNum + len > str.length) {\n len = str.length - startNum;\n }\n if (len < 0) {\n len = 0;\n }\n return str.substring(startNum, startNum + len);\n }\n return '';\n}"
},
{
"type": "Function",
"name": "substringBefore",
"description": "Returns the substring before the first occurrence of the character sequence chars in str.",
"args": "input, chars",
"returns": "string",
"code": "(input, chars) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n const charsStr = typeof chars === 'string' ? chars : JSON.stringify(chars);\n const index = str.indexOf(charsStr);\n if (index === -1) {\n return str;\n }\n return str.substring(0, index);\n}"
},
{
"type": "Function",
"name": "$substringBefore",
"description": "Returns the substring before the first occurrence of the character sequence chars in str.",
"args": "input, chars",
"returns": "string",
"code": "(input, chars) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n const charsStr = typeof chars === 'string' ? chars : JSON.stringify(chars);\n const index = str.indexOf(charsStr);\n if (index === -1) {\n return str;\n }\n return str.substring(0, index);\n}"
},
{
"type": "Function",
"name": "substringAfter",
"description": "Returns the substring after the first occurrence of the character sequence chars in str.",
"args": "input, chars",
"returns": "string",
"code": "(input, chars) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n const charsStr = typeof chars === 'string' ? chars : JSON.stringify(chars);\n const index = str.indexOf(charsStr);\n if (index === -1) {\n return '';\n }\n return str.substring(index + charsStr.length);\n}"
},
{
"type": "Function",
"name": "$substringAfter",
"description": "Returns the substring after the first occurrence of the character sequence chars in str.",
"args": "input, chars",
"returns": "string",
"code": "(input, chars) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n const charsStr = typeof chars === 'string' ? chars : JSON.stringify(chars);\n const index = str.indexOf(charsStr);\n if (index === -1) {\n return '';\n }\n return str.substring(index + charsStr.length);\n}"
},
{
"type": "Function",
"name": "uppercase",
"description": "Converts the input string to uppercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toUpperCase();\n}"
},
{
"type": "Function",
"name": "$uppercase",
"description": "Converts the input string to uppercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toUpperCase();\n}"
},
{
"type": "Function",
"name": "upper",
"description": "Converts the input string to uppercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toUpperCase();\n}"
},
{
"type": "Function",
"name": "$upper",
"description": "Converts the input string to uppercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toUpperCase();\n}"
},
{
"type": "Function",
"name": "lowercase",
"description": "Converts the input string to lowercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toLowerCase();\n}"
},
{
"type": "Function",
"name": "$lowercase",
"description": "Converts the input string to lowercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toLowerCase();\n}"
},
{
"type": "Function",
"name": "lower",
"description": "Converts the input string to lowercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toLowerCase();\n}"
},
{
"type": "Function",
"name": "$lower",
"description": "Converts the input string to lowercase.",
"args": "input",
"returns": "string",
"code": "(input) => {\n const str = typeof input === 'string' ? input : JSON.stringify(input);\n return str.toLowerCase();\n}"
},
{
"type": "Function",
"name": "camelCase",
"description": "Converts the input string to camel case.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input !== 'string')\n return '';\n return input.split(splitRegex).map((word, index) => {\n if (index === 0)\n return word.toLowerCase();\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n }).join('');\n}"
},
{
"type": "Function",
"name": "$camelCase",
"description": "Converts the input string to camel case.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input !== 'string')\n return '';\n return input.split(splitRegex).map((word, index) => {\n if (index === 0)\n return word.toLowerCase();\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n }).join('');\n}"
},
{
"type": "Function",
"name": "pascalCase",
"description": "Converts the input string to pascal case.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input !== 'string')\n return '';\n return input.split(splitRegex).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join('');\n}"
},
{
"type": "Function",
"name": "$pascalCase",
"description": "Converts the input string to pascal case.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input !== 'string')\n return '';\n return input.split(splitRegex).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join('');\n}"
},
{
"type": "Function",
"name": "trim",
"description": "Trims whitespace from both ends of a string.",
"args": "input, trimChar",
"returns": "string",
"code": "(input, trimChar) => {\n if (typeof input === 'string') {\n if (trimChar) {\n return input.replace(new RegExp(`^${trimChar}+|${trimChar}+$`, 'g'), '');\n }\n return input.trim();\n }\n return '';\n}"
},
{
"type": "Function",
"name": "$trim",
"description": "Trims whitespace from both ends of a string.",
"args": "input, trimChar",
"returns": "string",
"code": "(input, trimChar) => {\n if (typeof input === 'string') {\n if (trimChar) {\n return input.replace(new RegExp(`^${trimChar}+|${trimChar}+$`, 'g'), '');\n }\n return input.trim();\n }\n return '';\n}"
},
{
"type": "Function",
"name": "pad",
"description": "Pads the input string on both sides to center it.",
"args": "input, width, char",
"returns": "string",
"code": "(input, width, char = ' ') => {\n const str = typeof input !== 'string' ? JSON.stringify(input) : input;\n if (width > 0) {\n return str.padEnd(width, char);\n }\n else {\n return str.padStart(-width, char);\n }\n}"
},
{
"type": "Function",
"name": "$pad",
"description": "Pads the input string on both sides to center it.",
"args": "input, width, char",
"returns": "string",
"code": "(input, width, char = ' ') => {\n const str = typeof input !== 'string' ? JSON.stringify(input) : input;\n if (width > 0) {\n return str.padEnd(width, char);\n }\n else {\n return str.padStart(-width, char);\n }\n}"
},
{
"type": "Function",
"name": "contains",
"description": "Checks if the input string contains the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string' || Array.isArray(input)) {\n return input.includes(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "$contains",
"description": "Checks if the input string contains the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string' || Array.isArray(input)) {\n return input.includes(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "includes",
"description": "Checks if the input string contains the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string' || Array.isArray(input)) {\n return input.includes(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "$includes",
"description": "Checks if the input string contains the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string' || Array.isArray(input)) {\n return input.includes(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "startsWith",
"description": "Checks if the input string starts with the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string') {\n return input.startsWith(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "$startsWith",
"description": "Checks if the input string starts with the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string') {\n return input.startsWith(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "endsWith",
"description": "Checks if the input string ends with the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string') {\n return input.endsWith(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "$endsWith",
"description": "Checks if the input string ends with the specified substring.",
"args": "input, search",
"returns": "boolean",
"code": "(input, search) => {\n if (typeof input === 'string') {\n return input.endsWith(search);\n }\n return false;\n}"
},
{
"type": "Function",
"name": "split",
"description": "Splits the input string into an array of substrings.",
"args": "input, separator",
"returns": "array",
"code": "(input, separator) => {\n if (typeof input === 'string') {\n return input.split(separator);\n }\n return [];\n}"
},
{
"type": "Function",
"name": "$split",
"description": "Splits the input string into an array of substrings.",
"args": "input, separator",
"returns": "array",
"code": "(input, separator) => {\n if (typeof input === 'string') {\n return input.split(separator);\n }\n return [];\n}"
},
{
"type": "Function",
"name": "join",
"description": "Joins elements of an array into a string.",
"args": "input, separator",
"returns": "string",
"code": "(input, separator) => {\n if (Array.isArray(input)) {\n return input.join(separator);\n }\n return undefined;\n}"
},
{
"type": "Function",
"name": "$join",
"description": "Joins elements of an array into a string.",
"args": "input, separator",
"returns": "string",
"code": "(input, separator) => {\n if (Array.isArray(input)) {\n return input.join(separator);\n }\n return undefined;\n}"
},
{
"type": "Function",
"name": "replace",
"description": "Replaces occurrences of a specified string.",
"args": "input, search, replacement",
"returns": "string",
"code": "(input, search, replacement) => {\n if (typeof input === 'string' && typeof search === 'string') {\n const _replacement = replacement === undefined ? '' : replacement;\n return input.replace(new RegExp(search, 'g'), _replacement);\n }\n return undefined;\n}"
},
{
"type": "Function",
"name": "$replace",
"description": "Replaces occurrences of a specified string.",
"args": "input, search, replacement",
"returns": "string",
"code": "(input, search, replacement) => {\n if (typeof input === 'string' && typeof search === 'string') {\n const _replacement = replacement === undefined ? '' : replacement;\n return input.replace(new RegExp(search, 'g'), _replacement);\n }\n return undefined;\n}"
},
{
"type": "Function",
"name": "base64Encode",
"description": "Encodes a string to Base64.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input === 'string') {\n try {\n encodeURIComponent(input);\n const bytes = new TextEncoder().encode(input);\n const binString = String.fromCodePoint(...bytes);\n return btoa(binString);\n }\n catch (error) {\n return '';\n }\n }\n return '';\n}"
},
{
"type": "Function",
"name": "$base64Encode",
"description": "Encodes a string to Base64.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input === 'string') {\n try {\n encodeURIComponent(input);\n const bytes = new TextEncoder().encode(input);\n const binString = String.fromCodePoint(...bytes);\n return btoa(binString);\n }\n catch (error) {\n return '';\n }\n }\n return '';\n}"
},
{
"type": "Function",
"name": "base64Decode",
"description": "Decodes a Base64 encoded string.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input === 'string') {\n const binString = atob(input);\n const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));\n return new TextDecoder().decode(bytes);\n }\n return '';\n}"
},
{
"type": "Function",
"name": "$base64Decode",
"description": "Decodes a Base64 encoded string.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input === 'string') {\n const binString = atob(input);\n const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0));\n return new TextDecoder().decode(bytes);\n }\n return '';\n}"
},
{
"type": "Function",
"name": "formUrlEncoded",
"description": "Encodes a string or object to URI.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input === 'string') {\n return encodeURIComponent(input);\n }\n else if (typeof input === 'object') {\n return Object.keys(input).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(input[key])}`).join('&');\n }\n return '';\n}"
},
{
"type": "Function",
"name": "$formUrlEncoded",
"description": "Encodes a string or object to URI.",
"args": "input",
"returns": "string",
"code": "(input) => {\n if (typeof input === 'string') {\n return encodeURIComponent(input);\n }\n else if (typeof input === 'object') {\n return Object.keys(input).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(input[key])}`).join('&');\n }\n return '';\n}"
},
{
"type": "Function",
"name": "number",
"description": "Converts the input to a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'number')\n return input;\n if (typeof input === 'string')\n return parseFloat(input);\n return NaN;\n}"
},
{
"type": "Function",
"name": "$number",
"description": "Converts the input to a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'number')\n return input;\n if (typeof input === 'string')\n return parseFloat(input);\n return NaN;\n}"
},
{
"type": "Function",
"name": "parseFloat",
"description": "Converts the input to a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'number')\n return input;\n if (typeof input === 'string')\n return parseFloat(input);\n return NaN;\n}"
},
{
"type": "Function",
"name": "$parseFloat",
"description": "Converts the input to a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'number')\n return input;\n if (typeof input === 'string')\n return parseFloat(input);\n return NaN;\n}"
},
{
"type": "Function",
"name": "abs",
"description": "Returns the absolute value of a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.abs(num);\n}"
},
{
"type": "Function",
"name": "$abs",
"description": "Returns the absolute value of a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.abs(num);\n}"
},
{
"type": "Function",
"name": "floor",
"description": "Rounds a number down to the nearest integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.floor(num);\n}"
},
{
"type": "Function",
"name": "$floor",
"description": "Rounds a number down to the nearest integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.floor(num);\n}"
},
{
"type": "Function",
"name": "ceil",
"description": "Rounds a number up to the nearest integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.ceil(num);\n}"
},
{
"type": "Function",
"name": "$ceil",
"description": "Rounds a number up to the nearest integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.ceil(num);\n}"
},
{
"type": "Function",
"name": "round",
"description": "Rounds a number to the nearest integer.",
"args": "input, decimals",
"returns": "number",
"code": "(input, decimals) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : decimals ? Math.round(num * Math.pow(10, decimals)) / Math.pow(10, decimals) : Math.round(num);\n}"
},
{
"type": "Function",
"name": "$round",
"description": "Rounds a number to the nearest integer.",
"args": "input, decimals",
"returns": "number",
"code": "(input, decimals) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : decimals ? Math.round(num * Math.pow(10, decimals)) / Math.pow(10, decimals) : Math.round(num);\n}"
},
{
"type": "Function",
"name": "power",
"description": "Returns the value of a number raised to a power.",
"args": "input, exponent",
"returns": "number",
"code": "(input, exponent) => {\n const num = (0, exports.toNumber)(input);\n const exp = exponent === undefined ? 2 : exponent;\n return isNaN(num) ? NaN : Math.pow(num, exp);\n}"
},
{
"type": "Function",
"name": "$power",
"description": "Returns the value of a number raised to a power.",
"args": "input, exponent",
"returns": "number",
"code": "(input, exponent) => {\n const num = (0, exports.toNumber)(input);\n const exp = exponent === undefined ? 2 : exponent;\n return isNaN(num) ? NaN : Math.pow(num, exp);\n}"
},
{
"type": "Function",
"name": "sqrt",
"description": "Returns the square root of a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.sqrt(num);\n}"
},
{
"type": "Function",
"name": "$sqrt",
"description": "Returns the square root of a number.",
"args": "input",
"returns": "number",
"code": "(input) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? NaN : Math.sqrt(num);\n}"
},
{
"type": "Function",
"name": "random",
"description": "Generates a random number between 0 (inclusive) and 1 (exclusive).",
"returns": "number",
"code": "() => {\n return Math.random();\n}"
},
{
"type": "Function",
"name": "$random",
"description": "Generates a random number between 0 (inclusive) and 1 (exclusive).",
"returns": "number",
"code": "() => {\n return Math.random();\n}"
},
{
"type": "Function",
"name": "formatNumber",
"description": "Casts the number to a string and formats it to a decimal representation as specified by the format string.",
"args": "input, format",
"returns": "string",
"code": "(input, format) => {\n var _a, _b, _c;\n const num = typeof input === 'number' ? input : parseInt((0, exports.toNumber)(input).toString(), 10);\n return isNaN(num) ? '' : num.toLocaleString('en-us', {\n minimumFractionDigits: (_a = format.split('.')[1]) === null || _a === void 0 ? void 0 : _a.length,\n maximumFractionDigits: (_b = format.split('.')[1]) === null || _b === void 0 ? void 0 : _b.length,\n useGrouping: (_c = format.split('.')[0]) === null || _c === void 0 ? void 0 : _c.includes(',')\n });\n}"
},
{
"type": "Function",
"name": "$formatNumber",
"description": "Casts the number to a string and formats it to a decimal representation as specified by the format string.",
"args": "input, format",
"returns": "string",
"code": "(input, format) => {\n var _a, _b, _c;\n const num = typeof input === 'number' ? input : parseInt((0, exports.toNumber)(input).toString(), 10);\n return isNaN(num) ? '' : num.toLocaleString('en-us', {\n minimumFractionDigits: (_a = format.split('.')[1]) === null || _a === void 0 ? void 0 : _a.length,\n maximumFractionDigits: (_b = format.split('.')[1]) === null || _b === void 0 ? void 0 : _b.length,\n useGrouping: (_c = format.split('.')[0]) === null || _c === void 0 ? void 0 : _c.includes(',')\n });\n}"
},
{
"type": "Function",
"name": "formatBase",
"description": "Formats a number as a string in the specified base.",
"args": "input, base",
"returns": "string",
"code": "(input, base) => {\n const num = typeof input === 'number' ? input : parseInt((0, exports.toNumber)(input).toString(), 10);\n return isNaN(num) ? '' : num.toString(base);\n}"
},
{
"type": "Function",
"name": "$formatBase",
"description": "Formats a number as a string in the specified base.",
"args": "input, base",
"returns": "string",
"code": "(input, base) => {\n const num = typeof input === 'number' ? input : parseInt((0, exports.toNumber)(input).toString(), 10);\n return isNaN(num) ? '' : num.toString(base);\n}"
},
{
"type": "Function",
"name": "formatInteger",
"description": "Formats a number as an integer.",
"args": "input, format",
"returns": "string",
"code": "(input, format) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? '' : (0, exports.pad)(Math.floor(num).toString(), -format.length, '0');\n}"
},
{
"type": "Function",
"name": "$formatInteger",
"description": "Formats a number as an integer.",
"args": "input, format",
"returns": "string",
"code": "(input, format) => {\n const num = (0, exports.toNumber)(input);\n return isNaN(num) ? '' : (0, exports.pad)(Math.floor(num).toString(), -format.length, '0');\n}"
},
{
"type": "Function",
"name": "parseInteger",
"description": "Parses a string and returns an integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return parseInt(input, 10);\n }\n else if (typeof input === 'number') {\n return Math.floor(input);\n }\n return NaN;\n}"
},
{
"type": "Function",
"name": "parseInt",
"description": "Parses a string and returns an integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return parseInt(input, 10);\n }\n else if (typeof input === 'number') {\n return Math.floor(input);\n }\n return NaN;\n}"
},
{
"type": "Function",
"name": "$parseInteger",
"description": "Parses a string and returns an integer.",
"args": "input",
"returns": "number",
"code": "(input) => {\n if (typeof input === 'string') {\n return parseInt(input, 10);\n }\n else if (typeof input === 'number') {\n return Math.floor(input);\n }\n return NaN;\n}"
},
{
"type": "Function",
"name": "sum",
"description": "Calculates the sum of an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n return input.flat().reduce((acc, val) => acc + (0, exports.toNumber)(val), 0);\n}"
},
{
"type": "Function",
"name": "$sum",
"description": "Calculates the sum of an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n return input.flat().reduce((acc, val) => acc + (0, exports.toNumber)(val), 0);\n}"
},
{
"type": "Function",
"name": "max",
"description": "Finds the maximum value in an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n return Math.max(...input.flat().map(exports.toNumber));\n}"
},
{
"type": "Function",
"name": "$max",
"description": "Finds the maximum value in an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n return Math.max(...input.flat().map(exports.toNumber));\n}"
},
{
"type": "Function",
"name": "min",
"description": "Finds the minimum value in an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n return Math.min(...input.flat().map(exports.toNumber));\n}"
},
{
"type": "Function",
"name": "$min",
"description": "Finds the minimum value in an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n return Math.min(...input.flat().map(exports.toNumber));\n}"
},
{
"type": "Function",
"name": "average",
"description": "Calculates the average of an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n const total = (0, exports.sum)(...input);\n return total / input.flat().length;\n}"
},
{
"type": "Function",
"name": "avg",
"description": "Calculates the average of an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n const total = (0, exports.sum)(...input);\n return total / input.flat().length;\n}"
},
{
"type": "Function",
"name": "$average",
"description": "Calculates the average of an array of numbers.",
"args": "input",
"returns": "number",
"code": "(...input) => {\n if (!Array.isArray(input))\n return NaN;\n const total = (0, exports.sum)(...input);\n return total / input.flat().length;\n}"
},
{
"type": "Function",
"name": "boolean",
"description": "Converts the input to a boolean.",
"args": "input",
"returns": "boolean",
"code": "(input) => {\n if (typeof input === 'boolean')\n return input;\n if (typeof input === 'number')\n return input !== 0;\n if (typeof input === 'string') {\n if (input.trim().toLowerCase() === 'true' || input.trim() === '1')\n return true;\n if (input.trim().toLowerCase() === 'false' || input.trim() === '0')\n return false;\n else\n return undefined;\n }\n return Boolean(input);\n}"
},
{
"type": "Function",
"name": "$boolean",
"description": "Converts the input to a boolean.",
"args": "input",
"returns": "boolean",
"code": "(input) => {\n if (typeof input === 'boolean')\n return input;\n if (typeof input === 'number')\n return input !== 0;\n if (typeof input === 'string') {\n if (input.trim().toLowerCase() === 'true' || input.trim() === '1')\n return true;\n if (input.trim().toLowerCase() === 'false' || input.trim() === '0')\n return false;\n else\n return undefined;\n }\n return Boolean(input);\n}"
},
{
"type": "Function",
"name": "bool",
"description": "Converts the input to a boolean.",
"args": "input",
"returns": "boolean",
"code": "(input) => {\n if (typeof input === 'boolean')\n return input;\n if (typeof input === 'number')\n return input !== 0;\n if (typeof input === 'string') {\n if (input.trim().toLowerCase() === 'true' || input.trim() === '1')\n return true;\n if (input.trim().toLowerCase() === 'false' || input.trim() === '0')\n return false;\n else\n return undefined;\n }\n return Boolean(input);\n}"
},
{
"type": "Function",
"name": "$bool",
"description": "Converts the input to a boolean.",
"args": "input",
"returns": "boolean",
"code": "(input) => {\n if (typeof input === 'boolean')\n return input;\n if (typeof input === 'number')\n return input !== 0;\n if (typeof input === 'string') {\n if (input.trim().toLowerCase() === 'true' || input.trim() === '1')\n return true;\n if (input.trim().toLowerCase() === 'false' || input.trim() === '0')\n return false;\n else\n return undefined;\n }\n return Boolean(input);\n}"
},
{
"type": "Function",
"name": "not",
"description": "Returns the logical NOT of the input.",
"args": "input",
"returns": "boolean",
"code": "(input) => {\n return !(0, exports.toBoolean)(input);\n}"
},
{
"type": "Function",
"name": "$not",
"description": "Returns the logical NOT of the input.",
"args": "input",
"returns": "boolean",
"code": "(input) => {\n return !(0, exports.toBoolean)(input);\n}"
},
{
"type": "Function",
"name": "case",
"description": "Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.",
"args": "args",
"returns": "unknown",
"code": "(...args) => {\n if (args.length < 3)\n return null;\n const expressionResult = args[0];\n for (let i = 1; i < args.length - 1; i += 2) {\n const caseResult = args[i];\n if (JSON.stringify(expressionResult) === JSON.stringify(caseResult)) {\n return args[i + 1];\n }\n }\n // Return default\n if (args.length % 2 === 0) {\n const defaultResult = args[args.length - 1];\n return defaultResult;\n }\n // Return null if no default specified\n return null;\n}"
},
{
"type": "Function",
"name": "$case",
"description": "Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.",
"args": "args",
"returns": "unknown",
"code": "(...args) => {\n if (args.length < 3)\n return null;\n const expressionResult = args[0];\n for (let i = 1; i < args.length - 1; i += 2) {\n const caseResult = args[i];\n if (JSON.stringify(expressionResult) === JSON.stringify(caseResult)) {\n return args[i + 1];\n }\n }\n // Return default\n if (args.length % 2 === 0) {\n const defaultResult = args[args.length - 1];\n return defaultResult;\n }\n // Return null if no default specified\n return null;\n}"
},
{
"type": "Function",
"name": "switch",
"description": "Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.",
"args": "args",
"returns": "unknown",
"code": "(...args) => {\n if (args.length < 3)\n return null;\n const expressionResult = args[0];\n for (let i = 1; i < args.length - 1; i += 2) {\n const caseResult = args[i];\n if (JSON.stringify(expressionResult) === JSON.stringify(caseResult)) {\n return args[i + 1];\n }\n }\n // Return default\n if (args.length % 2 === 0) {\n const defaultResult = args[args.length - 1];\n return defaultResult;\n }\n // Return null if no default specified\n return null;\n}"
},
{
"type": "Function",
"name": "$switch",
"description": "Evaluates a list of predicates and returns the first result expression whose predicate is satisfied.",
"args": "args",
"returns": "unknown",
"code": "(...args) => {\n if (args.length < 3)\n return null;\n const expressionResult = args[0];\n for (let i = 1; i < args.length - 1; i += 2) {\n const caseResult = args[i];\n if (JSON.stringify(expressionResult) === JSON.stringify(caseResult)) {\n return args[i + 1];\n }\n }\n // Return default\n if (args.length % 2 === 0) {\n const defaultResult = args[args.length - 1];\n return defaultResult;\n }\n // Return null if no default specified\n return null;\n}"
},
{
"type": "Function",
"name": "append",
"description": "Appends an element to an array.",
"args": "input",
"returns": "array",
"code": "(...input) => {\n if (!Array.isArray(input))\n return [];\n return [...input.flat()];\n}"
},
{
"type": "Function",
"name": "$append",
"description": "Appends an element to an array.",
"args": "input",
"returns": "array",
"code": "(...input) => {\n if (!Array.isArray(input))\n return [];\n return [...input.flat()];\n}"
},
{
"type": "Function",
"name": "concat",
"description": "Appends an element to an array.",
"args": "input",
"returns": "array",
"code": "(...input) => {\n if (!Array.isArray(input))\n return [];\n return [...input.flat()];\n}"
},
{
"type": "Function",
"name": "$concat",
"description": "Appends an element to an array.",
"args": "input",
"returns": "array",
"code": "(...input) => {\n if (!Array.isArray(input))\n return [];\n return [...input.flat()];\n}"
},
{
"type": "Function",
"name": "reverse",
"description": "Reverses the elements of an array.",
"args": "input",
"returns": "array",
"code": "(...input) => {\n if (!Array.isArray(input))\n return [];\n return [...input.flat()].reverse();\n}"
},
{
"type": "Function",
"name": "$reverse",
"description": "Reverses the elements of an array.",
"args": "input",
"returns": "array",
"code": "(...input) => {\n if (!Array.isArray(input))\n return [];\n return [...input.flat()].reverse();\n}"
},
{
"type": "Function",
"name": "shuffle",
"description": "Shuffles the elements of an array.",
"args": "input",
"returns": "array",
"code": "(input) => {\n if (!Array.isArray(input))\n return [];\n for (let i = input.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [input[i], input[j]] = [input[j], input[i]];\n }\n return input;\n}"
},
{
"type": "Function",
"name": "$shuffle",
"description": "Shuffles the elements of an array.",
"args": "input",
"returns": "array",
"code": "(input) => {\n if (!Array.isArray(input))\n return [];\n for (let i = input.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [input[i], input[j]] = [input[j], input[i]];\n }\n return input;\n}"
},
{
"type": "Function",
"name": "sort",
"description": "Sorts the elements of an array.",
"args": "input, expression, descending",
"returns": "array",
"code": "(input, expression, descending) => {\n if (!Array.isArray(input))\n return [];\n if (!expression)\n return [...input].sort();\n const expr = _1.default.compile(expression);\n const compareFunction = (a, b) => {\n const aValue = expr.evalSync(a);\n const bValue = expr.evalSync(b);\n if (aValue < bValue)\n return descending ? -1 : 1;\n if (aValue > bValue)\n return descending ? 1 : -1;\n return 0;\n };\n return [...input].sort(compareFunction);\n}"
},
{
"type": "Function",
"name": "$sort",
"description": "Sorts the elements of an array.",
"args": "input, expression, descending",
"returns": "array",
"code": "(input, expression, descending) => {\n if (!Array.isArray(input))\n return [];\n if (!expression)\n return [...input].sort();\n const expr = _1.default.compile(expression);\n const compareFunction = (a, b) => {\n const aValue = expr.evalSync(a);\n const bValue = expr.evalSync(b);\n if (aValue < bValue)\n return descending ? -1 : 1;\n if (aValue > bValue)\n return descending ? 1 : -1;\n return 0;\n };\n return [...input].sort(compareFunction);\n}"
},
{
"type": "Function",
"name": "order",
"description": "Sorts the elements of an array.",
"args": "input, expression, descending",
"returns": "array",
"code": "(input, expression, descending) => {\n if (!Array.isArray(input))\n return [];\n if (!expression)\n return [...input].sort();\n const expr = _1.default.compile(expression);\n const compareFunction = (a, b) => {\n const aValue = expr.evalSync(a);\n const bValue = expr.evalSync(b);\n if (aValue < bValue)\n return descending ? -1 : 1;\n if (aValue > bValue)\n return descending ? 1 : -1;\n return 0;\n };\n return [...input].sort(compareFunction);\n}"
},
{
"type": "Function",
"name": "$order",
"description": "Sorts the elements of an array.",
"args": "input, expression, descending",
"returns": "array",
"code": "(input, expression, descending) => {\n if (!Array.isArray(input))\n return [];\n if (!expression)\n return [...input].sort();\n const expr = _1.default.compile(expression);\n const compareFunction = (a, b) => {\n const aValue = expr.evalSync(a);\n const bValue = expr.evalSync(b);\n if (aValue < bValue)\n return descending ? -1 : 1;\n if (aValue > bValue)\n return descending ? 1 : -1;\n return 0;\n };\n return [...input].sort(compareFunction);\n}"
},
{
"type": "Function",
"name": "distinct",
"description": "Returns a new array with the elements of the input array with duplicates removed.",
"args": "input",
"returns": "array",
"code": "(input) => {\n if (!Array.isArray(input))\n return [];\n return [...new Set(input)];\n}"
},
{
"type": "Function",
"name": "$distinct",
"description": "Returns a new array with the elements of the input array with duplicates removed.",
"args": "input",
"returns": "array",
"code": "(input) => {\n if (!Array.isArray(input))\n return [];\n return [...new Set(input)];\n}"
},
{
"type": "Function",
"name": "toObject",
"description": "Create a new object based on an array of key-value pairs.",
"args": "input, val",
"returns": "any",
"code": "(input, val) => {\n if (typeof input === 'string')\n return { [input]: val };\n if (!Array.isArray(input))\n return {};\n return input.reduce((acc, kv) => {\n if (Array.isArray(kv) && kv.length === 2) {\n acc[kv[0]] = kv[1];\n return acc;\n }\n else if (typeof kv === 'string') {\n acc[kv] = val;\n return acc;\n }\n return acc;\n }, {});\n}"
},
{
"type": "Function",
"name": "$toObject",
"description": "Create a new object based on an array of key-value pairs.",
"args": "input, val",
"returns": "any",
"code": "(input, val) => {\n if (typeof input === 'string')\n return { [input]: val };\n if (!Array.isArray(input))\n return {};\n return input.reduce((acc, kv) => {\n if (Array.isArray(kv) && kv.length === 2) {\n acc[kv[0]] = kv[1];\n return acc;\n }\n else if (typeof kv === 'string') {\n acc[kv] = val;\n return acc;\n }\n return acc;\n }, {});\n}"
},
{
"type": "Function",
"name": "fromEntries",
"description": "Create a new object based on an array of key-value pairs.",
"args": "input, val",
"returns": "any",
"code": "(input, val) => {\n if (typeof input === 'string')\n return { [input]: val };\n if (!Array.isArray(input))\n return {};\n return input.reduce((acc, kv) => {\n if (Array.isArray(kv) && kv.length === 2) {\n acc[kv[0]] = kv[1];\n return acc;\n }\n else if (typeof kv === 'string') {\n acc[kv] = val;\n return acc;\n }\n return acc;\n }, {});\n}"
},
{
"type": "Function",
"name": "$fromEntries",
"description": "Create a new object based on an array of key-value pairs.",
"args": "input, val",
"returns": "any",
"code": "(input, val) => {\n if (typeof input === 'string')\n return { [input]: val };\n if (!Array.isArray(input))\n return {};\n return input.reduce((acc, kv) => {\n if (Array.isArray(kv) && kv.length === 2) {\n acc[kv[0]] = kv[1];\n return acc;\n }\n else if (typeof kv === 'string') {\n acc[kv] = val;\n return acc;\n }\n return acc;\n }, {});\n}"
},
{
"type": "Function",
"name": "mapField",
"description": "Returns a new array with the elements of the input array transformed by the specified map function.",
"args": "input, field",
"returns": "array",
"code": "(input, field) => {\n if (!Array.isArray(input))\n return [];\n return input.map