Skip to content

Commit

Permalink
fix(meta-api): finalise each for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nomocas committed Apr 18, 2017
1 parent 57fc942 commit 0ac924c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/babelute.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,17 @@ export class Babelute {
*/
_each(array, func) {

assert(Array.isArray(array) || array.length, '._each meta-api need an array (or iterable with bracket access) as first argument');
assert(!array || Array.isArray(array), '._each meta-api need an array (or iterable with bracket access) as first argument');
assert(typeof func === 'function', '._each meta-api need a function as second argument');

array.forEach((item, index) => {
const b = func(item, index);
if (array)
array.forEach((item, index) => {
const b = func(item, index);

assert(b instanceof Babelute, '._each need a function that return a babelute');
assert(b instanceof Babelute, '._each need a function that return a babelute');

this._lexems.push.apply(this._lexems, b._lexems);
});
this._lexems.push.apply(this._lexems, b._lexems);
});
return this;
}

Expand Down

0 comments on commit 0ac924c

Please # to comment.