Skip to content

Commit

Permalink
Fix export module entry point - target main.mjs instead main.esm
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbol99 committed Dec 1, 2023
1 parent 12ffbdc commit 984251a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 119 deletions.
42 changes: 4 additions & 38 deletions dist/main.cjs.js → dist/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -3979,7 +3945,7 @@ class IntervalTree {
}
height += heightLeft;
return height;
}
};
}

/**
Expand Down
42 changes: 4 additions & 38 deletions dist/main.esm.js → dist/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -3975,7 +3941,7 @@ class IntervalTree {
}
height += heightLeft;
return height;
}
};
}

/**
Expand Down
42 changes: 4 additions & 38 deletions dist/main.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -3981,7 +3947,7 @@
}
height += heightLeft;
return height;
}
};
}

/**
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
},
Expand Down

0 comments on commit 984251a

Please sign in to comment.