Skip to content

Commit 1bc3f87

Browse files
committed
Refactor to improve bundle size
1 parent 2057ebb commit 1bc3f87

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

Diff for: index.js

+4-15
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,18 @@ module.exports = modifierFactory
77
// Turn `callback` into a child-modifier accepting a parent. See
88
// `array-iterate` for more info.
99
function modifierFactory(callback) {
10-
return iteratorFactory(wrapperFactory(callback))
11-
}
12-
13-
// Turn `callback` into a `iterator' accepting a parent.
14-
function iteratorFactory(callback) {
1510
return iterator
1611

1712
function iterator(parent) {
18-
var children = parent && parent.children
19-
20-
if (!children) {
13+
if (!parent || !parent.children) {
2114
throw new Error('Missing children in `parent` for `modifier`')
2215
}
2316

24-
iterate(children, callback, parent)
17+
iterate(parent.children, iteratee, parent)
2518
}
26-
}
27-
28-
// Pass the context as the third argument to `callback`.
29-
function wrapperFactory(callback) {
30-
return wrapper
3119

32-
function wrapper(value, index) {
20+
// Pass the context as the third argument to `callback`.
21+
function iteratee(value, index) {
3322
return callback(value, index, this)
3423
}
3524
}

0 commit comments

Comments
 (0)