{"id":15471817,"url":"https://github.com/thadeu/recollect-array-js","last_synced_at":"2026-01-22T13:48:02.748Z","repository":{"id":196760003,"uuid":"621535547","full_name":"thadeu/recollect-array-js","owner":"thadeu","description":"A simple and lightweight way to filter array using JavaScript","archived":false,"fork":false,"pushed_at":"2025-10-06T15:12:30.000Z","size":210,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-06T17:22:43.592Z","etag":null,"topics":[],"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/thadeu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["thadeu"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-03-30T21:31:31.000Z","updated_at":"2025-10-06T15:12:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"6cb10202-a98c-45fe-b574-08662ce115fc","html_url":"https://github.com/thadeu/recollect-array-js","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"77655c14e6151ebd91b9c442c17035443a0638d2"},"previous_names":["thadeu/recollect-array-js"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/thadeu/recollect-array-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Frecollect-array-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Frecollect-array-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Frecollect-array-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Frecollect-array-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thadeu","download_url":"https://codeload.github.com/thadeu/recollect-array-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thadeu%2Frecollect-array-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28663978,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T01:17:37.254Z","status":"online","status_checked_at":"2026-01-22T02:00:07.137Z","response_time":144,"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":[],"created_at":"2024-10-02T02:21:51.441Z","updated_at":"2026-01-22T13:48:02.743Z","avatar_url":"https://github.com/thadeu.png","language":"TypeScript","funding_links":["https://github.com/sponsors/thadeu"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e🔃 recollect-array-js\u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\u003ci\u003eSimple wrapper to filter array using JavaScript and simple predicate conditions\u003c/i\u003e\u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/thadeu/recollect-array-js/actions/workflows/ci.yml\"\u003e\n    \u003cimg alt=\"Build Status\" src=\"https://github.com/thadeu/recollect-array-js/actions/workflows/ci.yml/badge.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\n## Motivation\n\nBecause in sometimes, we need filter array passing conditions. This library simplify this work.\n\n## Documentation \u003c!-- omit in toc --\u003e\n\nVersion    | Documentation\n---------- | -------------\nunreleased | https://github.com/thadeu/recollect-array-js/blob/main/README.md\n\n## Table of Contents \u003c!-- omit in toc --\u003e\n  - [Installation](#installation)\n  - [Configuration](#configuration)\n  - [Availables Predicates](#availables-predicates)\n  - [Usage](#usage)\n  - [Utilities](#utilities)\n\n## Compatibility\n\n| kind           | branch  | javascript         |\n| -------------- | ------- | ------------------ |\n| unreleased     | main    | \u003e= 14.x, \u003c= 18.x |\n\n## Installation\n\nPlease prefer install directly from Github using tags or branch main\n\n```bash\nyarn add github:thadeu/recollect-array-js#main\n\n# or \n\nyarn add github:thadeu/recollect-array-js#v1.0.8\n```\n\nUse Yarn\n\n```bash\nyarn add recollect-array-js\n```\n\nor use NPM\n\n```bash\nnpm i --save recollect-array-js\n```\n\nand then, enjoy!\n\n```ts\nimport RecollectArray from 'recollect-array-js'\n```\n\n## Configuration\n\nWithout configuration, because we use only JavaScript. ❤️\n\n## Availables Predicates for all values\n\n| Type | Suffix | Value | \n| ----------- | ----------- | ----------- |\n| Equal | eq      | Anywhere |\n| NotEqual | not_eq        | Anywhere |\n| Contains | cont        | Anywhere |\n| NotContains | not_cont        | Anywhere |\n| Included | in  | Anywhere |\n| NotIncluded | not_in        | Anywhere |\n| LessThan | lt        | Anywhere |\n| LessThanEqual | lte        | Anywhere |\n| GreaterThan | gt        | Anywhere |\n| GreaterThanEqual | gte        | Anywhere |\n| GreaterThanEqual | gte        | Anywhere |\n| Empty | empty        | Anywhere |\n| Regex | reg or regex        | Anywhere |\n| NotRegex | not_reg or not_regex        | Anywhere |\n\n## Availables Predicates only when value is Object\n\n\u003e 💡 Below predicates works only when value is Object\n\n| Type | Suffix | Value | \n| ----------- | ----------- | ----------- |\n| Exists | exists        | Anywhere |\n| NotEqual | not_eq        | Object |\n| NotContains | not_cont        | Object |\n| NotIncluded | not_in        | Object |\n| NotMatches | not_matches        | Object |\n\n\n## Usage\n\n\u003cdetails\u003e\n  \u003csummary\u003eThink that your data seems like this.\u003c/summary\u003e\n  \n  ```ts\n  data = [\n    {\n      id: 1,\n      name: 'Test #1',\n      email: 'test1@email1.com',\n      schedule: { all_day: true },\n      numbers: [1, 2],\n      active: true,\n      count: 9\n    },\n    {\n      id: 2,\n      name: 'Test #2',\n      email: 'test2@email2.com',\n      schedule: { all_day: false },\n      numbers: [3, 4],\n      active: true,\n      count: 10\n    },\n    {\n      id: 3,\n      name: 'Test #3',\n      email: 'test3@email3.com',\n      schedule: { all_day: false },\n      numbers: [5, 6],\n      active: false,\n      count: 99,\n      members: null\n    }\n  ]\n  ```\n\u003c/details\u003e\n\nYou can use one or multiples predicates in your filter. We see some use cases.\n\n### Flexible Use Case (Hash)\n\n**Regex**\n\nWe going to test value with the Regex was passed to predicate, for example.\n\n```ts\nfilters = {\n  email: { regex: '.*@email3.com$' }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**Empty**\n\nWe going to check if value is has some items `[null, undefined, NaN, '', ' ']`\n\n```ts\nfilters = {\n  members: { empty: true }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**Equal**\n\n```ts\nfilters = {\n  active: { eq: true }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**NotEqual**\n\n```ts\nfilters = {\n  active: {\n    not_eq: true\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**Exists**\n\nFilter only if value be different of null or undefined\n\n```ts\nfilters = {\n  members: {\n    exists: true\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**NotExists**\n\n```ts\nfilters = {\n  members: {\n    exists: false\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**Nested Hash Paths**\n\n```ts\nfilters = {\n  'schedule.all_day': {\n    eq: true\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n**Nested Array Paths**\n\n\u003e Note the `.0` 🎉\n\n```ts\nfilters = {\n  'numbers.0': {\n    eq: '3'\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n```ts\nfilters = {\n  numbers: {\n    in: '3' // or in: ['3']\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\nUsing default Equal predicate.\n\n```ts\nRecollectArray.filter(data, { numbers: 3 })\n\nRecollectArray.filter(data, { active: true })\n\nRecollectArray.filter(data, { id: 3 })\n```\n\nIf array, you can navigate into self, using `property.NUMBER.property`\n\n```ts\ndata = [\n  {\n    schedules: [\n      {\n        opened: true,\n        all_day: true\n      },\n      {\n        opened: false,\n        all_day: true\n      }\n    ]\n  },\n  {\n    schedules: [\n      {\n        opened: false,\n        all_day: true\n      },\n      {\n        opened: false,\n        all_day: true\n      }\n    ]\n  }\n]\n\nfilters = {\n  'schedules.0.opened': {\n    eq: true\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n\n# [{ schedules: [{ opened: true, all_day: true }, { opened: false, all_day: true }] }]\n```\n\nAmazing, you can pass a Function value as value, like this.\n\n```javascript\nfilters = {\n  'schedules.0.opened': { eq: () =\u003e true }\n}\n\ncollection = Recollect::Array.filter(data, filters)\n```\n\n**Combine conditions**\n\nYes, you can combine one or multiple predicates to filter you array.\n\n\n```ts\nfilters = {\n  active: { eq: true },\n  numbers: {\n    in: [5],\n    not_in: '10'\n  },\n  email: {\n    cont: 'email1',\n    not_cont: '@gmail'\n  },\n  'schedule.all_day': {\n    in: [true, false]\n  }\n}\n\ncollection = RecollectArray.filter(data, filters)\n```\n\n[⬆️ \u0026nbsp;Back to Top](#table-of-contents-)\n\n## Development\n\nAfter checking out the repo, install dependencies. Then, run `yarn test` to run the tests.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/thadeu/recollect-array-js. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/thadeu/recollect-array-js/blob/master/CODE_OF_CONDUCT.md).\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthadeu%2Frecollect-array-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthadeu%2Frecollect-array-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthadeu%2Frecollect-array-js/lists"}