{"id":38278452,"url":"https://github.com/chans-open-source/any-foreach","last_synced_at":"2026-01-17T01:55:13.528Z","repository":{"id":57180863,"uuid":"185019984","full_name":"chans-open-source/any-foreach","owner":"chans-open-source","description":"可迭代任何内容","archived":false,"fork":false,"pushed_at":"2019-05-06T07:35:00.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-01T04:54:05.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chans-open-source.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-05T11:05:43.000Z","updated_at":"2019-05-06T07:35:02.000Z","dependencies_parsed_at":"2022-09-26T17:00:36.249Z","dependency_job_id":null,"html_url":"https://github.com/chans-open-source/any-foreach","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chans-open-source/any-foreach","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chans-open-source%2Fany-foreach","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chans-open-source%2Fany-foreach/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chans-open-source%2Fany-foreach/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chans-open-source%2Fany-foreach/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chans-open-source","download_url":"https://codeload.github.com/chans-open-source/any-foreach/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chans-open-source%2Fany-foreach/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28491823,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T00:50:05.742Z","status":"ssl_error","status_checked_at":"2026-01-17T00:43:11.982Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T01:55:13.419Z","updated_at":"2026-01-17T01:55:13.500Z","avatar_url":"https://github.com/chans-open-source.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# any-foreach\n\u003e Iterate over anything.Can be break anywhere.\n\n\u003e 可迭代任何内容，可在任意地方中断。\n\n## Install\n```cmd\n// npm\nnpm init\nnpm i any-foreach\n\n// or yarn\nyarn init\nyarn add any-foreach\n```\n\n\n## Import\n```js\nconst AnyFor = require('any-foreach')\n// or\nimport AnyFor from 'any-foreach'\n```\n## Iterate\n### Array\n```js\nAnyFor([-1, 0, 1, 2]).for((item, key, originObject) =\u003e {\n  // TODO\n  // -1, 0, [-1, 0, 1, 2]\n  // 0, 1, [-1, 0, 1, 2]\n  // ...\n})\n```\n\n### Object\n```js\nAnyFor({ 0: 1, 1: 2, 2: 3 }).for((item, key, originObject) =\u003e {\n  // TODO\n  // 1, 0, { 0: 1, 1: 2, 2: 3 }\n  // 2, 1, { 0: 1, 1: 2, 2: 3 }\n  // 3, 2, { 0: 1, 1: 2, 2: 3 }\n})\n```\n\n### NodeList\n```js\nconst elementList = document.querySelectorAll('elements')\nAnyFor(elementList).for((item, key, originObject) =\u003e {\n  // TODO\n  // elementItem, elementIndex, elementList\n})\n```\n\n## Iterate by key\n```js\nconst object = {\n  a: {\n    k: 1\n  },\n  b: {\n    k: 2\n  },\n  c: {\n    k: 3\n  }\n}\n\nAnyFor(object).byKey('k', (item, key, originObject, originItem) =\u003e {\n  // TODO\n  // 1 'a' { a: { k: 1 }, b: { k: 2 }, c: { k: 3 } } { k: 1 }\n  // 2 'b' { a: { k: 1 }, b: { k: 2 }, c: { k: 3 } } { k: 2 }\n  // 3 'c' { a: { k: 1 }, b: { k: 2 }, c: { k: 3 } } { k: 3 }\n})\n```\n\n## Break\n\u003e Return true will break the iterate.\n```js\nAnyFor([-1, 0, 1, 2]).for((item, key, originObject) =\u003e {\n  // TODO\n  // Break when item is 1\n  if(item === 1){\n    return true\n  }\n  // -1, 0, [-1, 0, 1, 2]\n  // 0, 1, [-1, 0, 1, 2]\n  // 1, 2, [-1, 0, 1, 2]\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchans-open-source%2Fany-foreach","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchans-open-source%2Fany-foreach","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchans-open-source%2Fany-foreach/lists"}