{"name":"array-iterate","version":"1.0.0","description":"forEach with the possibility to change the next position","license":"MIT","keywords":["array","list","iterate","walk"],"repository":{"type":"git","url":"git+https://github.com/wooorm/array-iterate.git"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com"},"files":["index.js"],"devDependencies":{"browserify":"^11.0.0","eslint":"^1.0.0","esmangle":"^1.0.0","istanbul":"^0.3.0","jscs":"^2.0.0","jscs-jsdoc":"^1.0.0","mdast":"^1.0.0","mdast-comment-config":"^1.0.0","mdast-github":"^1.0.0","mdast-lint":"^1.0.0","mdast-slug":"^1.0.0","mdast-validate-links":"^1.0.0","mocha":"^2.0.0"},"scripts":{"test-api":"mocha --check-leaks test.js","test-coverage":"istanbul cover _mocha -- test.js","test-travis":"npm run test-coverage","test":"npm run test-api","lint-api":"eslint .","lint-style":"jscs --reporter inline .","lint":"npm run lint-api && npm run lint-style","make":"npm run lint && npm run test-coverage","bundle":"browserify index.js --no-builtins -s arrayIterate > array-iterate.js","postbundle":"esmangle array-iterate.js > array-iterate.min.js","build-md":"mdast . --quiet","build":"npm run bundle && npm run build-md"},"gitHead":"8a8d4d42e175db72c0fa206dfc191d13dfe63a60","bugs":{"url":"https://github.com/wooorm/array-iterate/issues"},"homepage":"https://github.com/wooorm/array-iterate#readme","_id":"array-iterate@1.0.0","_shasum":"67cf333391a0fda11bb38c2ec00a104cafdb2ce3","_from":".","_npmVersion":"2.13.2","_nodeVersion":"2.5.0","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"shasum":"67cf333391a0fda11bb38c2ec00a104cafdb2ce3","tarball":"http://registry-npm.ywwl.com/array-iterate/download/array-iterate-1.0.0.tgz","integrity":"sha512-Zf0QeUZuk0dCpF+xy6QCXd+6xbWA25NSHIH2jutq/8qqDg8c2G0fKqDCJR61QFRE+vGuVyOT51xffNAkGlrUGA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHUi7aMNbMTaY80D+1UKHqyPeDtuYb/q18yECwAIu7iGAiA6DROhXrccrhLorjrdrBZBrjKmezqEyMhtdsw0cBOEWA=="}],"size":3092,"noattachment":false,"key":"/array-iterate/-/array-iterate-1.0.0.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"directories":{},"readme":"# array-iterate\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n\n[`Array#forEach()`][foreach] but it’s possible to define where to move to next.\n\n## Contents\n\n*   [What is this?](#what-is-this)\n*   [When should I use this?](#when-should-i-use-this)\n*   [Install](#install)\n*   [Use](#use)\n*   [API](#api)\n    *   [`arrayIterate(values, callbackFn[, thisArg])`](#arrayiteratevalues-callbackfn-thisarg)\n*   [Types](#types)\n*   [Compatibility](#compatibility)\n*   [Security](#security)\n*   [Contribute](#contribute)\n*   [License](#license)\n\n## What is this?\n\nA tiny package that works just like `forEach`, with one small difference.\n\n## When should I use this?\n\nYou can use this if for some weird reason—like I did—you have to sometimes\nskip a few places ahead or backwards when moving through an array.\n\n## Install\n\nThis package is [ESM only][esm].\nIn Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:\n\n```sh\nnpm install array-iterate\n```\n\nIn Deno with [Skypack][]:\n\n```js\nimport {arrayIterate} from 'https://cdn.skypack.dev/array-iterate@2?dts'\n```\n\nIn browsers with [Skypack][]:\n\n```html\n<script type=\"module\">\n  import {arrayIterate} from 'https://cdn.skypack.dev/array-iterate@2?min'\n</script>\n```\n\n## Use\n\n```js\nimport {arrayIterate} from 'array-iterate'\n\nlet first = true\n\narrayIterate(\n  [1, 2, 3, 4],\n  (value, index, values) => {\n    console.log(this, value, index, values)\n\n    // Repeat once.\n    if (first && index + 1 === values.length) {\n      first = false\n      return 0\n    }\n  },\n  {hello: 'world'}\n)\n```\n\nYields:\n\n```js\n{hello: 'world'}, 1, 0, [1, 2, 3, 4]\n{hello: 'world'}, 2, 1, [1, 2, 3, 4]\n{hello: 'world'}, 3, 2, [1, 2, 3, 4]\n{hello: 'world'}, 4, 3, [1, 2, 3, 4]\n{hello: 'world'}, 1, 0, [1, 2, 3, 4]\n{hello: 'world'}, 2, 1, [1, 2, 3, 4]\n{hello: 'world'}, 3, 2, [1, 2, 3, 4]\n{hello: 'world'}, 4, 3, [1, 2, 3, 4]\n```\n\n## API\n\nThis package exports the following identifiers: `arrayIterate`.\nThere is no default export.\n\n### `arrayIterate(values, callbackFn[, thisArg])`\n\nPerform the specified action for each element in an array (just like\n[`Array#forEach()`][foreach]).\nWhen `callbackFn` returns a `number`, moves to the element at that index\nnext.\n\n###### Parameters\n\n*   `values` (`Array<*>`)\n    — values to iterate over\n*   `callbackFn` (`Function`)\n    — function called for each element, can return the `index` to move to next\n*   `thisArg` (`*`, optional)\n    — optional object assigned as `this` in `callbackFn`\n\n###### Returns\n\n`undefined`.\n\n#### `function callbackFn(value, index, values)`\n\nCallback given to `iterate`.\n\n###### Parameters\n\n*   `this` (`*`)\n    — context object when given as `thisArg` to `arrayIterate` or `undefined`\n*   `value` (`*`)\n    — element in array\n*   `index` (`number`)\n    — index of `value` in `values`\n*   `values` (`Array.<*>`)\n    — list\n\n###### Returns\n\n`number` or `undefined` — the `index` to move to next.\n\n## Types\n\nThis package is fully typed with [TypeScript][].\nThere is also a `CallbackFn` type export that represents the callback function.\n\n## Compatibility\n\nThis package is at least compatible with all maintained versions of Node.js.\nAs of now, that is Node.js 12.20+, 14.14+, and 16.0+.\nIt also works in Deno and modern browsers.\n\n## Security\n\nThis package is safe, assuming that you don’t create an infinite loop\nby keeping on repeating.\n\n## Contribute\n\nYes please!\nSee [How to Contribute to Open Source][contribute].\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/wooorm/array-iterate/workflows/main/badge.svg\n\n[build]: https://github.com/wooorm/array-iterate/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/array-iterate.svg\n\n[coverage]: https://codecov.io/github/wooorm/array-iterate\n\n[downloads-badge]: https://img.shields.io/npm/dm/array-iterate.svg\n\n[downloads]: https://www.npmjs.com/package/array-iterate\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/array-iterate.svg\n\n[size]: https://bundlephobia.com/result?p=array-iterate\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[skypack]: https://www.skypack.dev\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[typescript]: https://www.typescriptlang.org\n\n[contribute]: https://opensource.guide/how-to-contribute/\n\n[foreach]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach\n","publish_time":1440328858549,"_cnpm_publish_time":1440328858549,"dist-tags":{"latest":"2.0.1"}}