std@0.147.0/collections/mod.ts

Deno standard library
Go to Latest
mod.ts (default module)
c
BinaryHeap
c
BSTree
c
RBTree
f
aggregateGroups
f
ascend
f
associateBy
f
associateWith
f
chunk
f
deepMerge
f
descend
f
distinct
f
distinctBy
f
dropLastWhile
f
dropWhile
f
filterEntries
f
filterKeys
f
filterValues
f
findSingle
f
firstNotNullishOf
f
groupBy
f
includesValue
f
intersect
f
joinToString
f
mapEntries
f
mapKeys
f
mapNotNullish
f
mapValues
f
maxBy
f
maxOf
f
maxWith
f
minBy
f
minOf
f
minWith
f
partition
f
permutations
f
reduceGroups
f
runningReduce
f
sample
f
slidingWindows
f
sortBy
f
sumOf
f
takeLastWhile
f
takeWhile
f
union
f
unzip
f
withoutAll
f
zip
T
DeepMerge
T
DeepMergeOptions
T
JoinToStringOptions
T
MergingStrategy
aggregate_groups.ts
f
aggregateGroups
associate_by.ts
f
associateBy
associate_with.ts
f
associateWith
binary_heap.ts
c
BinaryHeap
f
ascend
f
descend
binary_search_node.ts
c
BinarySearchNode
T
Direction
binary_search_tree.ts
c
BinarySearchTree
f
ascend
f
descend
bs_node.ts
c
BSNode
T
direction
T
Direction
bs_tree.ts
c
BSTree
f
ascend
f
descend
chunk.ts
f
chunk
deep_merge.ts
f
deepMerge
T
DeepMerge
T
DeepMergeOptions
T
MergingStrategy
distinct_by.ts
f
distinctBy
distinct.ts
f
distinct
drop_last_while.ts
f
dropLastWhile
drop_while.ts
f
dropWhile
filter_entries.ts
f
filterEntries
filter_keys.ts
f
filterKeys
filter_values.ts
f
filterValues
find_single.ts
f
findSingle
first_not_nullish_of.ts
f
firstNotNullishOf
group_by.ts
f
groupBy
includes_value.ts
f
includesValue
intersect.ts
f
intersect
join_to_string.ts
f
joinToString
T
JoinToStringOptions
map_entries.ts
f
mapEntries
map_keys.ts
f
mapKeys
map_not_nullish.ts
f
mapNotNullish
map_values.ts
f
mapValues
max_by.ts
f
maxBy
max_of.ts
f
maxOf
max_with.ts
f
maxWith
min_by.ts
f
minBy
min_of.ts
f
minOf
min_with.ts
f
minWith
partition.ts
f
partition
permutations.ts
f
permutations
rb_node.ts
c
RBNode
T
direction
T
Direction
rb_tree.ts
c
RBTree
f
ascend
f
descend
red_black_node.ts
c
RedBlackNode
T
direction
T
Direction
red_black_tree.ts
c
RedBlackTree
f
ascend
f
descend
reduce_groups.ts
f
reduceGroups
running_reduce.ts
f
runningReduce
sample.ts
f
sample
sliding_windows.ts
f
slidingWindows
sort_by.ts
f
sortBy
sum_of.ts
f
sumOf
take_last_while.ts
f
takeLastWhile
take_while.ts
f
takeWhile
union.ts
f
union
unzip.ts
f
unzip
without_all.ts
f
withoutAll
zip.ts
f
zip
import * as mod from "https://deno.land/std@0.147.0/collections/mod.ts";

This module includes pure functions for specific common tasks around collection types like Array and Record.

Classes

A priority queue implemented with a binary heap. The heap is in decending order by default, using JavaScript's built in comparison operators to sort the values.

An unbalanced binary search tree. The values are in ascending order by default, using JavaScript's built in comparison operators to sort the values.

A red-black tree. This is a kind of self-balancing binary search tree. The values are in ascending order by default, using JavaScript's built in comparison operators to sort the values.

Functions

