{"id":15685077,"url":"https://github.com/ljharb/iterate-value","last_synced_at":"2025-05-07T17:28:29.299Z","repository":{"id":54830712,"uuid":"223113366","full_name":"ljharb/iterate-value","owner":"ljharb","description":"Iterate any iterable JS value. Works robustly in all environments, all versions.","archived":false,"fork":false,"pushed_at":"2022-10-27T04:59:40.000Z","size":56,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-08T17:04:41.410Z","etag":null,"topics":["iterate","iteration","iterator","javascript","value","value-iteration"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ljharb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["ljharb"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-11-21T07:24:17.000Z","updated_at":"2024-06-09T22:45:06.000Z","dependencies_parsed_at":"2022-08-14T04:10:29.548Z","dependency_job_id":null,"html_url":"https://github.com/ljharb/iterate-value","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fiterate-value","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fiterate-value/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fiterate-value/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljharb%2Fiterate-value/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ljharb","download_url":"https://codeload.github.com/ljharb/iterate-value/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234143682,"owners_count":18786212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["iterate","iteration","iterator","javascript","value","value-iteration"],"created_at":"2024-10-03T17:23:21.913Z","updated_at":"2025-01-16T03:23:19.430Z","avatar_url":"https://github.com/ljharb.png","language":"JavaScript","readme":"# iterate-value \u003csup\u003e[![Version Badge][npm-version-svg]][package-url]\u003c/sup\u003e\n\n[![github actions][actions-image]][actions-url]\n[![coverage][codecov-image]][codecov-url]\n[![dependency status][deps-svg]][deps-url]\n[![dev dependency status][dev-deps-svg]][dev-deps-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n[![npm badge][npm-badge-png]][package-url]\n\nIterate any iterable JS value. Works robustly in all environments, all versions.\n\nIn modern engines, `[...value]` or `Array.from(value)` or `for (const item of value) { }` are sufficient to iterate an iterable value (an object with a `Symbol.iterator` method). However, older engines:\n - may lack `Symbol`, array spread, or `for..of` support altogether\n - may have `Symbol.iterator` but not implement it on everything it should, like arguments objects\n - may have `Map` and `Set`, but a non-standard name for the iterator-producing method (`.iterator` or `['@@iterator']`, eg) and no syntax to support it\n - may be old versions of Firefox that produce values until they throw a StopIteration exception, rather than having iteration result objects\n - may be polyfilled/shimmed/shammed, with `es6-shim` or `core-js` or similar\n\nThis library attempts to provide an abstraction over all that complexity!\n\nIf called with a single value, it will return an array of the yielded values. If also called with a callback function, it will instead call that callback once for each yielded value.\n\nIn node v13+, `exports` is used by the `es-get-iterator` dependency to provide a lean implementation that lacks all the complexity described above, in combination with the `browser` field so that bundlers will pick up the proper implementation.\n\nIf you are targeting browsers that definitely all have Symbol support, then you can configure your bundler to replace `require('has-symbols')()` with a literal `true`, which should allow dead code elimination to reduce the size of the bundled code.\n\n## Example\n\n```js\nvar iterate = require('iterate-value');\nvar assert = require('assert');\n\nassert.deepEqual(iterate('a 💩'), ['a', ' ', '💩']);\nassert.deepEqual(iterate([1, 2]), [1, 2]);\nassert.deepEqual(iterate(new Set([1, 2])), [1, 2]);\nassert.deepEqual(iterate(new Map([[1, 2], [3, 4]])), [[1, 2], [3, 4]]);\n\nfunction assertWithCallback(iterable, expected) {\n\tvar values = [];\n\tvar callback = function (x) { values.push(x); };\n\titerate(iterable, callback);\n\tassert.deepEqual(values, expected);\n}\nassertWithCallback('a 💩', ['a', ' ', '💩']);\nassertWithCallback([1, 2], [1, 2]);\nassertWithCallback(new Set([1, 2]), [1, 2]);\nassertWithCallback(new Map([[1, 2], [3, 4]]), [[1, 2], [3, 4]]);\n```\n\n## Tests\nSimply clone the repo, `npm install`, and run `npm test`\n\n[package-url]: https://npmjs.org/package/iterate-value\n[npm-version-svg]: https://versionbadg.es/ljharb/iterate-value.svg\n[deps-svg]: https://david-dm.org/ljharb/iterate-value.svg\n[deps-url]: https://david-dm.org/ljharb/iterate-value\n[dev-deps-svg]: https://david-dm.org/ljharb/iterate-value/dev-status.svg\n[dev-deps-url]: https://david-dm.org/ljharb/iterate-value#info=devDependencies\n[npm-badge-png]: https://nodei.co/npm/iterate-value.png?downloads=true\u0026stars=true\n[license-image]: https://img.shields.io/npm/l/iterate-value.svg\n[license-url]: LICENSE\n[downloads-image]: https://img.shields.io/npm/dm/iterate-value.svg\n[downloads-url]: https://npm-stat.com/charts.html?package=iterate-value\n[codecov-image]: https://codecov.io/gh/ljharb/iterate-value/branch/main/graphs/badge.svg\n[codecov-url]: https://app.codecov.io/gh/ljharb/iterate-value/\n[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/iterate-value\n[actions-url]: https://github.com/ljharb/iterate-value/actions\n","funding_links":["https://github.com/sponsors/ljharb"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljharb%2Fiterate-value","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fljharb%2Fiterate-value","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljharb%2Fiterate-value/lists"}