diff --git a/src/content/docs/logic-reference.md b/src/content/docs/logic-reference.md index b5edaa3..2fd207e 100644 --- a/src/content/docs/logic-reference.md +++ b/src/content/docs/logic-reference.md @@ -6,49 +6,56 @@ layout: '../../layouts/Doc.astro' order: 5 --- + + ## add Add a list of numbers together. Strings will be converted to numbers, null is treated as 0. ### Return Value -(`number`) +(`number`) ### Parameters -#### operand (`number`, `string`, `null`) +#### operand (`number`, `string`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml add: - 1 - 1 + ``` -_Returns_ +*Returns* ```json 2 ``` -_Example 2_ + +*Example 2* ```yaml add: - 1 - '1' + ``` -_Returns_ +*Returns* ```json 2 ``` -_Example 3_ + +*Example 3* ```yaml add: @@ -56,29 +63,32 @@ add: - add: - 2 - 3 + ``` -_Returns_ +*Returns* ```json 6 ``` + ## and Determines whether all arguments evaluate truthy. ### Return Value -(`boolean`) +(`boolean`) ### Parameters -#### condition (`number`, `string`, `null`, `array`, `object`, `boolean`) +#### condition (`number`, `string`, `null`, `array`, `object`, `boolean`) ### Examples -_Example 1_ + +*Example 1* ```yaml and: @@ -88,15 +98,17 @@ and: - and: - 1 - 1 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml and: @@ -106,25 +118,28 @@ and: - and: - true - true + ``` -_Returns_ +*Returns* ```json true ``` + ## concat Concatenate array or values into single array ### Parameters -#### (`number`, `string`, `null`, `array`, `object`, `boolean`) +#### (`number`, `string`, `null`, `array`, `object`, `boolean`) ### Examples -_Example 1_ + +*Example 1* ```yaml concat: @@ -134,15 +149,24 @@ concat: - 4 - - 5 - 6 + ``` -_Returns_ +*Returns* ```json -[1, 2, 3, 4, 5, 6] +[ + 1, + 2, + 3, + 4, + 5, + 6 +] ``` -_Example 2_ + +*Example 2* ```yaml concat: @@ -154,21 +178,34 @@ concat: - 6 - - 7 - 8 + ``` -_Returns_ +*Returns* ```json -[1, 2, [3, 4], 5, 6, 7, 8] +[ + 1, + 2, + [ + 3, + 4 + ], + 5, + 6, + 7, + 8 +] ``` + ## divide Divide two numbers, Logic will attempt to convert strings to numbers, null is treated as 0 ### Return Value -(`number`) +(`number`) ### Parameters @@ -178,13 +215,14 @@ Divide two numbers, Logic will attempt to convert strings to numbers, null is tr ### Examples + ## endswith -Determines whether a string ends with the characters of this search string. Number arguments are converted to strings. +Determines whether a string ends with the characters of this search string. Number arguments are converted to strings. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -194,112 +232,126 @@ Determines whether a string ends with the characters of this search string. Numb ### Examples -_Example 1_ + +*Example 1* ```yaml endswith: - Hello, friend - friend + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml endswith: - 42 - 2 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 3_ + +*Example 3* ```yaml endswith: - Hello, friend - Joe + ``` -_Returns_ +*Returns* ```json false ``` + ## equals Determines if all arguments are the same, returns true of false as appropriate. ### Return Value -(`boolean`) +(`boolean`) ### Parameters -#### (`number`, `string`, `null`, `array`, `object`, `boolean`) +#### (`number`, `string`, `null`, `array`, `object`, `boolean`) ### Examples -_Example 1_ + +*Example 1* ```yaml equals: - 1 - 1 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml equals: - true - false + ``` -_Returns_ +*Returns* ```json false ``` -_Example 3_ + +*Example 3* ```yaml equals: - 7 - 7 - 7 + ``` -_Returns_ +*Returns* ```json true ``` + ## filter Filter an array of items by a condition. When the condition evaluates true for the given item, the item is added to the returned array. ### Return Value -(`array`) +(`array`) ### Parameters @@ -307,9 +359,14 @@ Filter an array of items by a condition. When the condition evaluates true for t #### condition (`object`) +#### itemName (`string`, `null`) + +#### indexName (`string`, `null`) + ### Examples -_Example 1_ + +*Example 1* ```yaml filter: @@ -319,21 +376,99 @@ filter: - greater: - var: _item - 2 + +``` + +*Returns* + +```json +[ + 3, + 4 +] +``` + + +*Example 2* + +```yaml +filter: + - - 2 + - 3 + - 4 + - equals: + - var: _index + - 1 + +``` + +*Returns* + +```json +[ + 3 +] +``` + + +*Example 3* + +```yaml +filter: + - - banana + - apple + - mango + - endswith: + - var: fruit + - pple + - fruit + +``` + +*Returns* + +```json +[ + "apple" +] +``` + + +*Example 4* + +```yaml +filter: + - - grapple + - tackle + - scrapple + - and: + - endswith: + - var: _item + - pple + - greaterequals: + - var: position + - 1 + - null + - position + ``` -_Returns_ +*Returns* ```json -[3, 4] +[ + "scrapple" +] ``` + ## find Find an item in an array using a match condition expression. The first item in the array that matches the condition will be returned. ### Return Value -(`number`, `string`, `null`, `array`, `object`, `boolean`) +(`number`, `string`, `null`, `array`, `object`, `boolean`) ### Parameters @@ -341,9 +476,14 @@ Find an item in an array using a match condition expression. The first item in t #### condition (`object`) +#### itemName (`string`, `null`) + +#### indexName (`string`, `null`) + ### Examples -_Example 1_ + +*Example 1* ```yaml find: @@ -353,21 +493,90 @@ find: - greater: - var: _item - 2 + +``` + +*Returns* + +```json +3 +``` + + +*Example 2* + +```yaml +find: + - - 2 + - 3 + - 4 + - equals: + - var: _index + - 1 + ``` -_Returns_ +*Returns* ```json 3 ``` + +*Example 3* + +```yaml +find: + - - banana + - apple + - mango + - endswith: + - var: fruit + - pple + - fruit + +``` + +*Returns* + +```json +"apple" +``` + + +*Example 4* + +```yaml +find: + - - grapple + - tackle + - scrapple + - and: + - endswith: + - var: _item + - pple + - greaterequals: + - var: position + - 1 + - null + - position + +``` + +*Returns* + +```json +"scrapple" +``` + + ## flat Flattens nested arrays to the specied depth. ### Return Value -(`array`) +(`array`) ### Parameters @@ -377,42 +586,124 @@ Flattens nested arrays to the specied depth. ### Examples -_Example 1_ + +*Example 1* ```yaml flat: - - - - 1 - 2 - 2 + ``` -_Returns_ +*Returns* ```json -[[1], 2, 2] +[ + [ + 1 + ], + 2, + 2 +] ``` -_Example 2_ + +*Example 2* ```yaml flat: - - - - 1 - 2 + +``` + +*Returns* + +```json +[ + [ + 1 + ], + 2 +] +``` + + +## glob + +Determines whether a source path matches for any of the provided glob patterns. Returns boolean. + +### Return Value + +(`boolean`) + +### Parameters + +#### sourcePath (`number`, `string`) + +#### globPattern (`string`, `number`) + +### Examples + + +*Example 1* + +```yaml +glob: + - /santa/lives/up/north + - '**/up/north' + +``` + +*Returns* + +```json +true +``` + + +*Example 2* + +```yaml +glob: + - /santa/lives/up/north + - /santa/** + - '**/down/south' + +``` + +*Returns* + +```json +true +``` + + +*Example 3* + +```yaml +glob: + - /santa/lives/up/north + - '**/down/south' + ``` -_Returns_ +*Returns* ```json -[[1], 2] +false ``` + ## greater Determines if valueA is greater than valueB. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -422,41 +713,46 @@ Determines if valueA is greater than valueB. ### Examples -_Example 1_ + +*Example 1* ```yaml greater: - 2 - 1 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml greater: - 1 - 1 + ``` -_Returns_ +*Returns* ```json false ``` + ## greaterequals Determines if valueA is greater than or equal to valueB. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -466,55 +762,62 @@ Determines if valueA is greater than or equal to valueB. ### Examples -_Example 1_ + +*Example 1* ```yaml greaterequals: - 2 - 1 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml greaterequals: - 1 - 1 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 3_ + +*Example 3* ```yaml greaterequals: - 0 - 1 + ``` -_Returns_ +*Returns* ```json false ``` + ## has Determines if an object includes a specific key. Returns a boolean. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -524,34 +827,39 @@ Determines if an object includes a specific key. Returns a boolean. ### Examples -_Example 1_ + +*Example 1* ```yaml has: - first_name: Joe - first_name + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml has: - first_name: Joe - last_name + ``` -_Returns_ +*Returns* ```json false ``` + ## if Creates branching logic. When the first argument evaluates truthy the second argument, `ifResult` is returned, otherwise, the third, `elseResult` is returned. @@ -570,7 +878,8 @@ Creates branching logic. When the first argument evaluates truthy the second arg ### Examples -_Example 1_ + +*Example 1* ```yaml if: @@ -579,14 +888,16 @@ if: - 1 - foo - bar + ``` -_Returns_ +*Returns* ```json "foo" ``` + ## ifnot Creates branching logic. When the first argument evaluates falsy the second argument, `ifResult` is returned, otherwise, the third, `elseResult` is returned. @@ -605,13 +916,14 @@ Creates branching logic. When the first argument evaluates falsy the second argu ### Examples + ## includes determines whether an array or string contains a specified search element, returns a boolean. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -621,7 +933,8 @@ determines whether an array or string contains a specified search element, retur ### Examples -_Example 1_ + +*Example 1* ```yaml includes: @@ -629,15 +942,17 @@ includes: - 2 - 3 - 2 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml includes: @@ -645,21 +960,23 @@ includes: - 2 - 3 - 0 + ``` -_Returns_ +*Returns* ```json false ``` + ## join Creates and returns a string by concatenating all of the elements in the items array, separated by specified separator string or empty string. If the array has only one item, then that item will be returned without using the separator. ### Return Value -(`string`) +(`string`) ### Parameters @@ -669,7 +986,8 @@ Creates and returns a string by concatenating all of the elements in the items a ### Examples -_Example 1_ + +*Example 1* ```yaml join: @@ -677,36 +995,40 @@ join: - Fries - Soda - ' & ' + ``` -_Returns_ +*Returns* ```json "Hamburger & Fries & Soda" ``` -_Example 2_ + +*Example 2* ```yaml join: - - This - Or - That + ``` -_Returns_ +*Returns* ```json "ThisOrThat" ``` + ## length Returns the number of items or character in the specified array or string respectively. ### Return Value -(`number`) +(`number`) ### Parameters @@ -714,43 +1036,48 @@ Returns the number of items or character in the specified array or string respec ### Examples -_Example 1_ + +*Example 1* ```yaml length: - 0 - 1 - 2 + ``` -_Returns_ +*Returns* ```json 3 ``` -_Example 2_ + +*Example 2* ```yaml length: - foo - bar - baz + ``` -_Returns_ +*Returns* ```json 3 ``` + ## less Determines if valueA is less than valueB. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -760,34 +1087,39 @@ Determines if valueA is less than valueB. ### Examples -_Example 1_ + +*Example 1* ```yaml less: - 1 - 1 + ``` -_Returns_ +*Returns* ```json false ``` -_Example 2_ + +*Example 2* ```yaml less: - 0 - 1 + ``` -_Returns_ +*Returns* ```json true ``` + ## lessequals Determines if valueA is less than or equal to valueB. @@ -800,318 +1132,309 @@ Determines if valueA is less than or equal to valueB. ### Examples -_Example 1_ + +*Example 1* ```yaml lessequals: - 2 - 1 + ``` -_Returns_ +*Returns* ```json false ``` -_Example 2_ - -```yaml -lessequals: - - 1 - - 1 -``` - -_Returns_ - -```json -true -``` -_Example 3_ +*Example 2* ```yaml lessequals: - - 0 - 1 + - 1 + ``` -_Returns_ - -```json -true -``` - -## map - -Creates a new array populated with the results of calling a provided Logic expression on every element in the provided array. - -### Return Value - -(`array`) - -### Parameters - -#### sourceArray (`array`) - -#### logicExpression (`object`) - -### Examples - -_Example 1_ - -```yaml -map: - - - 1 - - 2 - - 3 - - add: - - var: _item - - 2 -``` - -_Returns_ - -```json -[3, 4, 5] -``` - -## match - -Determines whether a source path matches for any of the provided glob patterns. Returns boolean. - -### Return Value - -(`boolean`) - -### Parameters - -#### sourcePath (`number`, `string`) - -#### globPattern (`string`, `number`) - -### Examples - -_Example 1_ - -```yaml -match: - - /santa/lives/up/north - - '**/up/north' -``` - -_Returns_ - -```json -true -``` - -_Example 2_ - -```yaml -match: - - /santa/lives/up/north - - /santa/** - - '**/down/south' -``` - -_Returns_ +*Returns* ```json true ``` -_Example 3_ + +*Example 3* ```yaml -match: - - /santa/lives/up/north - - '**/down/south' +lessequals: + - 0 + - 1 + ``` -_Returns_ +*Returns* ```json -false +true ``` -## glob -Determines whether a source path matches for any of the provided glob patterns. Returns boolean. +## map + +Creates a new array populated with the results of calling a provided Logic expression on every element in the provided array. ### Return Value -(`boolean`) +(`array`) ### Parameters -#### sourcePath (`number`, `string`) +#### sourceArray (`array`) + +#### logicExpression (`object`) -#### globPattern (`string`, `number`) +#### itemName (`string`, `null`) + +#### indexName (`string`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml -match: - - /santa/lives/up/north - - '**/up/north' +map: + - - 1 + - 2 + - 3 + - add: + - var: _item + - 2 + ``` -_Returns_ +*Returns* ```json -true +[ + 3, + 4, + 5 +] ``` -_Example 2_ + +*Example 2* ```yaml -match: - - /santa/lives/up/north - - /santa/** - - '**/down/south' +map: + - - 1 + - 2 + - 3 + - if: + - modulo: + - var: _index + - 2 + ``` -_Returns_ +*Returns* ```json -true +[ + false, + true, + false +] ``` -_Example 3_ + +*Example 3* ```yaml -match: - - /santa/lives/up/north - - '**/down/south' +map: + - - banana + - apple + - mango + - var: s + - fruit + ``` -_Returns_ +*Returns* ```json -false +[ + "bananas", + "apples", + "mangos" +] +``` + + +*Example 4* + +```yaml +map: + - - banana + - apple + - mango + - if: + - equals: + - var: position + - 1 + - yummy + - nasty + - null + - position + +``` + +*Returns* + +```json +[ + "nasty", + "yummy", + "nasty" +] ``` + ## max Returns the largest of given values, strings are converted to numbers. Returns a number. ### Return Value -(`number`) +(`number`) ### Parameters -#### value (`number`, `string`, `null`) +#### value (`number`, `string`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml max: - 1 - 2 - 3 + ``` -_Returns_ +*Returns* ```json 3 ``` -_Example 2_ + +*Example 2* ```yaml max: - 1 - 2 - '3' + ``` -_Returns_ +*Returns* ```json 3 ``` -_Example 3_ + +*Example 3* ```yaml max: - 100 - 42 - '3' + ``` -_Returns_ +*Returns* ```json 100 ``` + ## min Returns the smallest of given values, strings are converted to numbers. Returns a number. ### Return Value -(`number`) +(`number`) ### Parameters -#### value (`number`, `string`, `null`) +#### value (`number`, `string`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml min: - 1 - 2 - 3 + ``` -_Returns_ +*Returns* ```json 1 ``` -_Example 2_ + +*Example 2* ```yaml min: - 1 - 2 - '3' + ``` -_Returns_ +*Returns* ```json 1 ``` -_Example 3_ + +*Example 3* ```yaml min: - 100 - 42 - '3' + ``` -_Returns_ +*Returns* ```json 3 ``` + ## modulo Returns the remainder after performing a division. @@ -1124,293 +1447,330 @@ Returns the remainder after performing a division. ### Examples -_Example 1_ + +*Example 1* ```yaml modulo: - 13 - 5 + ``` -_Returns_ +*Returns* ```json 3 ``` -_Example 2_ + +*Example 2* ```yaml modulo: - 1 - -2 + ``` -_Returns_ +*Returns* ```json 1 ``` -_Example 3_ + +*Example 3* ```yaml modulo: - 1 - 2 + ``` -_Returns_ +*Returns* ```json 1 ``` -_Example 4_ + +*Example 4* ```yaml modulo: - -13 - 5 + ``` -_Returns_ +*Returns* ```json -3 ``` -_Example 5_ + +*Example 5* ```yaml modulo: - -4 - 2 + ``` -_Returns_ +*Returns* ```json 0 ``` -_Example 6_ + +*Example 6* ```yaml modulo: - 5.5 - 2 + ``` -_Returns_ +*Returns* ```json 1.5 ``` + ## multiply Produces the product of the operands. ### Return Value -(`number`) +(`number`) ### Parameters -#### operand (`number`, `string`, `null`) +#### operand (`number`, `string`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml multiply: - 1 - 2 - 3 + ``` -_Returns_ +*Returns* ```json 6 ``` -_Example 2_ + +*Example 2* ```yaml multiply: - 50 - 50 - 50 + ``` -_Returns_ +*Returns* ```json 125000 ``` -_Example 3_ + +*Example 3* ```yaml multiply: - 21 - 2 + ``` -_Returns_ +*Returns* ```json 42 ``` + ## netmask Determines if an IP address is within one of the provided CIDR ranges. ### Return Value -(`boolean`) +(`boolean`) ### Parameters #### ipAddress (`string`) -#### cidr (`string`) +#### cidr (`string`) ### Examples -_Example 1_ + +*Example 1* ```yaml netmask: - 17.17.17.17 - 17.17.0.0/16 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml netmask: - 17.17.17.17 - 17.17.17.0/24 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 3_ + +*Example 3* ```yaml netmask: - 17.17.17.17 - 17.17.17.0/32 + ``` -_Returns_ +*Returns* ```json false ``` -_Example 4_ + +*Example 4* ```yaml netmask: - 17.17.17.17 - 17.17.17.0/24 - 2.0.0.0/16 + ``` -_Returns_ +*Returns* ```json true ``` + ## notequals Determines if all arguments are not the same, returns true of false as appropriate. ### Return Value -(`boolean`) +(`boolean`) ### Parameters -#### (`number`, `string`, `null`, `array`, `object`, `boolean`) +#### (`number`, `string`, `null`, `array`, `object`, `boolean`) ### Examples -_Example 1_ + +*Example 1* ```yaml notequals: - 1 - 1 + ``` -_Returns_ +*Returns* ```json false ``` -_Example 2_ + +*Example 2* ```yaml notequals: - true - false + ``` -_Returns_ +*Returns* ```json true ``` -_Example 3_ + +*Example 3* ```yaml notequals: - 7 - 7 - 42 + ``` -_Returns_ +*Returns* ```json false ``` + ## or Determines whether any of the conditions evaluate truthy. ### Return Value -(`boolean`) +(`boolean`) ### Parameters -#### condition (`number`, `string`, `null`, `array`, `object`, `boolean`) +#### condition (`number`, `string`, `null`, `array`, `object`, `boolean`) ### Examples -_Example 1_ + +*Example 1* ```yaml or: @@ -1419,15 +1779,17 @@ or: - or: - 1 - 0 + ``` -_Returns_ +*Returns* ```json true ``` -_Example 2_ + +*Example 2* ```yaml or: @@ -1436,21 +1798,23 @@ or: - or: - false - null + ``` -_Returns_ +*Returns* ```json false ``` + ## querystring Produces a list of list pairs for each entry in the provided query string. ### Return Value -(`array`) +(`array`) ### Parameters @@ -1458,29 +1822,38 @@ Produces a list of list pairs for each entry in the provided query string. ### Examples -_Example 1_ + +*Example 1* ```yaml querystring: - - '?santa=claus&bat=man' + - ?santa=claus&bat=man + ``` -_Returns_ +*Returns* ```json [ - ["santa", "claus"], - ["bat", "man"] + [ + "santa", + "claus" + ], + [ + "bat", + "man" + ] ] ``` + ## reduce Executes a "reducer" Logic expression on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value. An optional start value is passed as the initial execution of the reducer. ### Return Value -(`number`, `string`, `object`, `array`, `boolean`, `null`) +(`number`, `string`, `object`, `array`, `boolean`, `null`) ### Parameters @@ -1492,7 +1865,8 @@ Executes a "reducer" Logic expression on each element of the array, in order, pa ### Examples -_Example 1_ + +*Example 1* ```yaml reduce: @@ -1503,15 +1877,17 @@ reduce: - var: _previous - var: _current - 10 + ``` -_Returns_ +*Returns* ```json 16 ``` -_Example 2_ + +*Example 2* ```yaml reduce: @@ -1523,21 +1899,23 @@ reduce: - var: _previous - var: _current - 10 + ``` -_Returns_ +*Returns* ```json 0 ``` + ## slice Returns a portion of an array selected from start to end (end not included) where start and end represent the index of items in that array. ### Return Value -(`array`) +(`array`) ### Parameters @@ -1549,7 +1927,8 @@ Returns a portion of an array selected from start to end (end not included) wher ### Examples -_Example 1_ + +*Example 1* ```yaml slice: @@ -1558,15 +1937,19 @@ slice: - 3 - 0 - 1 + ``` -_Returns_ +*Returns* ```json -[1] +[ + 1 +] ``` -_Example 2_ + +*Example 2* ```yaml slice: @@ -1574,21 +1957,151 @@ slice: - 2 - 3 - 0 + +``` + +*Returns* + +```json +[ + 1, + 2, + 3 +] +``` + + +## sort + +Returns a new sorted array by calling a provided Logic comparison expression on the provided array. + +### Parameters + +#### sourceArray (`array`) + +#### logicExpression (`object`) + +#### prefixName (`string`) + +### Examples + + +*Example 1* + +```yaml +sort: + - - 3 + - 2 + - 5 + - 1 + - 4 + +``` + +*Returns* + +```json +[ + 1, + 2, + 3, + 4, + 5 +] +``` + + +*Example 2* + +```yaml +sort: + - - 3 + - 2 + - 5 + - 1 + - 4 + - if: + - greater: + - var: _item_a + - var: _item_b + - -1 + - 1 + +``` + +*Returns* + +```json +[ + 5, + 4, + 3, + 2, + 1 +] +``` + + +*Example 3* + +```yaml +sort: + - - mango + - apple + - pear + - banana + +``` + +*Returns* + +```json +[ + "apple", + "banana", + "mango", + "pear" +] +``` + + +*Example 4* + +```yaml +sort: + - - mango + - apple + - pear + - banana + - if: + - greater: + - var: fruit_a + - var: fruit_b + - -1 + - 1 + - fruit + ``` -_Returns_ +*Returns* ```json -[1, 2, 3] +[ + "pear", + "mango", + "banana", + "apple" +] ``` + ## startswith Determines whether a string starts with the characters of this search string. Number arguments are converted to strings. ### Return Value -(`boolean`) +(`boolean`) ### Parameters @@ -1598,55 +2111,62 @@ Determines whether a string starts with the characters of this search string. Nu ### Examples -_Example 1_ + +*Example 1* ```yaml endswith: - Hello, friend - Hello + ``` -_Returns_ +*Returns* ```json false ``` -_Example 2_ + +*Example 2* ```yaml endswith: - 42 - 4 + ``` -_Returns_ +*Returns* ```json false ``` -_Example 3_ + +*Example 3* ```yaml endswith: - Hello, friend - friend + ``` -_Returns_ +*Returns* ```json true ``` + ## substring Returns a portion of a string selected from start to end (end not included) where start and end represent the index of character in that string, starting from 0. ### Return Value -(`string`) +(`string`) ### Parameters @@ -1656,40 +2176,44 @@ Returns a portion of a string selected from start to end (end not included) wher #### rangeEnd (`number`, `string`) -#### (`number`, `string`) +#### (`number`, `string`) ### Examples + ## subtract Subtracts a list of numbers in sequence from first to last. Strings will be converted to numbers, null is treated as 0. ### Return Value -(`number`) +(`number`) ### Parameters -#### (`number`, `string`, `null`) +#### (`number`, `string`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml subtract: - 5 - 3 - 2 + ``` -_Returns_ +*Returns* ```json 0 ``` -_Example 2_ + +*Example 2* ```yaml subtract: @@ -1698,58 +2222,82 @@ subtract: - 12 - 3 - 2 + ``` -_Returns_ +*Returns* ```json -7 ``` + +## undefined + +undefined + +### Parameters + +#### (`string`) + +### Examples + + ## unique Produces a list of items with all duplicate values reduced to a single instance. ### Return Value -(`array`) +(`array`) ### Parameters -#### item (`number`, `string`, `object`, `array`, `boolean`, `null`) +#### item (`number`, `string`, `object`, `array`, `boolean`, `null`) ### Examples -_Example 1_ + +*Example 1* ```yaml unique: - banana - banana - pear + ``` -_Returns_ +*Returns* ```json -["banana", "pear"] +[ + "banana", + "pear" +] ``` -_Example 2_ + +*Example 2* ```yaml unique: - banana - pear + ``` -_Returns_ +*Returns* ```json -["banana", "pear"] +[ + "banana", + "pear" +] ``` -_Example 3_ + +*Example 3* ```yaml unique: @@ -1758,21 +2306,26 @@ unique: - banana - mango - mango + ``` -_Returns_ +*Returns* ```json -["banana", "mango"] +[ + "banana", + "mango" +] ``` + ## useragent Parses a user agent string constructing an object with user agent data separated into individual object properties ### Return Value -_useragent_: (`object`) Object with user agent data organized by individual property +*useragent*: (`object`) Object with user agent data organized by individual property ```json { @@ -1822,22 +2375,24 @@ _useragent_: (`object`) Object with user agent data organized by individual prop } ``` + ### Parameters #### userAgentString (`string`) ### Examples -_Example 1_ + +*Example 1* ```yaml useragent: - - >- - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) + - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2 + ``` -_Returns_ +*Returns* ```json { @@ -1862,6 +2417,7 @@ _Returns_ } ``` + ## var Retrieves the value of a given variable path, sub-indexes separated with ".". Optionally provide a data object for which to access the variable path from. @@ -1874,38 +2430,45 @@ Retrieves the value of a given variable path, sub-indexes separated with ".". Op ### Examples -_Example 1_ + +*Example 1* ```yaml var: _item + ``` -_Returns_ +*Returns* ```json "doorknob" ``` -_Example 2_ + +*Example 2* ```yaml var: $request.content-type + ``` -_Returns_ +*Returns* ```json "application/html" ``` -_Example 3_ + +*Example 3* ```yaml var: fancy.thing + ``` -_Returns_ +*Returns* ```json "snow globe" ``` +