From 48fa440fa1bf9519b08e07a69eeacab216c3e49a Mon Sep 17 00:00:00 2001 From: Maxime Labelle Date: Thu, 20 Oct 2022 21:57:48 +0200 Subject: [PATCH] Simplified syntax where possible. --- functions/abs.yml | 3 +-- functions/avg.yml | 3 +-- functions/ceil.yml | 5 +---- functions/contains.yml | 7 ++----- functions/ends_with.yml | 8 ++------ functions/floor.yml | 5 +---- functions/from_items.yml | 1 - functions/group_by.yml | 8 ++------ functions/items.yml | 7 ++----- functions/join.yml | 8 ++------ functions/keys.yml | 5 +---- functions/length.yml | 3 --- functions/let.yml | 7 ++----- functions/map.yml | 8 ++------ functions/max.yml | 3 --- functions/max_by.yml | 6 +----- functions/merge.yml | 10 +++------- functions/min.yml | 3 --- functions/min_by.yml | 6 +----- functions/not_null.yml | 10 +++------- functions/reverse.yml | 3 --- functions/sort.yml | 3 --- functions/sort_by.yml | 6 +----- functions/starts_with.yml | 8 ++------ functions/sum.yml | 5 +---- functions/to_array.yml | 5 +---- functions/to_number.yml | 5 +---- functions/to_string.yml | 5 +---- functions/type.yml | 5 +---- functions/values.yml | 5 +---- functions/zip.yml | 8 ++------ 31 files changed, 38 insertions(+), 136 deletions(-) diff --git a/functions/abs.yml b/functions/abs.yml index d303bc5..a8be7e3 100644 --- a/functions/abs.yml +++ b/functions/abs.yml @@ -3,9 +3,8 @@ topic: math args: required: - name: value - type: [number] + type: number desc: positive or negative number - optional: [] returns: type: number desc: positive magnitude of input value diff --git a/functions/avg.yml b/functions/avg.yml index c2a25c6..78b1f4f 100644 --- a/functions/avg.yml +++ b/functions/avg.yml @@ -3,9 +3,8 @@ topic: math args: required: - name: elements - type: ['array[number]'] + type: 'array[number]' desc: array of numbers to calculate average from - optional: [] returns: type: [number, 'null'] desc: average value of passed elements diff --git a/functions/ceil.yml b/functions/ceil.yml index 7cddcab..ae5a081 100644 --- a/functions/ceil.yml +++ b/functions/ceil.yml @@ -3,12 +3,9 @@ topic: math args: required: - name: value - type: [number] - desc: '' - optional: [] + type: number returns: type: number - desc: '' desc: | Returns the next highest integer value by rounding up if necessary. examples: diff --git a/functions/contains.yml b/functions/contains.yml index 00bb492..6237a63 100644 --- a/functions/contains.yml +++ b/functions/contains.yml @@ -4,14 +4,11 @@ args: required: - name: subject type: [array, string] - desc: '' - name: search - type: [any] - desc: '' - optional: [] + type: any + returns: type: boolean - desc: '' desc: | Returns `true` if the given `$subject` contains the provided `$search` string. diff --git a/functions/ends_with.yml b/functions/ends_with.yml index a431bde..2187bb6 100644 --- a/functions/ends_with.yml +++ b/functions/ends_with.yml @@ -3,15 +3,11 @@ topic: strings args: required: - name: subject - type: [string] - desc: '' + type: string - name: prefix - type: [string] - desc: '' - optional: [] + type: string returns: type: boolean - desc: '' desc: | Returns `true` if the `$subject` ends with the `$prefix`, otherwise this function returns `false`. diff --git a/functions/floor.yml b/functions/floor.yml index 7753fe1..fb22199 100644 --- a/functions/floor.yml +++ b/functions/floor.yml @@ -3,12 +3,9 @@ topic: math args: required: - name: value - type: [number] - desc: '' - optional: [] + type: number returns: type: number - desc: '' desc: | Returns the next lowest integer value by rounding down if necessary. examples: diff --git a/functions/from_items.yml b/functions/from_items.yml index cde756e..61f59ed 100644 --- a/functions/from_items.yml +++ b/functions/from_items.yml @@ -5,7 +5,6 @@ args: - name: arg type: ['array[any]'] desc: '' - optional: [] returns: type: [object] desc: '' diff --git a/functions/group_by.yml b/functions/group_by.yml index 866c075..efed314 100644 --- a/functions/group_by.yml +++ b/functions/group_by.yml @@ -3,15 +3,11 @@ topic: collections args: required: - name: elements - type: ['array[object]'] - desc: '' + type: 'array[object]' - name: expr - type: [expression->string] - desc: '' - optional: [] + type: expression->string returns: type: object - desc: '' desc: | Groups an array of objects `$elements` using an expression `$expr` as the group key. The `$expr` expression is applied to each element in the array `$elements` and the diff --git a/functions/items.yml b/functions/items.yml index 3012df7..1f20715 100644 --- a/functions/items.yml +++ b/functions/items.yml @@ -3,12 +3,9 @@ topic: misc args: required: - name: obj - type: [object] - desc: '' - optional: [] + type: object returns: - type: ['array[any]'] - desc: '' + type: 'array[any]' desc: |2 Returns an array of key-value pairs for the provided input object. Each pair is a 2-item array with the first item being the key and diff --git a/functions/join.yml b/functions/join.yml index 54dbf2e..3330780 100644 --- a/functions/join.yml +++ b/functions/join.yml @@ -3,15 +3,11 @@ topic: collections args: required: - name: glue - type: [string] - desc: '' + type: string - name: stringsarray - type: ['array[string]'] - desc: '' - optional: [] + type: 'array[string]' returns: type: string - desc: '' desc: | Returns all of the elements from the provided `$stringsarray` array joined together using the `$glue` argument as a separator between each. diff --git a/functions/keys.yml b/functions/keys.yml index 4010345..66d9bbb 100644 --- a/functions/keys.yml +++ b/functions/keys.yml @@ -3,12 +3,9 @@ topic: collections args: required: - name: obj - type: [object] - desc: '' - optional: [] + type: object returns: type: array - desc: '' desc: | Returns an array containing the keys of the provided object. Note that because JSON hashes are inheritently unordered, the diff --git a/functions/length.yml b/functions/length.yml index f763c9f..8b27a06 100644 --- a/functions/length.yml +++ b/functions/length.yml @@ -4,11 +4,8 @@ args: required: - name: subject type: [string, array, object] - desc: '' - optional: [] returns: type: number - desc: '' desc: | Returns the length of the given argument using the following types rules: diff --git a/functions/let.yml b/functions/let.yml index 46295c2..4c6a7d3 100644 --- a/functions/let.yml +++ b/functions/let.yml @@ -3,14 +3,11 @@ topic: misc args: required: - name: scope - type: [object] - desc: '' + type: object - name: expr - type: ['expression->any'] - optional: [] + type: 'expression->any' returns: type: any - desc: '' desc: | Captures the current evaluation context in a child lexical scope. diff --git a/functions/map.yml b/functions/map.yml index 07c6812..f401232 100644 --- a/functions/map.yml +++ b/functions/map.yml @@ -3,15 +3,11 @@ topic: collections args: required: - name: expr - type: [expression] - desc: '' + type: expression - name: elements - type: ['array[any]'] - desc: '' - optional: [] + type: 'array[any]' returns: type: array[any] - desc: '' desc: | Apply the `expr` to every element in the `elements` array and return the array of results. An `elements` of length diff --git a/functions/max.yml b/functions/max.yml index 0488f42..0f0b8c9 100644 --- a/functions/max.yml +++ b/functions/max.yml @@ -4,11 +4,8 @@ args: required: - name: collection type: ['array[number]', 'array[string]'] - desc: '' - optional: [] returns: type: number - desc: '' desc: | Returns the highest found number in the provided array argument. diff --git a/functions/max_by.yml b/functions/max_by.yml index 87f1155..0c8a94b 100644 --- a/functions/max_by.yml +++ b/functions/max_by.yml @@ -3,15 +3,11 @@ topic: math args: required: - name: elements - type: [array] - desc: '' + type: array - name: expr type: [expression->number, expression->string] - desc: '' - optional: [] returns: type: any - desc: '' desc: | Return the maximum element in an array using the expression `expr` as the comparison key. The entire maximum element is returned. diff --git a/functions/merge.yml b/functions/merge.yml index f43d5b5..5230bf0 100644 --- a/functions/merge.yml +++ b/functions/merge.yml @@ -3,15 +3,11 @@ topic: collections args: required: - name: argument - type: [object] - desc: '' - optional: - - name: .. - type: [object] - desc: '' + type: object + variadic: + type: object returns: type: object - desc: '' desc: | Accepts 0 or more objects as arguments, and returns a single object with subsequent objects merged. Each subsequent object’s key/value diff --git a/functions/min.yml b/functions/min.yml index 7db770f..884649f 100644 --- a/functions/min.yml +++ b/functions/min.yml @@ -4,11 +4,8 @@ args: required: - name: collection type: ['array[number]', 'array[string]'] - desc: '' - optional: [] returns: type: number - desc: '' desc: | Returns the lowest found number in the provided `$collection` argument. examples: diff --git a/functions/min_by.yml b/functions/min_by.yml index 2a76b08..1c8eab2 100644 --- a/functions/min_by.yml +++ b/functions/min_by.yml @@ -3,15 +3,11 @@ topic: math args: required: - name: elements - type: [array] - desc: '' + type: array - name: expr type: [expression->number, expression->string] - desc: '' - optional: [] returns: type: any - desc: '' desc: | Return the minimum element in an array using the expression `expr` as the comparison key. The entire maximum element is returned. diff --git a/functions/not_null.yml b/functions/not_null.yml index a998d26..fadc7c8 100644 --- a/functions/not_null.yml +++ b/functions/not_null.yml @@ -3,15 +3,11 @@ topic: misc args: required: - name: argument - type: [any] - desc: '' - optional: - - name: .. - type: [any] - desc: '' + type: any + variadic: + type: any returns: type: any - desc: '' desc: | Returns the first argument that does not resolve to `null`. This function accepts one or more arguments, and will evaluate them in order until a diff --git a/functions/reverse.yml b/functions/reverse.yml index 1f6e3bb..79aa48c 100644 --- a/functions/reverse.yml +++ b/functions/reverse.yml @@ -4,11 +4,8 @@ args: required: - name: argument type: [string, array] - desc: '' - optional: [] returns: type: array - desc: '' desc: | Reverses the order of the `$argument`. examples: diff --git a/functions/sort.yml b/functions/sort.yml index e82abce..f476e92 100644 --- a/functions/sort.yml +++ b/functions/sort.yml @@ -4,11 +4,8 @@ args: required: - name: list type: ['array[number]', 'array[string]'] - desc: '' - optional: [] returns: type: array - desc: '' desc: | This function accepts an array `$list` argument and returns the sorted elements of the `$list` as an array. diff --git a/functions/sort_by.yml b/functions/sort_by.yml index f63ec06..f4be515 100644 --- a/functions/sort_by.yml +++ b/functions/sort_by.yml @@ -3,15 +3,11 @@ topic: collections args: required: - name: elements - type: [array] - desc: '' + type: array - name: expr type: [expression->number, expression->string] - desc: '' - optional: [] returns: type: array - desc: '' desc: | Sort an array using an expression `expr` as the sort key. For each element in the array of `elements`, the `expr` expression is applied and the diff --git a/functions/starts_with.yml b/functions/starts_with.yml index ba50011..7b33e5d 100644 --- a/functions/starts_with.yml +++ b/functions/starts_with.yml @@ -3,15 +3,11 @@ topic: strings args: required: - name: subject - type: [string] - desc: '' + type: string - name: prefix - type: [string] - desc: '' - optional: [] + type: string returns: type: boolean - desc: '' desc: | Returns `true` if the `$subject` starts with the `$prefix`, otherwise this function returns `false`. diff --git a/functions/sum.yml b/functions/sum.yml index d4bca7a..4684399 100644 --- a/functions/sum.yml +++ b/functions/sum.yml @@ -3,12 +3,9 @@ topic: math args: required: - name: collection - type: ['array[number]'] - desc: '' - optional: [] + type: 'array[number]' returns: type: number - desc: '' desc: | Returns the sum of the provided array argument. diff --git a/functions/to_array.yml b/functions/to_array.yml index ef48355..ce84ad1 100644 --- a/functions/to_array.yml +++ b/functions/to_array.yml @@ -3,12 +3,9 @@ topic: conversion args: required: - name: arg - type: [any] - desc: '' - optional: [] + type: any returns: type: array - desc: '' desc: | * array - Returns the passed in value. * number/string/object/boolean/null - Returns a one element array containing diff --git a/functions/to_number.yml b/functions/to_number.yml index 90ccac2..86101bf 100644 --- a/functions/to_number.yml +++ b/functions/to_number.yml @@ -3,12 +3,9 @@ topic: conversion args: required: - name: arg - type: [any] - desc: '' - optional: [] + type: any returns: type: number - desc: '' desc: | * string - Returns the parsed number. Any string that conforms to the `json-number` production is supported. Note that the floating number diff --git a/functions/to_string.yml b/functions/to_string.yml index e042150..8ab7d6d 100644 --- a/functions/to_string.yml +++ b/functions/to_string.yml @@ -3,12 +3,9 @@ topic: conversion args: required: - name: arg - type: [any] - desc: '' - optional: [] + type: any returns: type: string - desc: '' desc: |2 * string - Returns the passed in value. diff --git a/functions/type.yml b/functions/type.yml index 503b10e..f313004 100644 --- a/functions/type.yml +++ b/functions/type.yml @@ -3,12 +3,9 @@ topic: misc args: required: - name: subject - type: [array, object, string, number, boolean, 'null'] - desc: '' - optional: [] + type: any returns: type: string - desc: '' desc: | Returns the JavaScript type of the given `$subject` argument as a string value. diff --git a/functions/values.yml b/functions/values.yml index edcff60..b831c27 100644 --- a/functions/values.yml +++ b/functions/values.yml @@ -3,12 +3,9 @@ topic: collections args: required: - name: obj - type: [object] - desc: '' - optional: [] + type: object returns: type: array - desc: '' desc: | Returns the values of the provided object. Note that because JSON hashes are inheritently unordered, the diff --git a/functions/zip.yml b/functions/zip.yml index f5d0d0d..25d5502 100644 --- a/functions/zip.yml +++ b/functions/zip.yml @@ -3,15 +3,11 @@ topic: misc args: required: - name: arg - type: ['array[any]'] - desc: '' + type: 'array[any]' variadic: - type: ['array[any]'] - desc: '' - optional: [] + type: 'array[any]' returns: type: ['array[array[any]]'] - desc: '' desc: |2 Accepts one or more arrays as arguments and returns an array of arrays in which the _i-th_ array contains the _i-th_ element from each of the