Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #309: call stack exceeded in Control.Bind.Bind instance for Array #311

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Breaking changes:
New features:

Bugfixes:
- call stack exceeded in Control.Bind.Bind instance for Array (#311 by @michaelficarra)

Other improvements:

Expand Down
10 changes: 9 additions & 1 deletion src/Control/Bind.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
var APPLY_CHUNK_SIZE = 10e3;
var push = Function.prototype.apply.bind(Array.prototype.push);

export const arrayBind = function (arr) {
return function (f) {
var result = [];
for (var i = 0, l = arr.length; i < l; i++) {
Array.prototype.push.apply(result, f(arr[i]));
var subArr = f(arr[i]);
while (subArr.length > APPLY_CHUNK_SIZE) {
push(result, subArr.slice(0, APPLY_CHUNK_SIZE);
subArr = subArr.slice(APPLY_CHUNK_SIZE);
}
push(result, subArr);
}
return result;
};
Expand Down
Loading