diff --git a/dist/main.cjs.js b/dist/main.cjs similarity index 99% rename from dist/main.cjs.js rename to dist/main.cjs index 7e912545..c0b1a5db 100644 --- a/dist/main.cjs.js +++ b/dist/main.cjs @@ -3507,34 +3507,15 @@ class IntervalTree { this.tree_walk(this.root, (node) => visitor(node.item.key, node.item.value)); } - /** - * Value Mapper. Walk through every node and map node value to another value - * @param callback(value,key) - function to be called for each tree item - */ + /** Value Mapper. Walk through every node and map node value to another value + * @param callback(value,key) - function to be called for each tree item + */ map(callback) { const tree = new IntervalTree(); this.tree_walk(this.root, (node) => tree.insert(node.item.key, callback(node.item.value, node.item.key))); return tree; } - /** - * @param {Interval} interval - optional if the iterator is intended to start from the beginning or end - * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output - * @returns {Iterator} - */ - *iterate(interval, outputMapperFn = (value, key) => value === key ? key.output() : value) { - let node; - if (interval) { - node = this.tree_search_nearest_forward(this.root, new Node(interval)); - } else if (this.root) { - node = this.local_minimum(this.root); - } - while (node) { - yield outputMapperFn(node.item.value, node.item.key); - node = this.tree_successor(node); - } - } - recalc_max(node) { let node_current = node; while (node_current.parent != null) { @@ -3767,21 +3748,6 @@ class IntervalTree { } } - tree_search_nearest_forward(node, search_node) { - let best; - let curr = node; - while (curr && curr != this.nil_node) { - if (curr.less_than(search_node)) { - if (curr.intersect(search_node) && (!best || curr.less_than(best))) best = curr; - curr = curr.right; - } else { - if (!best || curr.less_than(best)) best = curr; - curr = curr.left; - } - } - return best || null; - } - // Original search_interval method; container res support push() insertion // Search all intervals intersecting given one tree_search_interval(node, search_node, res) { @@ -3979,7 +3945,7 @@ class IntervalTree { } height += heightLeft; return height; - } + }; } /** diff --git a/dist/main.esm.js b/dist/main.mjs similarity index 99% rename from dist/main.esm.js rename to dist/main.mjs index c77ed352..c7ed24cc 100644 --- a/dist/main.esm.js +++ b/dist/main.mjs @@ -3503,34 +3503,15 @@ class IntervalTree { this.tree_walk(this.root, (node) => visitor(node.item.key, node.item.value)); } - /** - * Value Mapper. Walk through every node and map node value to another value - * @param callback(value,key) - function to be called for each tree item - */ + /** Value Mapper. Walk through every node and map node value to another value + * @param callback(value,key) - function to be called for each tree item + */ map(callback) { const tree = new IntervalTree(); this.tree_walk(this.root, (node) => tree.insert(node.item.key, callback(node.item.value, node.item.key))); return tree; } - /** - * @param {Interval} interval - optional if the iterator is intended to start from the beginning or end - * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output - * @returns {Iterator} - */ - *iterate(interval, outputMapperFn = (value, key) => value === key ? key.output() : value) { - let node; - if (interval) { - node = this.tree_search_nearest_forward(this.root, new Node(interval)); - } else if (this.root) { - node = this.local_minimum(this.root); - } - while (node) { - yield outputMapperFn(node.item.value, node.item.key); - node = this.tree_successor(node); - } - } - recalc_max(node) { let node_current = node; while (node_current.parent != null) { @@ -3763,21 +3744,6 @@ class IntervalTree { } } - tree_search_nearest_forward(node, search_node) { - let best; - let curr = node; - while (curr && curr != this.nil_node) { - if (curr.less_than(search_node)) { - if (curr.intersect(search_node) && (!best || curr.less_than(best))) best = curr; - curr = curr.right; - } else { - if (!best || curr.less_than(best)) best = curr; - curr = curr.left; - } - } - return best || null; - } - // Original search_interval method; container res support push() insertion // Search all intervals intersecting given one tree_search_interval(node, search_node, res) { @@ -3975,7 +3941,7 @@ class IntervalTree { } height += heightLeft; return height; - } + }; } /** diff --git a/dist/main.umd.js b/dist/main.umd.js index d0f818f3..b90fd647 100644 --- a/dist/main.umd.js +++ b/dist/main.umd.js @@ -3509,34 +3509,15 @@ this.tree_walk(this.root, (node) => visitor(node.item.key, node.item.value)); } - /** - * Value Mapper. Walk through every node and map node value to another value - * @param callback(value,key) - function to be called for each tree item - */ + /** Value Mapper. Walk through every node and map node value to another value + * @param callback(value,key) - function to be called for each tree item + */ map(callback) { const tree = new IntervalTree(); this.tree_walk(this.root, (node) => tree.insert(node.item.key, callback(node.item.value, node.item.key))); return tree; } - /** - * @param {Interval} interval - optional if the iterator is intended to start from the beginning or end - * @param outputMapperFn(value,key) - optional function that maps (value, key) to custom output - * @returns {Iterator} - */ - *iterate(interval, outputMapperFn = (value, key) => value === key ? key.output() : value) { - let node; - if (interval) { - node = this.tree_search_nearest_forward(this.root, new Node(interval)); - } else if (this.root) { - node = this.local_minimum(this.root); - } - while (node) { - yield outputMapperFn(node.item.value, node.item.key); - node = this.tree_successor(node); - } - } - recalc_max(node) { let node_current = node; while (node_current.parent != null) { @@ -3769,21 +3750,6 @@ } } - tree_search_nearest_forward(node, search_node) { - let best; - let curr = node; - while (curr && curr != this.nil_node) { - if (curr.less_than(search_node)) { - if (curr.intersect(search_node) && (!best || curr.less_than(best))) best = curr; - curr = curr.right; - } else { - if (!best || curr.less_than(best)) best = curr; - curr = curr.left; - } - } - return best || null; - } - // Original search_interval method; container res support push() insertion // Search all intervals intersecting given one tree_search_interval(node, search_node, res) { @@ -3981,7 +3947,7 @@ } height += heightLeft; return height; - } + }; } /** diff --git a/package.json b/package.json index 6d352a86..1a847bd8 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,18 @@ { "name": "@flatten-js/core", - "version": "1.4.4", + "version": "1.4.5", "description": "Javascript library for 2d geometry", - "main": "dist/main.cjs.js", + "main": "dist/main.cjs", "umd:main": "dist/main.umd.js", "unpkg": "dist/main.umd.js", - "module": "dist/main.esm.js", + "module": "dist/main.mjs", "types": "index.d.ts", + "exports": { + "types": "./index.d.ts", + "require": "./dist/main.cjs", + "import": "./dist/main.mjs", + "default": "./dist/main.umd.js" + }, "nyc": { "require": [ "@babel/register" diff --git a/rollup.config.js b/rollup.config.js index a52fa1a3..02733e5c 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,12 +4,12 @@ export default { input: 'index.js', output: [ { - file: 'dist/main.cjs.js', + file: 'dist/main.cjs', format: 'cjs', exports: 'named' }, { - file: 'dist/main.esm.js', + file: 'dist/main.mjs', format: 'esm', exports: 'named' },