https://github.com/doowb/iterator-sync
Iterate over a stack of functions.
https://github.com/doowb/iterator-sync
Last synced: about 2 months ago
JSON representation
Iterate over a stack of functions.
- Host: GitHub
- URL: https://github.com/doowb/iterator-sync
- Owner: doowb
- License: mit
- Created: 2015-06-13T18:15:08.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-16T03:03:57.000Z (over 9 years ago)
- Last Synced: 2024-10-04T19:43:20.822Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 539 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iterator-sync [](http://badge.fury.io/js/iterator-sync) [](https://travis-ci.org/doowb/iterator-sync)
> Iterate over a stack of functions.
This module is intended to be used with [loader-cache](https://github.com/jonschlinkert/loader-cache)but may be used by itself or in other modules.
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i iterator-sync --save
```## Usage
```js
var iterator = require('iterator-sync');
```## API
### [iterator](index.js#L20)
Iterate over a stack of functions passing the results of
each function to the next function in the stack.**Params**
* `stack` **{Array}**: Array of functions to call.
* `returns` **{Function}**: Returns a function that will iterator over the given stack of functions.```js
var fs = require('fs');
var iterator = require('iterator-sync');
var stack = [
function (fp) { return fs.readFileSync(fp, 'utf8'); },
function (contents) { return JSON.parse(contents); }
];
var readJSON = iterator(stack);
var pkg = readJSON('./package.json');
console.log(pkg);
```## Related projects
* [iterator-async](https://github.com/doowb/iterator-async): Iterate over a stack of async functions.
* [iterator-promise](https://github.com/doowb/iterator-promise): Iterator over a stack of functions.
* [iterator-streams](https://github.com/doowb/iterator-streams): Iterator over a stack of functions.
* [loader-cache](https://github.com/jonschlinkert/loader-cache): Register loader functions that dynamically read, parse or otherwise transform file contents when the name… [more](https://github.com/jonschlinkert/loader-cache)## Running tests
Install dev dependencies:
```sh
$ npm i -d && npm test
```## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/doowb/iterator-sync/issues/new)
## Author
**Brian Woodward**
+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)## License
Copyright © 2015 [Brian Woodward](https://github.com/doowb)
Released under the MIT license.***
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 17, 2015._