Skip to content

Commit

Permalink
beat codeclimate duplicate issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Mar 22, 2016
1 parent 089e2c4 commit 6630054
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,15 @@ AppBase.define(AsyncSimpleIterator.prototype, 'wrapIterator', function wrapItera
}
this.options = options ? utils.extend(this.options, options) : this.options

if (typeof this.options.beforeEach === 'function') {
this.on('beforeEach', this.options.beforeEach)
}
if (typeof this.options.afterEach === 'function') {
this.on('afterEach', this.options.afterEach)
}
if (typeof this.options.error === 'function') {
this.on('error', this.options.error)
var hooks = ['beforeEach', 'afterEach', 'error']
var len = hooks.length
var i = 0

while (i < len) {
var name = hooks[i++]
if (typeof this.options[name] === 'function') {
this.on(name, this.options[name])
}
}

return utils.iteratorFactory(this, iterator)
Expand Down

0 comments on commit 6630054

Please sign in to comment.