{"name":"array-iterate","version":"2.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"},"bugs":{"url":"https://github.com/wooorm/array-iterate/issues"},"funding":{"type":"github","url":"https://github.com/sponsors/wooorm"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","devDependencies":{"@types/tape":"^4.0.0","c8":"^7.0.0","prettier":"^2.0.0","remark-cli":"^9.0.0","remark-preset-wooorm":"^8.0.0","rimraf":"^3.0.0","tape":"^5.0.0","typescript":"^4.0.0","xo":"^0.38.0"},"scripts":{"prepublishOnly":"npm run build && npm run format","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","prebuild":"rimraf \"*.d.ts\"","build":"tsc","test-api":"node test","test-coverage":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"rules":{"no-var":"off","prefer-arrow-callback":"off","unicorn/no-this-assignment":"off","unicorn/prefer-type-error":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"gitHead":"7a5f9412112333a92692544fa00d75ea6f39386e","homepage":"https://github.com/wooorm/array-iterate#readme","_id":"array-iterate@2.0.0","_nodeVersion":"15.11.0","_npmVersion":"7.6.1","dist":{"integrity":"sha512-HNhAorCEY0NY/p+SMvcM0O2OTxZZItN0PT7pd2cXxpUlwPcQ/2ar4beOu0bS0Vkv7QRWcTfipECz/zhXUyArWg==","shasum":"901a2297f878c1d6ec5be4fea5e7ad16fa37c3e3","tarball":"http://registry-npm.ywwl.com/array-iterate/download/array-iterate-2.0.0.tgz","fileCount":5,"unpackedSize":8263,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgR1dqCRA9TVsSAnZWagAAybAP/1O53FTiP+iUYMKjHrSO\nZpQjgcRo3W8RuYsubJ5c94HZCWbl3fxQxpSRARB4GWe7/OKM/fFL4HTuNQ02\nIDBp3gHvZr1BAGoqIZPaqjFLZ7E6Wvwk7zLEMSp9k5936F7bTi3Ns1AU/CaC\neY7MAiVyj4OWG8Glu0XFdeybSfnbPsJDRiLA0+v+16HvDiYFLXBQsJoMCt3y\nEs7SF0aZ1HSpZZxqyBqCwjJzPgVytNPXpj0uTqscWLLZrnQJZtBnzHJdbxwV\nWKGeEMPxWfkWQUJFjYbn+hL86bkzb+rMRXV7ayDnXdk6MIJjqQyrQ1GqotVy\nQWO9mizzV4gLhM2JttEXRmI3nfZCix0ihuwat+GHdvX70J2EdUZZWZUszj0/\ncBpt4nhdsc/n68ZdP3havqvez0foH0HHuMjBYFzXm9saNWsnE2dPDM7zZDVx\nISpYicI1oexUJATSIIBUWhtUOyevFi2DsXVxTSRjCaUChe+vGvKw0lA8YDIS\nAeDOTEo/LLv1aLeflIpO92mGRaTqj8nOyq5vXNqKSjctNpQ717Mp9NDbkQSt\n0utMsKBPFZOzhiWXNKwdz6hOVGBUNdXfmKl90jM72nt70VhtOrYDS530LYOD\nQRJrnpBG2iijzHTDGEejSsfRnrtRie1NSADsRdG0hqvfMjzOaq/n/18do8Rb\n6+FO\r\n=E0EY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGbVEG9m35ZmUUeRra/UpuSCyiGIls4BAtEjc0LkMYsUAiEAjt71863U+ihsyXH9+l2/OPOCVH0VQAJV8sp1RlcPSyw="}],"size":3301,"noattachment":false,"key":"/array-iterate/-/array-iterate-2.0.0.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/array-iterate_2.0.0_1615288169539_0.7512623195363055"},"_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":1615288169734,"_cnpm_publish_time":1615288169734,"dist-tags":{"latest":"2.0.1"}}