UNPKG

@tylerbu/sorted-btree-es6

Version:

A sorted list of key-value pairs in a fast, typed in-memory B+ tree with a powerful API.

2 lines (1 loc) 566 B
Object.defineProperty(exports,"__esModule",{value:!0}),exports.intersect=intersect;let shared_1=require("./shared"),forEachKeyInBoth_1=require("./forEachKeyInBoth"),bulkLoad_1=require("./bulkLoad");function intersect(e,r,t){var o=e,n=r,a=(0,shared_1.checkCanDoSetOperation)(o,n,!0);if(0===o._root.size())return e.clone();if(0===n._root.size())return r.clone();let c=[],u=[];(0,forEachKeyInBoth_1.forEachKeyInBoth)(e,r,(e,r,o)=>{r=t(e,r,o);c.push(e),u.push(r)});o=new e.constructor(void 0,e._compare,a);return o._root=(0,bulkLoad_1.bulkLoadRoot)(c,u,a,e._compare),o}