arrays

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(_ context.Context, args ...core.Value) (core.Value, error)

APPEND appends a new item to an array and returns a new array with a given element. If “uniqueOnly“ is set to true, then will add the item only if it's unique. @param {Any[]} arr - Target array. @param {Any} item - Target value to add. @return {Any[]} - New array.

func First

func First(_ context.Context, args ...core.Value) (core.Value, error)

FIRST returns a first element from a given array. @param {Any[]} arr - Target array. @return {Any} - First element in a given array.

func Flatten

func Flatten(_ context.Context, args ...core.Value) (core.Value, error)

FLATTEN turns an array of arrays into a flat array. All array elements in array will be expanded in the result array. Non-array elements are added as they are. The function will recurse into sub-arrays up to the specified depth. Duplicates will not be removed. @param {Any[]} arr - Target array. @param {Int} [depth] - Depth level. @return {Any[]} - Flat array.

func Intersection

func Intersection(_ context.Context, args ...core.Value) (core.Value, error)

INTERSECTION return the intersection of all arrays specified. The result is an array of values that occur in all arguments. The element order is random. Duplicates are removed. @param {Any[], repeated} arrays - An arbitrary number of arrays as multiple arguments (at least 2). @return {Any[]} - A single array with only the elements, which exist in all provided arrays.

func Last

func Last(_ context.Context, args ...core.Value) (core.Value, error)

LAST returns the last element of an array. @param {Any[]} array - The target array. @return {Any} - Last element of an array.

func Minus

func Minus(_ context.Context, args ...core.Value) (core.Value, error)

MINUS return the difference of all arrays specified. The order of the result array is undefined and should not be relied on. Duplicates will be removed. @param {Any[], repeated} arrays - An arbitrary number of arrays as multiple arguments (at least 2). @return {Any[]} - An array of values that occur in the first array, but not in any of the subsequent arrays.

func Nth

func Nth(_ context.Context, args ...core.Value) (core.Value, error)

NTH returns the element of an array at a given position. It is the same as anyArray[position] for positive positions, but does not support negative positions. If position is negative or beyond the upper bound of the array, then NONE will be returned. @param {Any[]} array - An array with elements of arbitrary type. @param {Int} index - Position of desired element in array, positions start at 0. @return {Any} - The array element at the given position.

func Outersection

func Outersection(_ context.Context, args ...core.Value) (core.Value, error)

OUTERSECTION return the values that occur only once across all arrays specified. The element order is random. @param {Any[], repeated} arrays - An arbitrary number of arrays as multiple arguments (at least 2). @return {Any[]} - A single array with only the elements that exist only once across all provided arrays.

func Pop

func Pop(_ context.Context, args ...core.Value) (core.Value, error)

POP returns a new array without last element. @param {Any[]} array - Target array. @return {Any[]} - Copy of an array without last element.

func Position

func Position(_ context.Context, args ...core.Value) (core.Value, error)

POSITION returns a value indicating whether an element is contained in array. Optionally returns its position. @param {Any[]} array - The source array. @param {Any} value - The target value. @param {Boolean} [position=False] - Boolean value which indicates whether to return item's position. @return {Boolean | Int} - A value indicating whether an element is contained in array.

func Push

func Push(_ context.Context, args ...core.Value) (core.Value, error)

PUSH create a new array with appended value. @param {Any[]} array - Source array. @param {Any} value - Target value. @param {Boolean} [unique=False] - Read indicating whether to do uniqueness check. @return {Any[]} - A new array with appended value.

func RegisterLib added in v0.8.0

func RegisterLib(ns core.Namespace) error

func RemoveNth

func RemoveNth(_ context.Context, args ...core.Value) (core.Value, error)

REMOVE_NTH returns a new array without an element by a given position. @param {Any[]} array - Source array. @param {Int} position - Target element position. @return {Any[]} - A new array without an element by a given position.

func RemoveValue

func RemoveValue(_ context.Context, args ...core.Value) (core.Value, error)

REMOVE_VALUE returns a new array with removed all occurrences of value in a given array. Optionally with a limit to the number of removals. @param {Any[]} array - Source array. @param {Any} value - Target value. @param {Int} [limit] - A limit to the number of removals. @return {Any[]} - A new array with removed all occurrences of value in a given array.

func RemoveValues

func RemoveValues(_ context.Context, args ...core.Value) (core.Value, error)

REMOVE_VALUES returns a new array with removed all occurrences of values in a given array. @param {Any[]} array - Source array. @param {Any[]} values - Target values. @return {Any[]} - A new array with removed all occurrences of values in a given array.

func Shift

func Shift(_ context.Context, args ...core.Value) (core.Value, error)

SHIFT returns a new array without the first element. @param {Any[]} array - Target array. @return {Any[]} - Copy of an array without the first element.

func Slice

func Slice(_ context.Context, args ...core.Value) (core.Value, error)

SLICE returns a new sliced array. @param {Any[]} array - Source array. @param {Int} start - Start position of extraction. @param {Int} [length] - Read indicating how many elements to extract. @return {Any[]} - Sliced array.

func Sorted

func Sorted(_ context.Context, args ...core.Value) (core.Value, error)

SORTED sorts all elements in anyArray. The function will use the default comparison order for FQL value types. @param {Any[]} array - Target array. @return {Any[]} - Sorted array.

func SortedUnique

func SortedUnique(_ context.Context, args ...core.Value) (core.Value, error)

SORTED_UNIQUE sorts all elements in anyArray. The function will use the default comparison order for FQL value types. Additionally, the values in the result array will be made unique @param {Any[]} array - Target array. @return {Any[]} - Sorted array.

func ToUniqueArray added in v0.5.0

func ToUniqueArray(arr *values.Array) *values.Array

func Union

func Union(_ context.Context, args ...core.Value) (core.Value, error)

UNION returns the union of all passed arrays. @param {Any[], repeated} arrays - List of arrays to combine. @return {Any[]} - All array elements combined in a single array, in any order.

func UnionDistinct

func UnionDistinct(_ context.Context, args ...core.Value) (core.Value, error)

UNION_DISTINCT returns the union of all passed arrays with unique values. @param {Any[], repeated} arrays - List of arrays to combine. @return {Any[]} - All unique array elements combined in a single array, in any order.

func Unique

func Unique(_ context.Context, args ...core.Value) (core.Value, error)

UNIQUE returns all unique elements from a given array. @param {Any[]} array - Target array. @return {Any[]} - New array without duplicates.

func Unshift

func Unshift(_ context.Context, args ...core.Value) (core.Value, error)

UNSHIFT prepends value to a given array. @param {Any[]} array - Target array. @param {Any} value - Target value to prepend. @param {Boolean} [unique=False] - Optional value indicating whether a value must be unique to be prepended. Default is false. @return {Any[]} - New array with prepended value.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL