{"id":21831343,"url":"https://github.com/nodef/extra-iterable","last_synced_at":"2025-04-14T07:07:24.214Z","repository":{"id":33824003,"uuid":"133694055","full_name":"nodef/extra-iterable","owner":"nodef","description":"An iterable is a sequence of values.","archived":false,"fork":false,"pushed_at":"2025-04-08T16:43:57.000Z","size":1237,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T16:53:05.855Z","etag":null,"topics":["accumulate","cartesian-product","chunk","compare","concat","copy","copy-within","count","count-as","cut","cut-at","cut-at-right","cut-right","cycle","difference","drop","drop-right","drop-while","extra","iterable"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/extra-iterable","language":"TypeScript","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/nodef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-16T16:23:44.000Z","updated_at":"2025-04-08T16:43:58.000Z","dependencies_parsed_at":"2024-06-18T21:34:05.614Z","dependency_job_id":"8c438b9e-87d0-4f9a-bad3-6083848a6328","html_url":"https://github.com/nodef/extra-iterable","commit_stats":{"total_commits":321,"total_committers":1,"mean_commits":321.0,"dds":0.0,"last_synced_commit":"0b7c5abe33188ec4bcac56175f29a38de0b0ca22"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-iterable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-iterable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-iterable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-iterable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodef","download_url":"https://codeload.github.com/nodef/extra-iterable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248058589,"owners_count":21040777,"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":["accumulate","cartesian-product","chunk","compare","concat","copy","copy-within","count","count-as","cut","cut-at","cut-at-right","cut-right","cycle","difference","drop","drop-right","drop-while","extra","iterable"],"created_at":"2024-11-27T19:09:46.571Z","updated_at":"2025-04-14T07:07:24.197Z","avatar_url":"https://github.com/nodef.png","language":"TypeScript","readme":"An [iterable] is a sequence of values.\u003cbr\u003e\n📦 [Node.js](https://www.npmjs.com/package/extra-iterable),\n🌐 [Web](https://www.npmjs.com/package/extra-iterable.web),\n📜 [Files](https://unpkg.com/extra-iterable/),\n📰 [Docs](https://nodef.github.io/extra-iterable/),\n📘 [Wiki](https://github.com/nodef/extra-iterable/wiki/).\n\nThis is a collection of functions for operating upon **iterables**. Assumption\nhere is that an **iterable** can *only* be iterated over *once*. Methods which\nrequire multiple iterations preserve old values in a backup array using\n[toMany]. Many methods accept both compare and map functions, and in some cases\nusing **only** a map function enables *faster comparision* (like [unique]). I\nborrowed a lot of ideas from Haskell, Elm, Python, Basic, Lodash, and other NPM\npackages. These are mentioned in references of each method.\n\nThis package is available in *Node.js* and *Web* formats. To use it on the web,\nsimply use the `extra_iterable` global variable after loading with a `\u003cscript\u003e`\ntag from the [jsDelivr CDN].\n\n\u003e Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).\n\n[iterable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\n[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-iterable.web/index.js\n\n\u003cbr\u003e\n\n```javascript\nconst xiterable = require('extra-iterable');\n// import * as xiterable from \"extra-iterable\";\n// import * as xiterable from \"https://unpkg.com/extra-iterable/index.mjs\"; (deno)\n\nvar x = [2, 4, 6, 8];\nxiterable.get(x, 1);\n// → 4\n\nvar x = [1, 2, 3, 4];\n[...xiterable.swap(x, 0, 1)];\n// → [ 2, 1, 3, 4 ]\n\nvar x = [1, 2, 3];\n[...xiterable.cycle(x, 0, 4)];\n// → [1, 2, 3, 1]\n\nvar x = [1, 2, 3, 4];\nxiterable.reduce(x, (acc, v) =\u003e acc+v);\n// → 10\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## Index\n\n| Property | Description |\n|  ----  |  ----  |\n| [is] | Check if value is an iterable. |\n| [isIterator] | Check if value is an iterator. |\n| [isList] | Check if value is a list (iterable \u0026 !string). |\n| [iterator] | Get iterator of an iterable. |\n| [keys] | List all indices. |\n| [values] | List all values. |\n| [entries] | List all index-value pairs. |\n|  |  |\n| [from] | Convert an iterable-like to iterable. |\n| [fromIterator] | Convert an iterator to iterable. |\n| [fromRange] | Generate iterable from given number range. |\n| [fromInvocation] | Generate iterable from repeated function invocation. |\n| [fromApplication] | Generate iterable from repeated function application. |\n|  |  |\n| [isOnce] | Check if an iterable can iterated only once. |\n| [isMany] | Check if an iterable can be iterated many times. |\n| [toMany] | Convert a once-like iterable to many. |\n| [toInvokable] | Generate a function that iterates over values upon invocation. |\n|  |  |\n| [isEmpty] | Check if an iterable is empty. |\n| [length] | Find the length of an iterable. |\n|  |  |\n| [compare] | Compare two iterables. |\n| [isEqual] | Check if two iterables are equal. |\n|  |  |\n| [index] | Get zero-based index for element in iterable. |\n| [indexRange] | Get index range for part of iterable. |\n| [get] | Get value at index. |\n| [getAll] | Get values at indices. |\n| [getPath] | Get value at path in a nested iterable. |\n| [hasPath] | Check if nested iterable has a path. |\n| [set] | Set value at index. |\n| [swap] | Exchange two values. |\n| [remove] | Remove value at index. |\n|  |  |\n| [count] | Count values which satisfy a test. |\n| [countAs] | Count occurrences of values. |\n| [min] | Find smallest value. |\n| [max] | Find largest value. |\n| [range] | Find smallest and largest values. |\n| [minEntry] | Find smallest entry. |\n| [maxEntry] | Find largest entry. |\n| [rangeEntries] | Find smallest and largest entries. |\n|  |  |\n| [slice] | Get part of an iterable. |\n| [head] | Get first value. |\n| [last] | Get last value. |\n| [tail] | Get values except first. |\n| [init] | Get values except last. |\n| [left] | Get values from left. |\n| [right] | Get values from right. |\n| [middle] | Get values from middle. |\n| [take] | Keep first n values only. |\n| [takeRight] | Keep last n values only. |\n| [takeWhile] | Keep values from left, while a test passes. |\n| [takeWhileRight] | Keep values from right, while a test passes. |\n| [drop] | Discard first n values only. |\n| [dropRight] | Discard last n values only. |\n| [dropWhile] | Discard values from left, while a test passes. |\n| [dropWhileRight] | Discard values from right, while a test passes. |\n|  |  |\n| [includes] | Check if iterable has a value. |\n| [indexOf] | Find first index of a value. |\n| [lastIndexOf] | Find last index of a value. |\n| [find] | Find first value passing a test. |\n| [findRight] | Find last value passing a test. |\n| [scanWhile] | Scan from left, while a test passes. |\n| [scanWhileRight] | Scan from right, while a test passes. |\n| [scanUntil] | Scan from left, until a test passes. |\n| [scanUntilRight] | Scan from right, until a test passes. |\n| [search] | Find index of first value passing a test. |\n| [searchRight] | Find index of last value passing a test. |\n| [searchAll] | Find indices of values passing a test. |\n| [searchValue] | Find first index of a value. |\n| [searchValueRight] | Find last index of a value. |\n| [searchValueAll] | Find indices of a value. |\n| [searchInfix] | Find first index of an infix. |\n| [searchInfixRight] | Find last index of an infix. |\n| [searchInfixAll] | Find indices of an infix. |\n| [searchSubsequence] | Find first index of a subsequence. |\n| [hasValue] | Check if iterable has a value. |\n| [hasPrefix] | Check if iterable starts with a prefix. |\n| [hasSuffix] | Check if iterable ends with a suffix. |\n| [hasInfix] | Check if iterable contains an infix. |\n| [hasSubsequence] | Check if iterable has a subsequence. |\n|  |  |\n| [forEach] | Call a function for each value. |\n| [some] | Check if any value satisfies a test. |\n| [every] | Check if all values satisfy a test. |\n| [map] | Transform values of an iterable. |\n| [reduce] | Reduce values of iterable to a single value. |\n| [filter] | Keep the values which pass a test. |\n| [filterAt] | Keep the values at given indices. |\n| [reject] | Discard the values which pass a test. |\n| [rejectAt] | Discard the values at given indices. |\n| [accumulate] | Produce accumulating values. |\n| [flat] | Flatten nested iterable to given depth. |\n| [flatMap] | Flatten nested iterable, based on map function. |\n| [zip] | Combine values from iterables. |\n|  |  |\n| [fill] | Fill with given value. |\n| [push] | Add values to the end. |\n| [unshift] | Add values to the start. |\n| [copy] | Copy part of iterable to another. |\n| [copyWithin] | Copy part of iterable within. |\n| [moveWithin] | Move part of iterable within. |\n| [splice] | Remove or replaces existing values. |\n| [split] | Break iterable considering test as separator. |\n| [splitAt] | Break iterable considering indices as separator. |\n| [cut] | Break iterable when test passes. |\n| [cutRight] | Break iterable after test passes. |\n| [cutAt] | Break iterable at given indices. |\n| [cutAtRight] | Break iterable after given indices. |\n| [group] | Keep similar values together and in order. |\n| [partition] | Segregate values by test result. |\n| [partitionAs] | Segregate values by similarity. |\n| [chunk] | Break iterable into chunks of given size. |\n| [cycle] | Obtain values that cycle through an iterable. |\n| [repeat] | Repeat an iterable given times. |\n| [reverse] | Reverse the values. |\n| [rotate] | Rotate values in iterable. |\n| [intersperse] | Place a separator between every value. |\n| [interpolate] | Estimate new values between existing ones. |\n| [intermix] | Place values of an iterable between another. |\n| [interleave] | Place values from iterables alternately. |\n|  |  |\n| [concat] | Append values from iterables. |\n| [merge] | Merge values from sorted iterables. |\n| [join] | Join values together into a string. |\n|  |  |\n| [isUnique] | Check if there are no duplicate values. |\n| [isDisjoint] | Checks if arrays have no value in common. |\n| [unique] | Remove duplicate values. |\n| [union] | Obtain values present in any iterable. |\n| [intersection] | Obtain values present in both iterables. |\n| [difference] | Obtain values not present in another iterable. |\n| [symmetricDifference] | Obtain values not present in both iterables. |\n| [cartesianProduct] | List cartesian product of iterables. |\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n[![](https://img.youtube.com/vi/qgxPbqDskyw/maxresdefault.jpg)](https://www.youtube.com/watch?v=qgxPbqDskyw)\u003cbr\u003e\n[![ORG](https://img.shields.io/badge/org-nodef-green?logo=Org)](https://nodef.github.io)\n[![DOI](https://zenodo.org/badge/133694055.svg)](https://zenodo.org/badge/latestdoi/133694055)\n[![Coverage Status](https://coveralls.io/repos/github/nodef/extra-iterable/badge.svg?branch=master)](https://coveralls.io/github/nodef/extra-iterable?branch=master)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/1ba4b1b22418456df9f9/test_coverage)](https://codeclimate.com/github/nodef/extra-iterable/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/1ba4b1b22418456df9f9/maintainability)](https://codeclimate.com/github/nodef/extra-iterable/maintainability)\n![](https://ga-beacon.deno.dev/G-RC63DPBH3P:SH3Eq-NoQ9mwgYeHWxu7cw/github.com/nodef/extra-iterable)\n\n\n[is]: https://github.com/nodef/extra-iterable/wiki/is\n[isIterator]: https://github.com/nodef/extra-iterable/wiki/isIterator\n[isList]: https://github.com/nodef/extra-iterable/wiki/isList\n[iterator]: https://github.com/nodef/extra-iterable/wiki/iterator\n[keys]: https://github.com/nodef/extra-iterable/wiki/keys\n[values]: https://github.com/nodef/extra-iterable/wiki/values\n[entries]: https://github.com/nodef/extra-iterable/wiki/entries\n[from]: https://github.com/nodef/extra-iterable/wiki/from\n[fromIterator]: https://github.com/nodef/extra-iterable/wiki/fromIterator\n[fromRange]: https://github.com/nodef/extra-iterable/wiki/fromRange\n[fromInvocation]: https://github.com/nodef/extra-iterable/wiki/fromInvocation\n[fromApplication]: https://github.com/nodef/extra-iterable/wiki/fromApplication\n[isOnce]: https://github.com/nodef/extra-iterable/wiki/isOnce\n[isMany]: https://github.com/nodef/extra-iterable/wiki/isMany\n[toMany]: https://github.com/nodef/extra-iterable/wiki/toMany\n[toInvokable]: https://github.com/nodef/extra-iterable/wiki/toInvokable\n[isEmpty]: https://github.com/nodef/extra-iterable/wiki/isEmpty\n[length]: https://github.com/nodef/extra-iterable/wiki/length\n[compare]: https://github.com/nodef/extra-iterable/wiki/compare\n[isEqual]: https://github.com/nodef/extra-iterable/wiki/isEqual\n[index]: https://github.com/nodef/extra-iterable/wiki/index\n[indexRange]: https://github.com/nodef/extra-iterable/wiki/indexRange\n[get]: https://github.com/nodef/extra-iterable/wiki/get\n[getAll]: https://github.com/nodef/extra-iterable/wiki/getAll\n[getPath]: https://github.com/nodef/extra-iterable/wiki/getPath\n[hasPath]: https://github.com/nodef/extra-iterable/wiki/hasPath\n[set]: https://github.com/nodef/extra-iterable/wiki/set\n[swap]: https://github.com/nodef/extra-iterable/wiki/swap\n[remove]: https://github.com/nodef/extra-iterable/wiki/remove\n[count]: https://github.com/nodef/extra-iterable/wiki/count\n[countAs]: https://github.com/nodef/extra-iterable/wiki/countAs\n[min]: https://github.com/nodef/extra-iterable/wiki/min\n[max]: https://github.com/nodef/extra-iterable/wiki/max\n[range]: https://github.com/nodef/extra-iterable/wiki/range\n[minEntry]: https://github.com/nodef/extra-iterable/wiki/minEntry\n[maxEntry]: https://github.com/nodef/extra-iterable/wiki/maxEntry\n[rangeEntries]: https://github.com/nodef/extra-iterable/wiki/rangeEntries\n[slice]: https://github.com/nodef/extra-iterable/wiki/slice\n[head]: https://github.com/nodef/extra-iterable/wiki/head\n[last]: https://github.com/nodef/extra-iterable/wiki/last\n[tail]: https://github.com/nodef/extra-iterable/wiki/tail\n[init]: https://github.com/nodef/extra-iterable/wiki/init\n[left]: https://github.com/nodef/extra-iterable/wiki/left\n[right]: https://github.com/nodef/extra-iterable/wiki/right\n[middle]: https://github.com/nodef/extra-iterable/wiki/middle\n[take]: https://github.com/nodef/extra-iterable/wiki/take\n[takeRight]: https://github.com/nodef/extra-iterable/wiki/takeRight\n[takeWhile]: https://github.com/nodef/extra-iterable/wiki/takeWhile\n[takeWhileRight]: https://github.com/nodef/extra-iterable/wiki/takeWhileRight\n[drop]: https://github.com/nodef/extra-iterable/wiki/drop\n[dropRight]: https://github.com/nodef/extra-iterable/wiki/dropRight\n[dropWhile]: https://github.com/nodef/extra-iterable/wiki/dropWhile\n[dropWhileRight]: https://github.com/nodef/extra-iterable/wiki/dropWhileRight\n[includes]: https://github.com/nodef/extra-iterable/wiki/includes\n[indexOf]: https://github.com/nodef/extra-iterable/wiki/indexOf\n[lastIndexOf]: https://github.com/nodef/extra-iterable/wiki/lastIndexOf\n[find]: https://github.com/nodef/extra-iterable/wiki/find\n[findRight]: https://github.com/nodef/extra-iterable/wiki/findRight\n[scanWhile]: https://github.com/nodef/extra-iterable/wiki/scanWhile\n[scanWhileRight]: https://github.com/nodef/extra-iterable/wiki/scanWhileRight\n[scanUntil]: https://github.com/nodef/extra-iterable/wiki/scanUntil\n[scanUntilRight]: https://github.com/nodef/extra-iterable/wiki/scanUntilRight\n[search]: https://github.com/nodef/extra-iterable/wiki/search\n[searchRight]: https://github.com/nodef/extra-iterable/wiki/searchRight\n[searchAll]: https://github.com/nodef/extra-iterable/wiki/searchAll\n[searchValue]: https://github.com/nodef/extra-iterable/wiki/searchValue\n[searchValueRight]: https://github.com/nodef/extra-iterable/wiki/searchValueRight\n[searchValueAll]: https://github.com/nodef/extra-iterable/wiki/searchValueAll\n[searchInfix]: https://github.com/nodef/extra-iterable/wiki/searchInfix\n[searchInfixRight]: https://github.com/nodef/extra-iterable/wiki/searchInfixRight\n[searchInfixAll]: https://github.com/nodef/extra-iterable/wiki/searchInfixAll\n[searchSubsequence]: https://github.com/nodef/extra-iterable/wiki/searchSubsequence\n[hasValue]: https://github.com/nodef/extra-iterable/wiki/hasValue\n[hasPrefix]: https://github.com/nodef/extra-iterable/wiki/hasPrefix\n[hasSuffix]: https://github.com/nodef/extra-iterable/wiki/hasSuffix\n[hasInfix]: https://github.com/nodef/extra-iterable/wiki/hasInfix\n[hasSubsequence]: https://github.com/nodef/extra-iterable/wiki/hasSubsequence\n[forEach]: https://github.com/nodef/extra-iterable/wiki/forEach\n[some]: https://github.com/nodef/extra-iterable/wiki/some\n[every]: https://github.com/nodef/extra-iterable/wiki/every\n[map]: https://github.com/nodef/extra-iterable/wiki/map\n[reduce]: https://github.com/nodef/extra-iterable/wiki/reduce\n[filter]: https://github.com/nodef/extra-iterable/wiki/filter\n[filterAt]: https://github.com/nodef/extra-iterable/wiki/filterAt\n[reject]: https://github.com/nodef/extra-iterable/wiki/reject\n[rejectAt]: https://github.com/nodef/extra-iterable/wiki/rejectAt\n[accumulate]: https://github.com/nodef/extra-iterable/wiki/accumulate\n[flat]: https://github.com/nodef/extra-iterable/wiki/flat\n[flatMap]: https://github.com/nodef/extra-iterable/wiki/flatMap\n[zip]: https://github.com/nodef/extra-iterable/wiki/zip\n[fill]: https://github.com/nodef/extra-iterable/wiki/fill\n[push]: https://github.com/nodef/extra-iterable/wiki/push\n[unshift]: https://github.com/nodef/extra-iterable/wiki/unshift\n[copy]: https://github.com/nodef/extra-iterable/wiki/copy\n[copyWithin]: https://github.com/nodef/extra-iterable/wiki/copyWithin\n[moveWithin]: https://github.com/nodef/extra-iterable/wiki/moveWithin\n[splice]: https://github.com/nodef/extra-iterable/wiki/splice\n[split]: https://github.com/nodef/extra-iterable/wiki/split\n[splitAt]: https://github.com/nodef/extra-iterable/wiki/splitAt\n[cut]: https://github.com/nodef/extra-iterable/wiki/cut\n[cutRight]: https://github.com/nodef/extra-iterable/wiki/cutRight\n[cutAt]: https://github.com/nodef/extra-iterable/wiki/cutAt\n[cutAtRight]: https://github.com/nodef/extra-iterable/wiki/cutAtRight\n[group]: https://github.com/nodef/extra-iterable/wiki/group\n[partition]: https://github.com/nodef/extra-iterable/wiki/partition\n[partitionAs]: https://github.com/nodef/extra-iterable/wiki/partitionAs\n[chunk]: https://github.com/nodef/extra-iterable/wiki/chunk\n[cycle]: https://github.com/nodef/extra-iterable/wiki/cycle\n[repeat]: https://github.com/nodef/extra-iterable/wiki/repeat\n[reverse]: https://github.com/nodef/extra-iterable/wiki/reverse\n[rotate]: https://github.com/nodef/extra-iterable/wiki/rotate\n[intersperse]: https://github.com/nodef/extra-iterable/wiki/intersperse\n[interpolate]: https://github.com/nodef/extra-iterable/wiki/interpolate\n[intermix]: https://github.com/nodef/extra-iterable/wiki/intermix\n[interleave]: https://github.com/nodef/extra-iterable/wiki/interleave\n[concat]: https://github.com/nodef/extra-iterable/wiki/concat\n[merge]: https://github.com/nodef/extra-iterable/wiki/merge\n[join]: https://github.com/nodef/extra-iterable/wiki/join\n[isUnique]: https://github.com/nodef/extra-iterable/wiki/isUnique\n[isDisjoint]: https://github.com/nodef/extra-iterable/wiki/isDisjoint\n[unique]: https://github.com/nodef/extra-iterable/wiki/unique\n[union]: https://github.com/nodef/extra-iterable/wiki/union\n[intersection]: https://github.com/nodef/extra-iterable/wiki/intersection\n[difference]: https://github.com/nodef/extra-iterable/wiki/difference\n[symmetricDifference]: https://github.com/nodef/extra-iterable/wiki/symmetricDifference\n[cartesianProduct]: https://github.com/nodef/extra-iterable/wiki/cartesianProduct\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fextra-iterable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodef%2Fextra-iterable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fextra-iterable/lists"}