Heap instance constructor.
OptionalcompareOrOptions: AsyncComparator<T> | HeapAsyncOptions<T>Optional comparison function or options object
Alias of peek
Alias of add
Alias of pop
Length of the heap.
Get length limit of the heap.
Set length limit of the heap. The limit is applied lazily on the next add() or eagerly via setLimit().
Limit value. Negative, Infinity, or NaN set the limit to 0.
Async iterator interface. Iterates in order of priority without consuming the heap. Same as sortedIterator. Use drain to consume it.
Returns the comparison function.
Returns true if this queue contains the specified element.
Element to be found
Optionalfn: AsyncIsEqual<T>Optional comparison function, receives (element, needle)
Get the index of the first occurrence of the element in the heap.
Element to be found
OptionalcallbackFn: AsyncIsEqual<T>Optional comparison function, receives (element, needle)
Index or -1 if not found
Get the indexes of every occurrence of the element in the heap.
Element to be found
OptionalcallbackFn: AsyncIsEqual<T>Optional comparison function, receives (element, needle)
Array of indexes or empty array if not found
Remove an element from the heap.
Optionalo: TElement to be found
Optionalfn: AsyncIsEqual<T>Optional function to compare
True if the heap was modified
Set length limit of the heap with async limit application. Same as assigning to limit but awaits eviction and returns NaN if the value was invalid.
Limit. Negative, Infinity, or NaN values set the limit to 0.
The limit or NaN if the value was negative, or NaN.
Iterates over the heap in order of priority without consuming or modifying it. Lazy: the first k elements cost O(k log k), regardless of the heap size. Throws if the heap length changes while iterating; use drain to push while consuming.
StaticdefaultStaticgetStaticgetStaticgetStaticheapbottomReturn the n least valuable elements of a heap-like Array
Array, should be an array-heap
Max number of elements
Optionalcompare: AsyncComparator<N>Optional compare function
Elements
StaticheapifyConverts an array into an array-heap, in place
Array to be modified
Optionalcompare: AsyncComparator<N>Optional compare function
For convenience, it returns a Heap instance
StaticheappopExtract the peek of an array-heap
Array to be modified, should be a heap
Optionalcompare: AsyncComparator<N>Optional compare function
Returns the extracted peek
StaticheappushPushes a item into an array-heap
Array to be modified, should be a heap
Item to push
Optionalcompare: AsyncComparator<N>Optional compare function
StaticheappushpopPush followed by pop, faster
Array to be modified, should be a heap
Item to push
Optionalcompare: AsyncComparator<N>Optional compare function
Returns the extracted peek
StaticheapreplaceReplace peek with item
Array to be modified, should be a heap
Item as replacement
Optionalcompare: AsyncComparator<N>Optional compare function
Returns the extracted peek
StaticheaptopReturn the n most valuable elements of a heap-like Array
Array, should be an array-heap
Max number of elements
Optionalcompare: AsyncComparator<N>Optional compare function
Elements
StaticmaxStaticmaxStaticminStaticminStaticnlargestReturn the n most valuable elements of an iterable
Max number of elements
Optionalcompare: AsyncComparator<N>Optional compare function
Elements
StaticnsmallestReturn the n least valuable elements of an iterable
Max number of elements
Optionalcompare: AsyncComparator<N>Optional compare function
Elements
Staticprint
Heap