Socket
Socket
Sign inDemoInstall

collections

Package Overview
Dependencies
Maintainers
6
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

collections - npm Package Compare versions

Comparing version 5.1.2 to 5.1.3

13

CHANGES.md

@@ -1,2 +0,13 @@

## v5.1
## v5.1.3
- Fix Sorted-Set.reduceRight #206
- Fix sorted array incomparable values bugs #171
## v5.1.2
- Pass the this.sort arguments to this.sorted. #191
- Add npm run build via browserify #190
## v5.1.1
- Fix SortedArray handles incomparable values poorly #27
## v5.1.0
- Addresses a bug with Array#find and deprecate find|findLast in favor of findValue|findLastValue API in collections.

@@ -3,0 +14,0 @@

2

package.json
{
"name": "collections",
"version": "5.1.2",
"version": "5.1.3",
"description": "data structures with idiomatic JavaScript collection interfaces",

@@ -5,0 +5,0 @@ "homepage": "http://www.collectionsjs.com",

@@ -56,2 +56,18 @@ "use strict";

function determineIncomparableRange(index, array, value, compare, equals) {
// Return the inclusive start and end indices of the incomparable streak containing value.
var start = index;
var end = index;
while (start > 0 && compare(value, array[start - 1]) === 0) {
start--;
}
while (end < array.length - 1 && compare(value, array[end + 1]) === 0) {
end++;
}
return {start: start, end: end};
}
function searchFirst(array, value, compare, equals) {

@@ -62,10 +78,11 @@ var index = search(array, value, compare);

} else {
while (index > 0 && equals(value, array[index - 1])) {
index--;
var range = determineIncomparableRange(index, array, value, compare, equals);
for (var i = range.start; i <= range.end; i++) {
if (equals(value, array[i])) {
return i;
}
}
if (!equals(value, array[index])) {
return -1;
} else {
return index;
}
return -1;
}

@@ -79,10 +96,11 @@ }

} else {
while (index < array.length - 1 && equals(value, array[index + 1])) {
index++;
var range = determineIncomparableRange(index, array, value, compare, equals);
for (var i = range.end; i >= range.start; i--) {
if (equals(value, array[i])) {
return i;
}
}
if (!equals(value, array[index])) {
return -1;
} else {
return index;
}
return -1;
}

@@ -117,4 +135,4 @@ }

}
var index = search(this.array, value, this.contentCompare);
return index >= 0 && this.contentEquals(this.array[index], value);
var index = searchFirst(this.array, value, this.contentCompare, this.contentEquals);
return index !== -1;
};

@@ -121,0 +139,0 @@

@@ -603,3 +603,3 @@ "use strict";

if (this.right) {
basis = this.right.reduce(callback, basis, index, thisp, tree, depth + 1);
basis = this.right.reduceRight(callback, basis, index, thisp, tree, depth + 1);
index -= this.right.length;

@@ -610,3 +610,3 @@ }

if (this.left) {
basis = this.left.reduce(callback, basis, index, thisp, tree, depth + 1);
basis = this.left.reduceRight(callback, basis, index, thisp, tree, depth + 1);
}

@@ -613,0 +613,0 @@ return basis;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc