{"id":19042013,"url":"https://github.com/writetome51/array-remove-by-test","last_synced_at":"2025-02-21T22:44:40.920Z","repository":{"id":122062364,"uuid":"151037119","full_name":"writetome51/array-remove-by-test","owner":"writetome51","description":"Function that removes items from the array that match the criteria of the test function","archived":false,"fork":false,"pushed_at":"2020-09-09T20:53:30.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T12:53:18.342Z","etag":null,"topics":["array","array-manipulations","filter","items","javascript","remove","typescript"],"latest_commit_sha":null,"homepage":null,"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/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-10-01T04:39:06.000Z","updated_at":"2020-09-09T20:53:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"fbca85aa-61f2-4a9f-912f-403542c41255","html_url":"https://github.com/writetome51/array-remove-by-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Farray-remove-by-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/writetome51","download_url":"https://codeload.github.com/writetome51/array-remove-by-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240100512,"owners_count":19747683,"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":["array","array-manipulations","filter","items","javascript","remove","typescript"],"created_at":"2024-11-08T22:33:56.502Z","updated_at":"2025-02-21T22:44:40.901Z","avatar_url":"https://github.com/writetome51.png","language":"TypeScript","readme":"# removeByTest(\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;test: (value, index?, array?) =\u003e boolean,\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;array,\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;useRemovedItem?: (\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;value, index?, array?\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;) =\u003e void\u003cbr\u003e):  void\n\nRemoves any item in `array` that passes a `test`.  \nIf you use the optional callback `useRemovedItem()`, remember that this function   \nremoves items in descending index-order, i.e., item with index 0 is removed last.\n\n## Example\n```js\nlet arr = [1,2,3,4,5,6,7,8,9,10];\n\nremoveByTest((item) =\u003e (item % 2) === 0,  arr);\nconsole.log(arr);\n// [1,3,5,7,9]\n\n  \narr = [ [10, 2, 3], [2, 3, 4], 1, 6, false, [10, 20] ];\n\nremoveByTest(\n    (item) =\u003e (Array.isArray(item) \u0026\u0026 item[0] === 10),\n    arr\n);\nconsole.log(arr);\n// [ [2, 3, 4], 1, 6, false ]\n\n\n// Collect the indexes of removed items:\n\narr = [10, 1, 20, 2, 30, 3, 40, 4];\n\nlet found = [];\nremoveByTest(\n    (value) =\u003e value \u003e= 10, \n    arr, \n    (value, index) =\u003e found.push(index)\n);\nconsole.log(found);\n// [ 6, 4, 2, 0 ] \n// (items removed in descending index-order)\n```\n\n## Installation\n```bash\nnpm i @writetome51/array-remove-by-test\n```\n\n## Loading\n```js\nimport {removeByTest} from '@writetome51/array-remove-by-test';\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Farray-remove-by-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwritetome51%2Farray-remove-by-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Farray-remove-by-test/lists"}