{"name":"array-iterate","version":"1.1.2","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"},"bugs":{"url":"https://github.com/wooorm/array-iterate/issues"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"http://wooorm.com"}],"files":["index.js"],"dependencies":{},"devDependencies":{"browserify":"^16.0.0","esmangle":"^1.0.0","nyc":"^11.0.0","prettier":"^1.12.0","remark-cli":"^5.0.0","remark-preset-wooorm":"^4.0.0","tape":"^4.4.0","xo":"^0.20.0"},"scripts":{"format":"remark . -qfo && prettier --write '**/*.js' && xo --fix","build-bundle":"browserify index.js -s arrayIterate > array-iterate.js","build-mangle":"esmangle array-iterate.js > array-iterate.min.js","build":"npm run build-bundle && npm run build-mangle","test-api":"node test","test-coverage":"nyc --reporter lcov tape test.js","test":"npm run format && npm run build && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"esnext":false,"rules":{"no-var":"off","prefer-arrow-callback":"off","guard-for-in":"off","unicorn/prefer-type-error":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"nyc":{"check-coverage":true,"lines":100,"functions":100,"branches":100},"gitHead":"add581e1d1c405a1b342b307839588a5702f6c9a","homepage":"https://github.com/wooorm/array-iterate#readme","_id":"array-iterate@1.1.2","_npmVersion":"5.6.0","_nodeVersion":"9.5.0","_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"dist":{"integrity":"sha512-1hWSHTIlG/8wtYD+PPX5AOBtKWngpDFjrsrHgZpe+JdgNGz0udYu6ZIkAa/xuenIUEqFv7DvE2Yr60jxweJSrQ==","shasum":"f66a57e84426f8097f4197fbb6c051b8e5cdf7d8","tarball":"http://registry-npm.ywwl.com/array-iterate/download/array-iterate-1.1.2.tgz","fileCount":4,"unpackedSize":6121,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa0eOfCRA9TVsSAnZWagAA0MAP/ix1oa7LZJ++amBPttXY\nBUKCZlOqzTdaPFjTpkGhNgQU/hWjBFQEXi18E8w1gomQsHHbsXeN1VZ729IE\nr5m8CD72DEo3yxYLvDBxgvmMVKqQBUTKy+80R/6nfz7X/1OAs7/zJOTNjB+m\nSOVWBxAQdmTj+TM7IGmwim3t5C8UYTNE3JXNY0tMhH46LXCpDsJeOAVXcrKq\nIWJklmRdSyjGmNHKPg+rKnL0JcdOzxxgLApZUgCEfFrPrzS2raqZDRunHES0\niVsInBCeDVdOcZRv3+rRrNn7yRfpBX7kJZXbtFG9S7oKrtQHC+ILcGZ1zZHY\ndggAs82u3gMfc7CQFmBQqE550lT/a9rp1BgXu+UD4SKXSDmWxuL5gMUX+WEk\nWKqskOkVb6eNpYmVaUvFkn5mpUEIW1pQGnkOxkORuk3qA0v8ZYJhJGU/D56L\nDg+DTZrgV9oSeQAyRePw1s81m6lGwSpORAPEe5ElMbu/foyYe2Icvcwu4QFL\notURMbN0aCar+PPoo8bFZXh0ICwVQ31y377z4IekVnQVdzpLWdljd7eUi0+d\nSD43+ykgedCEZGtg/0X3cpZXLvyNYQ3zmvJWFkqG6V6GIBR1Y3+rfD8iTGhl\nN7qnc6EIJMguNDligEPhz2m96IZLkdjLxan6Aem6FMe1V+bvIAE1KoG1glsY\n5ZN6\r\n=uuBW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCsd5dSOz+A7MS1+zX69bq0P2u5lWKAypKLSE2IdJfJ8wIhAMl8UtXEpT8SOEkGkxaTxUizXeIuhenfjCdRtkCUcz3j"}],"size":2765,"noattachment":false,"key":"/array-iterate/-/array-iterate-1.1.2.tgz"},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-iterate_1.1.2_1523704734477_0.2727673759563265"},"_hasShrinkwrap":false,"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":1523704734571,"_cnpm_publish_time":1523704734571,"dist-tags":{"latest":"2.0.1"}}