Comparing version 0.31.2 to 0.31.3
# Changelog | ||
## 0.31.3 | ||
* Fixing `Heap.nsmallest` & `Heap.nlargest` docs & typings. | ||
* Fixing `Heap.nsmallest` & `Heap.nlargest` not using custom comparator function when `n = 1`. | ||
## 0.31.2 | ||
@@ -4,0 +9,0 @@ |
@@ -81,5 +81,5 @@ /** | ||
export function nsmallest<T>(n: number, comparator: HeapComparator<T>, values: Iterable<T>): Array<T>; | ||
export function nsmallest<T>(comparator: HeapComparator<T>, n: number, values: Iterable<T>): Array<T>; | ||
export function nsmallest<T>(n: number, values: Iterable<T>): Array<T>; | ||
export function nlargest<T>(n: number, comparator: HeapComparator<T>, values: Iterable<T>): Array<T>; | ||
export function nlargest<T>(comparator: HeapComparator<T>, n: number, values: Iterable<T>): Array<T>; | ||
export function nlargest<T>(n: number, values: Iterable<T>): Array<T>; |
12
heap.js
@@ -212,3 +212,3 @@ /** | ||
// If n is equal to 1, it's just a matter of find the minimum | ||
// If n is equal to 1, it's just a matter of finding the minimum | ||
if (n === 1) { | ||
@@ -219,3 +219,3 @@ if (iterables.isArrayLike(iterable)) { | ||
if (v < min) | ||
if (min === Infinity || compare(v, min) < 0) | ||
min = v; | ||
@@ -231,3 +231,3 @@ } | ||
forEach(iterable, function(value) { | ||
if (value < min) | ||
if (min === Infinity || compare(value, min) < 0) | ||
min = value; | ||
@@ -310,3 +310,3 @@ }); | ||
// If n is equal to 1, it's just a matter of find the maximum | ||
// If n is equal to 1, it's just a matter of finding the maximum | ||
if (n === 1) { | ||
@@ -317,3 +317,3 @@ if (iterables.isArrayLike(iterable)) { | ||
if (v > max) | ||
if (max === -Infinity || compare(v, max) > 0) | ||
max = v; | ||
@@ -329,3 +329,3 @@ } | ||
forEach(iterable, function(value) { | ||
if (value > max) | ||
if (max === -Infinity || compare(value, max) > 0) | ||
max = value; | ||
@@ -332,0 +332,0 @@ }); |
{ | ||
"name": "mnemonist", | ||
"version": "0.31.2", | ||
"version": "0.31.3", | ||
"description": "Curated collection of data structures for the JavaScript language.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
318080