You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # make-iterator [![NPM version](https://img.shields.io/npm/v/make-iterator.svg?style=flat)](https://www.npmjs.com/package/make-iterator) [![NPM monthly downloads](https://img.shields.io/npm/dm/make-iterator.svg?style=flat)](https://npmjs.org/package/make-iterator) [![NPM total downloads](https://img.shields.io/npm/dt/make-iterator.svg?style=flat)](https://npmjs.org/package/make-iterator) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/make-iterator.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/make-iterator)
  2. > Convert an argument into a valid iterator. Based on the `.makeIterator()` implementation in mout https://github.com/mout/mout.
  3. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
  4. ## Install
  5. Install with [npm](https://www.npmjs.com/):
  6. ```sh
  7. $ npm install --save make-iterator
  8. ```
  9. Copyright (c) 2012, 2013 moutjs team and contributors (http://moutjs.com)
  10. ## Usage
  11. ```js
  12. var iterator = require('make-iterator');
  13. ```
  14. **Regex**
  15. ```js
  16. var arr = ['a', 'b', 'c', 'd', 'e', 'f'];
  17. var fn = iterator(/[a-c]/);
  18. console.log(arr.filter(fn));
  19. //=> ['a', 'b', 'c'];
  20. ```
  21. **Objects**
  22. ```js
  23. var fn = iterator({ a: 1, b: { c: 2 } });
  24. console.log(fn({ a: 1, b: { c: 2, d: 3 } }));
  25. //=> true
  26. console.log(fn({ a: 1, b: { c: 3 } }));
  27. //=> false
  28. ```
  29. ## About
  30. <details>
  31. <summary><strong>Contributing</strong></summary>
  32. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
  33. </details>
  34. <details>
  35. <summary><strong>Running Tests</strong></summary>
  36. 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:
  37. ```sh
  38. $ npm install && npm test
  39. ```
  40. </details>
  41. <details>
  42. <summary><strong>Building docs</strong></summary>
  43. _(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.)_
  44. To generate the readme, run the following command:
  45. ```sh
  46. $ npm install -g verbose/verb#dev verb-generate-readme && verb
  47. ```
  48. </details>
  49. ### Related projects
  50. You might also be interested in these projects:
  51. * [any](https://www.npmjs.com/package/any): Returns `true` if a value exists in the given string, array or object. | [homepage](https://github.com/jonschlinkert/any "Returns `true` if a value exists in the given string, array or object.")
  52. * [arr-filter](https://www.npmjs.com/package/arr-filter): Faster alternative to javascript's native filter method. | [homepage](https://github.com/jonschlinkert/arr-filter "Faster alternative to javascript's native filter method.")
  53. * [arr-map](https://www.npmjs.com/package/arr-map): Faster, node.js focused alternative to JavaScript's native array map. | [homepage](https://github.com/jonschlinkert/arr-map "Faster, node.js focused alternative to JavaScript's native array map.")
  54. * [array-every](https://www.npmjs.com/package/array-every): Returns true if the callback returns truthy for all elements in the given array. | [homepage](https://github.com/jonschlinkert/array-every "Returns true if the callback returns truthy for all elements in the given array.")
  55. * [collection-map](https://www.npmjs.com/package/collection-map): Returns an array of mapped values from an array or object. | [homepage](https://github.com/jonschlinkert/collection-map "Returns an array of mapped values from an array or object.")
  56. * [utils](https://www.npmjs.com/package/utils): Fast, generic JavaScript/node.js utility functions. | [homepage](https://github.com/jonschlinkert/utils "Fast, generic JavaScript/node.js utility functions.")
  57. ### Author
  58. **Jon Schlinkert**
  59. * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
  60. * [GitHub Profile](https://github.com/jonschlinkert)
  61. * [Twitter Profile](https://twitter.com/jonschlinkert)
  62. ### License
  63. Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
  64. Released under the [MIT License](LICENSE).
  65. ***
  66. _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on April 08, 2018._