{"id":19041954,"url":"https://github.com/writetome51/array-remove-by-indexes","last_synced_at":"2026-04-16T02:32:18.287Z","repository":{"id":122062365,"uuid":"155801950","full_name":"writetome51/array-remove-by-indexes","owner":"writetome51","description":"Removes items from array, identified by indexes","archived":false,"fork":false,"pushed_at":"2021-10-26T23:32:23.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T12:54:53.454Z","etag":null,"topics":["array-manipulations","items","javascript","remove","typescript"],"latest_commit_sha":null,"homepage":null,"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/writetome51.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-02T02:14:05.000Z","updated_at":"2021-10-26T23:32:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f0941a8-abe9-483a-9f1c-980eea9970a3","html_url":"https://github.com/writetome51/array-remove-by-indexes","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/writetome51/array-remove-by-indexes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-indexes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-indexes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-indexes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-indexes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/writetome51","download_url":"https://codeload.github.com/writetome51/array-remove-by-indexes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-indexes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31868495,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["array-manipulations","items","javascript","remove","typescript"],"created_at":"2024-11-08T22:33:29.824Z","updated_at":"2026-04-16T02:32:18.265Z","avatar_url":"https://github.com/writetome51.png","language":"JavaScript","readme":"# removeByIndexes\\\u003cT\\\u003e(\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;indexes: number[],\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;array: T[],\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;useRemovedItem?: (item: T) =\u003e void\u003cbr\u003e): void\n\nRemoves items, identified by `indexes`, from `array`.   \nNegative indexes not allowed.  \nOptional callback `useRemovedItem()` lets you collect each removed item  \nfor further manipulation.  \nThe algorithm first sorts `indexes` in ascending order. Then the items of  \n`array` are removed in descending index order, i.e., item with index 0 would  \nbe removed last.\n\n## Examples\n```js\nlet arr = [10,20,30,40,50,60];\nremoveByIndexes([3, 1], arr);\n// arr is now [10, 30, 50, 60].\n\n\narr = ['he', 'llo', 'zz', 'gg', 'cc'];\nlet removed = [];\n\nremoveByIndexes([4, 0], arr, (item) =\u003e removed.push(item));\n// removed is ['cc', 'he'] (remember, elements are removed in descending index order).\n// arr is ['llo', 'zz', 'gg']. \n\n\narr = [10,20,30,40,50,60];\nremoved = [];\n\nremoveByIndexes([1, 3, 5], arr, (item) =\u003e removed.push(item));\n// removed is [60, 40, 20]\n// arr is [10, 30, 50].\n\n\n// It can work with duplicate indexes, though the result may not be\n// what you wanted:\n\narr = ['he', 'llo', 'zz', 'gg', 'cc', 'aa'];\nremoveByIndexes([2, 3, 4, 4], arr);\n// arr is ['he', 'llo']\n\narr = ['he', 'llo', 'zz', 'gg', 'cc', 'aa'];\nremoveByIndexes([1, 1, 1], arr);\n// arr is ['he', 'cc', 'aa']\n\n// Don't pass string numbers. You'll get confusing errors or unexpected results.\nremoveByIndexes(['1'], arr);\n// Error: \"the array does not have enough items to fulfill your request\"\n```\n\n## Installation\n`npm i  @writetome51/array-remove-by-indexes`\n\n## Loading\n```js\nimport {removeByIndexes} from '@writetome51/array-remove-by-indexes';\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Farray-remove-by-indexes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwritetome51%2Farray-remove-by-indexes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Farray-remove-by-indexes/lists"}