{"_id":"@a-z/iterate-it","_rev":"3-21794d6dd37776a8462afc18b08c549a","name":"@a-z/iterate-it","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@a-z/iterate-it","version":"0.1.0","description":"A handy function with a unified interface to iterate Strings, Arrays, TypedArrays, Maps, Sets, (any Iterables) & Objects.","license":"MIT","author":{"name":"Alrik Zachert","email":"alrik.zachert@gmail.com"},"keywords":["iterable","iterate","iterator","utility","map","set","array","string","object","array-iterator","object-iterator","map-iterator","set-iterator","string-iterator"],"main":"index.js","bugs":{"url":"https://github.com/alrik/iterate-javascript/issues"},"repository":{"url":"git+https://github.com/alrik/iterate-javascript.git"},"scripts":{"test":"mocha"},"dependencies":{"chai":"^4.1.2","mocha":"^4.1.0"},"publishConfig":{"access":"public"},"gitHead":"81bec23058d08b994e8a7d2696e33266f99c0270","homepage":"https://github.com/alrik/iterate-javascript#readme","_id":"@a-z/iterate-it@0.1.0","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"a-z","email":"az@kreatiefer.de"},"dist":{"integrity":"sha512-QBhizv3j70zF6lttQVTh/+OBSqvRlnQkNajw2mhmgz3X6XhPx6HUg0PAMfNUEHH684eJsX6tPHl4nWt8SQ32xg==","shasum":"9187d28dbe7b4242d9084741752208a6020baa2b","tarball":"https://registry.npmjs.org/@a-z/iterate-it/-/iterate-it-0.1.0.tgz","fileCount":16,"unpackedSize":47283,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCkIGf/zPC35f5sSoLcyCt6JL8yIp+dyvGNwpEJ5DQr7wIgLQCBjsxygq1t0Q2tGuRPWRFlnTzmL7hix7/fMDTIOr8="}]},"maintainers":[{"name":"a-z","email":"az@kreatiefer.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iterate-it_0.1.0_1518732806246_0.3435381035542082"},"_hasShrinkwrap":false},"0.1.1":{"name":"@a-z/iterate-it","version":"0.1.1","description":"A handy function with a unified interface to iterate Strings, Arrays, TypedArrays, Maps, Sets, (any Iterables) & Objects.","license":"MIT","author":{"name":"Alrik Zachert","email":"alrik.zachert@gmail.com"},"keywords":["iterable","iterate","iterator","utility","map","set","array","string","object","array-iterator","object-iterator","map-iterator","set-iterator","string-iterator"],"main":"index.js","bugs":{"url":"https://github.com/alrik/iterate-javascript/issues"},"repository":{"url":"git+https://github.com/alrik/iterate-javascript.git"},"scripts":{"test":"mocha"},"devDependencies":{"chai":"^4.1.2","mocha":"^4.1.0"},"publishConfig":{"access":"public"},"gitHead":"ed1e45936f9e6b801eef704e9b244f3f77297c95","homepage":"https://github.com/alrik/iterate-javascript#readme","_id":"@a-z/iterate-it@0.1.1","_npmVersion":"5.5.1","_nodeVersion":"8.9.0","_npmUser":{"name":"a-z","email":"az@kreatiefer.de"},"dist":{"integrity":"sha512-bZygY9+5qPywR+hp2IwDQfcYB30QLJxfRK9SHxK1+MTv8OYCNY0GpX8JAYXSYmcg3jndAvMem3BLjZdbY6Jtzw==","shasum":"320dd320455076c424a11c1e3bc67c7d8a9216dd","tarball":"https://registry.npmjs.org/@a-z/iterate-it/-/iterate-it-0.1.1.tgz","fileCount":16,"unpackedSize":47390,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyQ892dgjxMy9Gndoqom/IYIYVE8D3Fodem5g/QDG3lgIgL6voAl1XhwacD0Kt6yVSyp1UsmDtzpW1EeTh2u4JZ1Q="}]},"maintainers":[{"name":"a-z","email":"az@kreatiefer.de"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iterate-it_0.1.1_1518733380609_0.24810326668365268"},"_hasShrinkwrap":false}},"time":{"created":"2018-02-15T22:13:26.176Z","0.1.0":"2018-02-15T22:13:26.392Z","modified":"2022-04-04T10:52:37.872Z","0.1.1":"2018-02-15T22:23:00.664Z"},"maintainers":[{"name":"a-z","email":"az@kreatiefer.de"}],"description":"A handy function with a unified interface to iterate Strings, Arrays, TypedArrays, Maps, Sets, (any Iterables) & Objects.","homepage":"https://github.com/alrik/iterate-javascript#readme","keywords":["iterable","iterate","iterator","utility","map","set","array","string","object","array-iterator","object-iterator","map-iterator","set-iterator","string-iterator"],"repository":{"url":"git+https://github.com/alrik/iterate-javascript.git"},"author":{"name":"Alrik Zachert","email":"alrik.zachert@gmail.com"},"bugs":{"url":"https://github.com/alrik/iterate-javascript/issues"},"license":"MIT","readme":"# iterate-javascript\n\n[![Subscribe to Release Notes](https://release-notes.com/badges/v1.svg)](https://release-notes.com/@alrik/iterate-javascript)\n[![NPM Package](https://img.shields.io/npm/v/@a-z/iterate-it.svg)](https://www.npmjs.com/package/@a-z/iterate-it)\n[![MIT license](https://img.shields.io/github/license/alrik/iterate-javascript.svg)](LICENSE)\n\nA handy function with a **unified interface** to iterate Strings, Arrays, TypedArrays, Maps, Sets, (any Iterables) & Objects.\nThe api is oriented on [Array.prototype.forEach](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)\nwith the advantage of **iterating almost everything** and **iteration skipping**.\n\n## Installation\n\n```bash\n$ yarn add @a-z/iterate-it\n# or\n$ npm i -S @a-z/iterate-it\n```\n\n## Usage\n\nThe module `@a-z/itarate-it` exports a single function that takes to parameters; an iterable and a callback.\nThe `iterate` function returns a iteration result, that indicates if the iteration was complete of has been skipped.\n\n\n```js\nconst iterate = require('@a-z/iterate-it');\nconst { complete } = iterate(iterable, callback);\n```\n\n### Parameters\n\n#### iterable\nThe iterable or object to iterate over.\nSupported types are String, Array, TypedArray, Map, Set, (any Iterable) & Object.\n\n#### callback\nA function to be called with every element or value of the iterable.\nThe iteration will stop if the function returns `false`.\n\nThe function takes 3 parameters:\n\n* **value**: The current element being processed.\n* **key**: The corresponding key\n* **iterable**: The iterable passed to iterate\n\n### Return Value\n`iterate()` returns a status object with the following properties:\n\n* **complete**: Will be `true` if all items have been iterated, falthy if the iteration was stoped before.\n\n### Examples\n\n#### Iterating strings\n```js\niterate(\"a1b2c3d4e5\", (char, index, str) => {}); \n// => \"12345\"\niterate(new String(\"a1b2c3d4e5\"), (char, index, str) => {}); \n// => [String: '12345']\n```\n\n#### Iterating maps\n```js\nconst map = new Map([['a', 1], ['b', 2], ['c', 3]]);\n\niterate(map, (value, key) => console.log(key, value)); \n// a 1\n// b 2\n// c 3\n```\n\n#### Iterating sets\n```js\nconst set = new Set(['a', 1, 'b']);\n\niterate(set, (value, key) => console.log(key, value)); \n// a a\n// 1 1\n// b b\n```\n\n#### Iterating arrays\n```js\nconst arr = ['a', 1, 'b'];\n\niterate(arr, (value, index) => console.log(index, value)); \n// 0 a\n// 1 1\n// 2 b\n```\n\n#### Iterating typed arrays\n```js\nconst typedArr = new Int32Array([1, 2, -3]);\n\niterate(typedArr, (value, index) => console.log(index, value));\n// 0 1\n// 1 2\n// 2 -3\n```\n\n#### Iterating plain objects\n```js\nconst obj = { a: 1, b: 2, c: 3 };\n\niterate(obj, (value, key) => console.log(key, value)); \n// a 1\n// b 2\n// c 3\n```\n\n#### Skipping the iteration\n```js\nconst arr = [1, 2, undefined, 3, 4];\n\nconst { complete } = iterate(arr, (value) => {\n  console.log(value);\n  \n  // skip iteration as soon as there is an invalid item\n  if (typeof value === 'undefined') {\n    return false;\n  }\n});\n\nconsole.log(complete === true)\n\n// 1\n// 2\n// false\n```\n\n---\n\n### LICENSE\n\nThe files in this archive are released under MIT license.\nYou can find a copy of this license in [LICENSE](LICENSE).\n","readmeFilename":"README.md"}