New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@x-oasis/prefix-interval-tree

Package Overview
Dependencies
Maintainers
0
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@x-oasis/prefix-interval-tree - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

16

dist/prefix-interval-tree.cjs.development.js

@@ -219,3 +219,3 @@ 'use strict';

_proto.greatestLowerBound = function greatestLowerBound(t) {
if (t < 0) {
if (t < 0 || !this._actualSize) {
return -1;

@@ -225,3 +225,3 @@ }

if (this._heap[node] < t) {
return Math.max(this._actualSize - 1, 0);
return this._actualSize;
}

@@ -237,6 +237,6 @@ while (node < this._half) {

}
return Math.min(node - this._half, this._actualSize - 1);
return Math.min(node - this._half, this._actualSize);
};
_proto.greatestStrictLowerBound = function greatestStrictLowerBound(t) {
if (t <= 0) {
if (t <= 0 || !this._actualSize) {
return -1;

@@ -246,3 +246,3 @@ }

if (this._heap[node] < t) {
return Math.max(this._actualSize - 1, 0);
return this._actualSize;
}

@@ -258,3 +258,3 @@ while (node < this._half) {

}
return Math.min(node - this._half, this._actualSize - 1);
return Math.min(node - this._half, this._actualSize);
};

@@ -274,6 +274,6 @@ _proto.computeRange = function computeRange(minOffset, maxOffset) {

_proto.leastUpperBound = function leastUpperBound(t) {
return this.greatestStrictLowerBound(t) + 1;
return Math.min(this.greatestStrictLowerBound(t) + 1, this._actualSize);
};
_proto.leastStrictUpperBound = function leastStrictUpperBound(t) {
return this.greatestLowerBound(t) + 1;
return Math.min(this.greatestLowerBound(t) + 1, this._actualSize);
};

@@ -280,0 +280,0 @@ return PrefixIntervalTree;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){return Math.floor(t/2)},e=function(t){for(var e=[],i=t-1;i>=0;--i)e[i]=0;return e};function i(t){for(var e=1;e<t;)e*=2;return e}exports.default=function(){function a(t,e){"number"==typeof t&&this.initWithNumber(t),Array.isArray(t)&&this.initWithArray(t);var i=e||{},a=i.onUpdateItemLayout;this._onUpdateIntervalTree=i.onUpdateIntervalTree,this._onUpdateItemLayout=a}var n=a.prototype;return n.initWithNumber=function(t){this._half=i(t),this._size=this._half,this._heap=e(2*this._half),this._actualSize=0},n.initWithArray=function(t){var a;for(this._half=i(t.length),this._size=this._half,this._heap=e(2*this._half),a=0;a<this._size;++a)this._heap[this._half+a]=t[a];for(a=this._half-1;a>0;--a)this._heap[a]=this._heap[2*a]+this._heap[2*a+1];this._actualSize=t.length},a.uniform=function(t,e){for(var i=[],n=t-1;n>=0;--n)i[n]=e;return new a(i)},a.empty=function(t){return a.uniform(t,0)},n.stretch=function(){for(var t=e(2*this._half*2),i=2*this._half,a=0;a<this._size;a++)t[i+a]=this._heap[this._half+a]||0;for(var n=i-1;n>0;n--)t[n]=t[2*n]+t[2*n+1];this._half=i,this._size=i,this._heap=t},n.isValidIndex=function(t){return"number"==typeof t&&t>=0&&t<this._actualSize},n.reflowHeap=function(e,i){var a=this;void 0===i&&(i=2*this._half-2);var n=Math.log2(this._size);Array.from({length:n},(function(t,e){return e})).reduce((function(e){for(var i=e.endIndex,n=t(e.startIndex),h=t(i),r=n;r<=h;r++)a._heap[r]=a._heap[2*r]+a._heap[2*r+1];return{startIndex:n,endIndex:h}}),{startIndex:e,endIndex:i})},n.remove=function(t){this.batchRemove([t])},n.batchRemove=function(t){var e=this;if(t.sort((function(t,e){return t-e})),t.forEach((function(t){e.isValidIndex(t)&&(isNaN(t)?console.warn("Passing a NaN value as interval tree index"):(e._heap.splice(e._half+t,1),e._heap.push(0),e._actualSize=e._actualSize-1))})),this.reflowHeap(t[0]+this._half),"function"==typeof this._onUpdateIntervalTree&&this._onUpdateIntervalTree(this._heap),"function"==typeof this._onUpdateItemLayout)for(var i=t[0];i<this._half;i++)this._onUpdateItemLayout(i,this.get(i))},n.removeV0=function(t){if(this.isValidIndex(t))if(isNaN(t))console.warn("Passing a NaN value as interval tree index");else{var i=e(2*this._half),a=this._heap.slice(this._half);a.splice(t,1);for(var n=this._half;n<2*this._half;n++)i[n]=a[n-this._half]||0;for(var h=this._half-1;h>0;h--)i[h]=i[2*h]+i[2*h+1];this._actualSize=this._actualSize-1,this._heap=i}},n.set=function(e,i){if("number"!=typeof e||e<0)return!1;if(isNaN(e))return console.warn("Passing a NaN value as interval tree index"),!1;for(;e>=this._half;)this.stretch();var a=this._half+e;for(this._heap[a]=i,a=t(a);0!==a;a=t(a))this._heap[a]=this._heap[2*a]+this._heap[2*a+1];return e+1>this._actualSize&&(this._actualSize=e+1),"function"==typeof this._onUpdateIntervalTree&&this._onUpdateIntervalTree(this._heap),"function"==typeof this._onUpdateItemLayout&&this._onUpdateItemLayout(e,i),!0},n.getMaxUsefulLength=function(){return this.getActualSize()},n.getActualSize=function(){return this._actualSize},n.get=function(t){return this._heap[this._half+t]},n.getSize=function(){return this._size},n.getHalf=function(){return this._half},n.getHeap=function(){return this._heap},n.getMaxValue=function(){return this._heap[1]},n.sumUntil=function(e){if(e<=0)return 0;for(var i=this._half+e-1,a=this._heap[i];1!==i;i=t(i))i%2==1&&(a+=this._heap[i-1]);return a},n.sumTo=function(t){return this.sumUntil(t+1)},n.sum=function(t,e){return this.sumUntil(e)-this.sumUntil(t)},n.greatestLowerBound=function(t){if(t<0)return-1;var e=1;if(this._heap[e]<t)return Math.max(this._actualSize-1,0);for(;e<this._half;){var i=this._heap[2*e];t<i?e*=2:(e=2*e+1,t-=i)}return Math.min(e-this._half,this._actualSize-1)},n.greatestStrictLowerBound=function(t){if(t<=0)return-1;var e=1;if(this._heap[e]<t)return Math.max(this._actualSize-1,0);for(;e<this._half;){var i=this._heap[2*e];t<=i?e*=2:(e=2*e+1,t-=i)}return Math.min(e-this._half,this._actualSize-1)},n.computeRange=function(t,e){return this.getHeap()[1]<t?{startIndex:this._actualSize,endIndex:this._actualSize}:{startIndex:this.greatestLowerBound(t),endIndex:this.leastStrictUpperBound(e)}},n.leastUpperBound=function(t){return this.greatestStrictLowerBound(t)+1},n.leastStrictUpperBound=function(t){return this.greatestLowerBound(t)+1},a}();
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(t){return Math.floor(t/2)},e=function(t){for(var e=[],i=t-1;i>=0;--i)e[i]=0;return e};function i(t){for(var e=1;e<t;)e*=2;return e}exports.default=function(){function a(t,e){"number"==typeof t&&this.initWithNumber(t),Array.isArray(t)&&this.initWithArray(t);var i=e||{},a=i.onUpdateItemLayout;this._onUpdateIntervalTree=i.onUpdateIntervalTree,this._onUpdateItemLayout=a}var n=a.prototype;return n.initWithNumber=function(t){this._half=i(t),this._size=this._half,this._heap=e(2*this._half),this._actualSize=0},n.initWithArray=function(t){var a;for(this._half=i(t.length),this._size=this._half,this._heap=e(2*this._half),a=0;a<this._size;++a)this._heap[this._half+a]=t[a];for(a=this._half-1;a>0;--a)this._heap[a]=this._heap[2*a]+this._heap[2*a+1];this._actualSize=t.length},a.uniform=function(t,e){for(var i=[],n=t-1;n>=0;--n)i[n]=e;return new a(i)},a.empty=function(t){return a.uniform(t,0)},n.stretch=function(){for(var t=e(2*this._half*2),i=2*this._half,a=0;a<this._size;a++)t[i+a]=this._heap[this._half+a]||0;for(var n=i-1;n>0;n--)t[n]=t[2*n]+t[2*n+1];this._half=i,this._size=i,this._heap=t},n.isValidIndex=function(t){return"number"==typeof t&&t>=0&&t<this._actualSize},n.reflowHeap=function(e,i){var a=this;void 0===i&&(i=2*this._half-2);var n=Math.log2(this._size);Array.from({length:n},(function(t,e){return e})).reduce((function(e){for(var i=e.endIndex,n=t(e.startIndex),h=t(i),r=n;r<=h;r++)a._heap[r]=a._heap[2*r]+a._heap[2*r+1];return{startIndex:n,endIndex:h}}),{startIndex:e,endIndex:i})},n.remove=function(t){this.batchRemove([t])},n.batchRemove=function(t){var e=this;if(t.sort((function(t,e){return t-e})),t.forEach((function(t){e.isValidIndex(t)&&(isNaN(t)?console.warn("Passing a NaN value as interval tree index"):(e._heap.splice(e._half+t,1),e._heap.push(0),e._actualSize=e._actualSize-1))})),this.reflowHeap(t[0]+this._half),"function"==typeof this._onUpdateIntervalTree&&this._onUpdateIntervalTree(this._heap),"function"==typeof this._onUpdateItemLayout)for(var i=t[0];i<this._half;i++)this._onUpdateItemLayout(i,this.get(i))},n.removeV0=function(t){if(this.isValidIndex(t))if(isNaN(t))console.warn("Passing a NaN value as interval tree index");else{var i=e(2*this._half),a=this._heap.slice(this._half);a.splice(t,1);for(var n=this._half;n<2*this._half;n++)i[n]=a[n-this._half]||0;for(var h=this._half-1;h>0;h--)i[h]=i[2*h]+i[2*h+1];this._actualSize=this._actualSize-1,this._heap=i}},n.set=function(e,i){if("number"!=typeof e||e<0)return!1;if(isNaN(e))return console.warn("Passing a NaN value as interval tree index"),!1;for(;e>=this._half;)this.stretch();var a=this._half+e;for(this._heap[a]=i,a=t(a);0!==a;a=t(a))this._heap[a]=this._heap[2*a]+this._heap[2*a+1];return e+1>this._actualSize&&(this._actualSize=e+1),"function"==typeof this._onUpdateIntervalTree&&this._onUpdateIntervalTree(this._heap),"function"==typeof this._onUpdateItemLayout&&this._onUpdateItemLayout(e,i),!0},n.getMaxUsefulLength=function(){return this.getActualSize()},n.getActualSize=function(){return this._actualSize},n.get=function(t){return this._heap[this._half+t]},n.getSize=function(){return this._size},n.getHalf=function(){return this._half},n.getHeap=function(){return this._heap},n.getMaxValue=function(){return this._heap[1]},n.sumUntil=function(e){if(e<=0)return 0;for(var i=this._half+e-1,a=this._heap[i];1!==i;i=t(i))i%2==1&&(a+=this._heap[i-1]);return a},n.sumTo=function(t){return this.sumUntil(t+1)},n.sum=function(t,e){return this.sumUntil(e)-this.sumUntil(t)},n.greatestLowerBound=function(t){if(t<0||!this._actualSize)return-1;var e=1;if(this._heap[e]<t)return this._actualSize;for(;e<this._half;){var i=this._heap[2*e];t<i?e*=2:(e=2*e+1,t-=i)}return Math.min(e-this._half,this._actualSize)},n.greatestStrictLowerBound=function(t){if(t<=0||!this._actualSize)return-1;var e=1;if(this._heap[e]<t)return this._actualSize;for(;e<this._half;){var i=this._heap[2*e];t<=i?e*=2:(e=2*e+1,t-=i)}return Math.min(e-this._half,this._actualSize)},n.computeRange=function(t,e){return this.getHeap()[1]<t?{startIndex:this._actualSize,endIndex:this._actualSize}:{startIndex:this.greatestLowerBound(t),endIndex:this.leastStrictUpperBound(e)}},n.leastUpperBound=function(t){return Math.min(this.greatestStrictLowerBound(t)+1,this._actualSize)},n.leastStrictUpperBound=function(t){return Math.min(this.greatestLowerBound(t)+1,this._actualSize)},a}();
//# sourceMappingURL=prefix-interval-tree.cjs.production.min.js.map

@@ -215,3 +215,3 @@ var parent = function parent(node) {

_proto.greatestLowerBound = function greatestLowerBound(t) {
if (t < 0) {
if (t < 0 || !this._actualSize) {
return -1;

@@ -221,3 +221,3 @@ }

if (this._heap[node] < t) {
return Math.max(this._actualSize - 1, 0);
return this._actualSize;
}

@@ -233,6 +233,6 @@ while (node < this._half) {

}
return Math.min(node - this._half, this._actualSize - 1);
return Math.min(node - this._half, this._actualSize);
};
_proto.greatestStrictLowerBound = function greatestStrictLowerBound(t) {
if (t <= 0) {
if (t <= 0 || !this._actualSize) {
return -1;

@@ -242,3 +242,3 @@ }

if (this._heap[node] < t) {
return Math.max(this._actualSize - 1, 0);
return this._actualSize;
}

@@ -254,3 +254,3 @@ while (node < this._half) {

}
return Math.min(node - this._half, this._actualSize - 1);
return Math.min(node - this._half, this._actualSize);
};

@@ -270,6 +270,6 @@ _proto.computeRange = function computeRange(minOffset, maxOffset) {

_proto.leastUpperBound = function leastUpperBound(t) {
return this.greatestStrictLowerBound(t) + 1;
return Math.min(this.greatestStrictLowerBound(t) + 1, this._actualSize);
};
_proto.leastStrictUpperBound = function leastStrictUpperBound(t) {
return this.greatestLowerBound(t) + 1;
return Math.min(this.greatestLowerBound(t) + 1, this._actualSize);
};

@@ -276,0 +276,0 @@ return PrefixIntervalTree;

{
"name": "@x-oasis/prefix-interval-tree",
"version": "0.2.2",
"version": "0.2.3",
"description": "prefix interval tree function",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -321,3 +321,3 @@ const parent = (node: number) => Math.floor(node / 2);

greatestLowerBound(t: number) {
if (t < 0) {
if (t < 0 || !this._actualSize) {
return -1;

@@ -329,3 +329,3 @@ }

// not use this._size;this._size always be a big value
return Math.max(this._actualSize - 1, 0);
return this._actualSize;
}

@@ -343,3 +343,3 @@

return Math.min(node - this._half, this._actualSize - 1);
return Math.min(node - this._half, this._actualSize);
}

@@ -352,3 +352,3 @@

greatestStrictLowerBound(t: number) {
if (t <= 0) {
if (t <= 0 || !this._actualSize) {
return -1;

@@ -359,3 +359,3 @@ }

if (this._heap[node] < t) {
return Math.max(this._actualSize - 1, 0);
return this._actualSize;
}

@@ -373,3 +373,3 @@

return Math.min(node - this._half, this._actualSize - 1);
return Math.min(node - this._half, this._actualSize);
}

@@ -413,3 +413,3 @@

leastUpperBound(t: number) {
return this.greatestStrictLowerBound(t) + 1;
return Math.min(this.greatestStrictLowerBound(t) + 1, this._actualSize);
}

@@ -422,3 +422,3 @@

leastStrictUpperBound(t: number) {
return this.greatestLowerBound(t) + 1;
return Math.min(this.greatestLowerBound(t) + 1, this._actualSize);
}

@@ -425,0 +425,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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