Skip to content

Commit

Permalink
use app-base from my master
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Mar 22, 2016
1 parent 0590cd3 commit 2d8c340
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm i async-simple-iterator --save
const asyncSimpleIterator = require('async-simple-iterator')
```

### [AsyncSimpleIterator](index.js#L51)
### [AsyncSimpleIterator](index.js#L52)
> Initialize `AsyncSimpleIterator` with `options`.
**Params**
Expand Down Expand Up @@ -54,7 +54,7 @@ ctrl.map([
})
```

### [.wrapIterator](index.js#L129)
### [.wrapIterator](index.js#L134)
> Wraps `iterator` function which then can be passed to [async][] lib. You can pass returned iterator function to **every** [async][] method that you want.
**Params**
Expand Down
13 changes: 9 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'use strict'

var utils = require('./utils')
var AppBase = require('app-base').AppBase

/**
* > Initialize `AsyncSimpleIterator` with `options`.
Expand Down Expand Up @@ -54,8 +55,11 @@ function AsyncSimpleIterator (options) {
}
this.defaultOptions(options)
utils.Emitter(this)
AppBase.call(this)
}

AppBase.extend(AsyncSimpleIterator)

/**
* > Setting default options. Default `settle` option is `false`.
*
Expand All @@ -64,12 +68,12 @@ function AsyncSimpleIterator (options) {
* @api private
*/

AsyncSimpleIterator.prototype.defaultOptions = function defaultOptions (options) {
AppBase.define(AsyncSimpleIterator.prototype, 'defaultOptions', function defaultOptions (options) {
options = utils.extend({settle: false}, this.options, options)
options.settle = typeof options.settle === 'boolean' ? !!options.settle : false
this.options = options
return this
}
})

/**
* > Wraps `iterator` function which then can be passed to [async][] lib.
Expand Down Expand Up @@ -120,13 +124,14 @@ AsyncSimpleIterator.prototype.defaultOptions = function defaultOptions (options)
* @emit `afterEach` with signature `err, res, val[, value], next`
* @emit `error` with signature `err, res, val[, value], next`
*
* @name .wrapIterator
* @param {Function} `iterator` Iterator to pass to [async][] lib.
* @param {Object=} `options` Pass `beforeEach`, `afterEach` and `error` hooks or `settle` option.
* @return {Function} Wrapped `iterator` function which can be passed to every [async][] method.
* @api public
*/

AsyncSimpleIterator.prototype.wrapIterator = function wrapIterator (iterator, options) {
AppBase.define(AsyncSimpleIterator.prototype, 'wrapIterator', function wrapIterator (iterator, options) {
if (typeof iterator !== 'function') {
throw new TypeError('async-simple-iterator: expect `iterator` to be function')
}
Expand All @@ -143,7 +148,7 @@ AsyncSimpleIterator.prototype.wrapIterator = function wrapIterator (iterator, op
}

return utils.iteratorFactory(this, iterator)
}
})

/**
* Expose `AsyncSimpleIterator` instance
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"test": "standard && node test.js"
},
"dependencies": {
"app-base": "github:tunnckocore/app-base",
"component-emitter": "^1.2.0",
"extend-shallow": "^2.0.1",
"is-typeof-error": "^1.1.0",
Expand Down Expand Up @@ -77,4 +78,4 @@
"reflinks": true
}
}
}
}

0 comments on commit 2d8c340

Please sign in to comment.