Applies the given aggregator to each group in the given Grouping, returning the results together with the respective group keys

Compares its two arguments for ascending order using JavaScript's built in comparison operators.

Transforms the given array into a Record, extracting the key of each element using the given selector. If the selector produces the same key for multiple elements, the latest one will be used (overriding the ones before it).

Builds a new Record using the given array as keys and choosing a value for each key using the given selector. If any of two pairs would have the same value the latest on will be used (overriding the ones before it).

Splits the given array into chunks of the given size and returns them

Merges the two given Records, recursively merging any nested Records with the second collection overriding the first in case of conflict

Compares its two arguments for descending order using JavaScript's built in comparison operators.

Returns all distinct elements in the given array, preserving order by first occurrence

Returns all elements in the given array that produce a distinct value using the given selector, preserving order by first occurrence

Returns a new array that drops all elements in the given collection until the last element that does not match the given predicate

Returns a new array that drops all elements in the given collection until the first element that does not match the given predicate

Returns a new record with all entries of the given record except the ones that do not match the given predicate

Returns a new record with all entries of the given record except the ones that have a key that does not match the given predicate

Returns a new record with all entries of the given record except the ones that have a value that does not match the given predicate

Returns an element if and only if that element is the only one matching the given condition. Returns undefined otherwise.

Applies the given selector to elements in the given array until a value is produced that is neither null nor undefined and returns that value Returns undefined if no such value is produced

Applies the given selector to each element in the given array, returning a Record containing the results as keys and all values that produced that key as values.

If the given value is part of the given object it returns true, otherwise it returns false. Doesn't work with non-primitive values: includesValue({x: {}}, {}) returns false.

Returns all distinct elements that appear at least once in each of the given arrays

Transforms the elements in the given array to strings using the given selector. Joins the produced strings into one using the given separator and applying the given prefix and suffix to the whole string afterwards. If the array could be huge, you can specify a non-negative value of limit, in which case only the first limit elements will be appended, followed by the truncated string. Returns the resulting string.

Applies the given transformer to all entries in the given record and returns a new record containing the results

Applies the given transformer to all keys in the given record's entries and returns a new record containing the transformed entries.

Returns a new array, containing all elements in the given array transformed using the given transformer, except the ones that were transformed to null or undefined

Applies the given transformer to all values in the given record and returns a new record containing the resulting keys associated to the last value that produced them.

Returns the first element that is the largest value of the given function or undefined if there are no elements.

Applies the given selector to all elements of the given collection and returns the max value of all elements. If an empty array is provided the function will return undefined

Returns the first element having the largest value according to the provided comparator or undefined if there are no elements.

Returns the first element that is the smallest value of the given function or undefined if there are no elements.

Applies the given selector to all elements of the given collection and returns the min value of all elements. If an empty array is provided the function will return undefined

Returns the first element having the smallest value according to the provided comparator or undefined if there are no elements

Returns a tuple of two arrays with the first one containing all elements in the given array that match the given predicate and the second one containing all that do not

Builds all possible orders of all elements in the given array Ignores equality of elements, meaning this will always return the same number of permutations for a given length of input.

Applies the given reducer to each group in the given Grouping, returning the results together with the respective group keys

Calls the given reducer on each element of the given collection, passing it's result as the accumulator to the next respective call, starting with the given initialValue. Returns all intermediate accumulator results.

Returns a random element from the given array.

Generates sliding views of the given array of the given size and returns a new array containing all of them.

Returns all elements in the given collection, sorted stably by their result using the given selector. The selector function is called only once for each element.

Applies the given selector to all elements in the given collection and calculates the sum of the results

Returns all elements in the given array after the last element that does not match the given predicate.

Returns all elements in the given collection until the first element that does not match the given predicate.

Returns all distinct elements that appear in any of the given arrays

Builds two separate arrays from the given array of 2-tuples, with the first returned array holding all first tuple elements and the second one holding all the second elements

Returns an array excluding all given values.

Type Aliases

Merge deeply two objects

Deep merge options

Options for joinToString

Merging strategy