Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Mar 22, 2016
1 parent 2f877b8 commit 704ab6d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 37 deletions.
4 changes: 3 additions & 1 deletion .verb.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ npm i {%= name %} --save
> For more use-cases see the [tests](./test.js)
```js
const {%= varname %} = require('{%= name %}')
var base = require('{%= name %}')
// or get constructor
var {%= varname[0].toUpperCase() + varname.slice(1) %} = require('{%= name %}').{%= varname[0].toUpperCase() + varname.slice(1) %}
```

{%= apidocs('index.js') %}
Expand Down
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ npm i async-simple-iterator --save
> For more use-cases see the [tests](./test.js)
```js
const asyncSimpleIterator = require('async-simple-iterator')
var base = require('async-simple-iterator')
// or get constructor
var AsyncSimpleIterator = require('async-simple-iterator').AsyncSimpleIterator
```

### [AsyncSimpleIterator](index.js#L52)
Expand All @@ -30,19 +32,20 @@ var ctrl = require('async')
var AsyncSimpleIterator = require('async-simple-iterator').AsyncSimpleIterator

var fs = require('fs')
var base = new AsyncSimpleIterator({ settle: true })
var iterator = base.wrapIterator(fs.stat)

base
.on('beforeEach', function (val) {
var base = new AsyncSimpleIterator({
settle: true,
beforeEach: function (val) {
console.log('before each:', val)
})
.on('afterEach', function (err, res, val) {
console.log('after each:', err, res, val)
})
.on('error', function (err, res, val) {
console.log('on error:', err, res, val)
})
},
error: function (err, res, val) {
console.log('on error:', val)
}
})
var iterator = base.wrapIterator(fs.stat, {
afterEach: function (err, res, val) {
console.log('after each:', val)
}
})

ctrl.map([
'path/to/existing/file.js',
Expand All @@ -54,7 +57,7 @@ ctrl.map([
})
```

### [.wrapIterator](index.js#L134)
### [.wrapIterator](index.js#L136)
> 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 All @@ -75,9 +78,6 @@ var ctrl = require('async')
var base = require('async-simple-iterator')

base
.on('beforeEach', function (value, key, next) {
console.log('before each:', value, key)
})
.on('afterEach', function (err, res, value, key, next) {
console.log('after each:', err, res, value, key)
})
Expand All @@ -96,7 +96,12 @@ var iterator = base.wrapIterator(function (value, key, next) {
}
next(null, 123 + key + 456)

}, { settle: true })
}, {
settle: true,
beforeEach: function (value, key, next) {
console.log('before each:', value, key)
}
})

ctrl.forEachOf({
dev: './dev.json',
Expand All @@ -111,7 +116,7 @@ ctrl.forEachOf({

## Related
* [async](https://www.npmjs.com/package/async): Higher-order functions and common patterns for asynchronous code | [homepage](https://github.com/caolan/async)
* [async-base-iterator](https://www.npmjs.com/package/async-base-iterator): Basic iterator for [async][] library that handles asynchronous and synchronous… [more](https://www.npmjs.com/package/async-base-iterator) | [homepage](https://github.com/tunnckocore/async-base-iterator)
* [async-base-iterator](https://www.npmjs.com/package/async-base-iterator): Basic iterator for [async][] library that handles async and synchronous… [more](https://www.npmjs.com/package/async-base-iterator) | [homepage](https://github.com/tunnckocore/async-base-iterator)
* [async-control](https://www.npmjs.com/package/async-control): Ultimate asynchronous control flow goodness with built-in hook system and… [more](https://www.npmjs.com/package/async-control) | [homepage](https://github.com/hybridables/async-control)
* [relike](https://www.npmjs.com/package/relike): Simple promisify a callback-style function with sane defaults. Support promisify-ing… [more](https://www.npmjs.com/package/relike) | [homepage](https://github.com/hybridables/relike)

Expand Down
36 changes: 19 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ var AppBase = require('app-base').AppBase
* var AsyncSimpleIterator = require('async-simple-iterator').AsyncSimpleIterator
*
* var fs = require('fs')
* var base = new AsyncSimpleIterator({ settle: true })
* var iterator = base.wrapIterator(fs.stat)
*
* base
* .on('beforeEach', function (val) {
* var base = new AsyncSimpleIterator({
* settle: true,
* beforeEach: function (val) {
* console.log('before each:', val)
* })
* .on('afterEach', function (err, res, val) {
* console.log('after each:', err, res, val)
* })
* .on('error', function (err, res, val) {
* console.log('on error:', err, res, val)
* })
*
* },
* error: function (err, res, val) {
* console.log('on error:', val)
* }
* })
* var iterator = base.wrapIterator(fs.stat, {
* afterEach: function (err, res, val) {
* console.log('after each:', val)
* }
* })
*
* ctrl.map([
* 'path/to/existing/file.js',
Expand Down Expand Up @@ -86,9 +86,6 @@ AppBase.define(AsyncSimpleIterator.prototype, 'defaultOptions', function default
* var base = require('async-simple-iterator')
*
* base
* .on('beforeEach', function (value, key, next) {
* console.log('before each:', value, key)
* })
* .on('afterEach', function (err, res, value, key, next) {
* console.log('after each:', err, res, value, key)
* })
Expand All @@ -107,7 +104,12 @@ AppBase.define(AsyncSimpleIterator.prototype, 'defaultOptions', function default
* }
* next(null, 123 + key + 456)
*
* }, { settle: true })
* }, {
* settle: true,
* beforeEach: function (value, key, next) {
* console.log('before each:', value, key)
* }
* })
*
* ctrl.forEachOf({
* dev: './dev.json',
Expand Down

0 comments on commit 704ab6d

Please sign in to comment.