Open royaldark opened 7 years ago
In which JS environment, browser or node? A use case would be appreciated
Seems the recursive solution has outlived it usefulness. Any interest in writing a depth first traversing alternative? On Sat, Oct 15, 2016 at 12:50 AM Benoit Marchant notifications@github.com wrote:
In which JS environment, browser or node? A use case would be appreciated
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/montagejs/collections/issues/164#issuecomment-253969271, or mute the thread https://github.com/notifications/unsubscribe-auth/AADrhpBZKA4kxaSPzMEsbgjaRkcaXqB5ks5q0IXhgaJpZM4KXnMr .
I experienced it in Node. Here is a simple reproduction:
const SortedSet = require("collections/sorted-set");
const vals = [];
for (let i = 0; i < 10000; i++) {
vals.push(i);
}
const set = new SortedSet(vals);
console.log(set.toArray());
/home/Joe/dev/node_modules/collections/sorted-set.js:584
Node.prototype.reduce = function (callback, basis, index, thisp, tree, depth) {
^
RangeError: Maximum call stack size exceeded
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:584:34)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
at Node.reduce (/home/Joe/dev/node_modules/collections/sorted-set.js:589:27)
I have a SortedSet with 9904 entries (simple one-level maps). Calling .toArray() always throws a call stack exceeded error.