Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bplustree

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bplustree - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

33

dist/bplustree.js

@@ -63,5 +63,3 @@ 'use strict';

} else if (options.getValues) {
result = result.concat(node.v[i].reduce(function (a, b) {
return a.concat(b);
}, []));
result.push(node.v[i]);
} else {

@@ -74,6 +72,8 @@ result[node.k[i]] = node.v[i];

walk(this.tree);
var out = result.length && Array.isArray(result[0]) ? Array.prototype.concat.apply([], result) : result;
if ((options.getKeys || options.getValues) && options.descending) {
return result.reverse();
return out.reverse();
}
return result;
return out;
}

@@ -108,3 +108,2 @@

if (this.cmpFn(lo, leaf.k[leaf.k.length - 1]) === 1) {
// use cmpFn here
return [];

@@ -128,5 +127,3 @@ }

// if key at current index is upper bound, concat all vals and stop
result = result.concat(leaf.v[index]).reduce(function (a, b) {
return a.concat(b);
}, []);
result.push(leaf.v[index]);
break;

@@ -136,11 +133,7 @@ }

// if last key is upper bound, concat all vals and stop
result = result.concat(leaf.v.slice(index)).reduce(function (a, b) {
return a.concat(b);
}, []);
result.push(leaf.v.slice(index));
break;
} else if (this.cmpFn(leaf.k[leaf.k.length - 1], hi) === -1) {
// if last key is smaller than upper bound, fetch next leaf and iterate
result = result.concat(leaf.v.slice(index)).reduce(function (a, b) {
return a.concat(b);
}, []);
result.push(leaf.v.slice(index));
if (leaf.n !== null) {

@@ -156,5 +149,3 @@ leaf = this.fetch(leaf.n, { getLeaf: true });

for (; leaf.k[i] <= hi; i++) {}
result = result.concat(leaf.v.slice(0, i)).reduce(function (a, b) {
return a.concat(b);
}, []);
result.push(leaf.v.slice(0, i));
break;

@@ -164,2 +155,8 @@ }

if (Array.isArray(result[0])) {
result = Array.prototype.concat.apply([], Array.prototype.concat.apply([], result));
} else {
result = Array.prototype.concat.apply([], result);
}
if (options.descending) {

@@ -166,0 +163,0 @@ result.reverse();

@@ -38,3 +38,3 @@ /** Class representing a B+ Tree. */

options || (options = {});
let result = (options.getKeys || options.getValues) ? [] : {};
const result = (options.getKeys || options.getValues) ? [] : {};
function walk(node) {

@@ -51,3 +51,3 @@ if (node.t === 'branch') {

} else if (options.getValues) {
result = result.concat(node.v[i].reduce((a, b) => a.concat(b), []));
result.push(node.v[i]);
} else {

@@ -60,6 +60,9 @@ result[node.k[i]] = node.v[i];

walk(this.tree);
const out = (result.length && Array.isArray(result[0])) ?
Array.prototype.concat.apply([], result) : result;
if ((options.getKeys || options.getValues) && options.descending) {
return result.reverse();
return out.reverse();
}
return result;
return out;
}

@@ -89,3 +92,3 @@

}
if (this.cmpFn(lo, leaf.k[leaf.k.length - 1]) === 1) { // use cmpFn here
if (this.cmpFn(lo, leaf.k[leaf.k.length - 1]) === 1) {
return [];

@@ -109,3 +112,3 @@ }

// if key at current index is upper bound, concat all vals and stop
result = result.concat(leaf.v[index]).reduce((a, b) => a.concat(b), []);
result.push(leaf.v[index]);
break;

@@ -115,7 +118,7 @@ }

// if last key is upper bound, concat all vals and stop
result = result.concat(leaf.v.slice(index)).reduce((a, b) => a.concat(b), []);
result.push(leaf.v.slice(index));
break;
} else if (this.cmpFn(leaf.k[leaf.k.length - 1], hi) === -1) {
// if last key is smaller than upper bound, fetch next leaf and iterate
result = result.concat(leaf.v.slice(index)).reduce((a, b) => a.concat(b), []);
result.push(leaf.v.slice(index));
if (leaf.n !== null) {

@@ -131,3 +134,3 @@ leaf = this.fetch(leaf.n, { getLeaf: true });

for (; leaf.k[i] <= hi; i++);
result = result.concat(leaf.v.slice(0, i)).reduce((a, b) => a.concat(b), []);
result.push(leaf.v.slice(0, i));
break;

@@ -137,2 +140,8 @@ }

if (Array.isArray(result[0])) {
result = Array.prototype.concat.apply([], Array.prototype.concat.apply([], result));
} else {
result = Array.prototype.concat.apply([], result);
}
if (options.descending) {

@@ -139,0 +148,0 @@ result.reverse();

{
"name": "bplustree",
"version": "1.1.1",
"version": "1.1.2",
"scripts": {

@@ -5,0 +5,0 @@ "test": "mocha --compilers js:babel-core/register --check-leaks test/bplustree.js && npm run build",

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