https://github.com/jonschlinkert/make-iterator
Convert an argument into a valid iterator. Based on the `.makeIterator()` implementation in mout https://github.com/mout/mout.
https://github.com/jonschlinkert/make-iterator
callback iterate iteratee iterator loop map reduce
Last synced: 10 months ago
JSON representation
Convert an argument into a valid iterator. Based on the `.makeIterator()` implementation in mout https://github.com/mout/mout.
- Host: GitHub
- URL: https://github.com/jonschlinkert/make-iterator
- Owner: jonschlinkert
- License: mit
- Created: 2014-09-30T23:30:00.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-08T14:18:45.000Z (almost 8 years ago)
- Last Synced: 2025-04-15T00:45:35.972Z (11 months ago)
- Topics: callback, iterate, iteratee, iterator, loop, map, reduce
- Language: JavaScript
- Size: 20.5 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# make-iterator [](https://www.npmjs.com/package/make-iterator) [](https://npmjs.org/package/make-iterator) [](https://npmjs.org/package/make-iterator) [](https://travis-ci.org/jonschlinkert/make-iterator)
> Convert an argument into a valid iterator. Based on the `.makeIterator()` implementation in mout https://github.com/mout/mout.
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save make-iterator
```
Although the code has materially changed, this was originally based on the
make iterator function in moutjs, and externalized to a module. Thanks to the
moutjs team for the inspiration.
Copyright (c) 2012, 2013 moutjs team and contributors (http://moutjs.com)
## Usage
```js
var iterator = require('make-iterator');
```
**Regex**
```js
var arr = ['a', 'b', 'c', 'd', 'e', 'f'];
var fn = iterator(/[a-c]/);
console.log(arr.filter(fn));
//=> ['a', 'b', 'c'];
```
**Objects**
```js
var fn = iterator({ a: 1, b: { c: 2 } });
console.log(fn({ a: 1, b: { c: 2, d: 3 } }));
//=> true
console.log(fn({ a: 1, b: { c: 3 } }));
//=> false
```
## About
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install && npm test
```
Building docs
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme, run the following command:
```sh
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```
### Related projects
You might also be interested in these projects:
* [breakdance](https://www.npmjs.com/package/breakdance): Breakdance is a node.js library for converting HTML to markdown. Highly pluggable, flexible and easy… [more](http://breakdance.io) | [homepage](http://breakdance.io "Breakdance is a node.js library for converting HTML to markdown. Highly pluggable, flexible and easy to use. It's time for your markup to get down.")
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
* [snapdragon](https://www.npmjs.com/package/snapdragon): Easy-to-use plugin system for creating powerful, fast and versatile parsers and compilers, with built-in source-map… [more](https://github.com/here-be/snapdragon) | [homepage](https://github.com/here-be/snapdragon "Easy-to-use plugin system for creating powerful, fast and versatile parsers and compilers, with built-in source-map support.")
### Author
**Jon Schlinkert**
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
### License
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 08, 2018._