{"id":15823283,"url":"https://github.com/mesqueeb/filter-anything","last_synced_at":"2025-04-11T00:51:45.454Z","repository":{"id":33781354,"uuid":"161919952","full_name":"mesqueeb/filter-anything","owner":"mesqueeb","description":"A simple (TypeScript) integration of \"pick\" and \"omit\" to filter props of an object","archived":false,"fork":false,"pushed_at":"2025-02-19T18:49:26.000Z","size":1940,"stargazers_count":36,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T00:51:38.060Z","etag":null,"topics":["delete-props","fillables","filter","filter-fields","filter-props","guard","guarded","guarded-props","omit","pick","props-stay","typescript","wildcard"],"latest_commit_sha":null,"homepage":"https://npmjs.com/filter-anything","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/mesqueeb.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"mesqueeb","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":"2018-12-15T15:50:47.000Z","updated_at":"2025-02-19T18:49:31.000Z","dependencies_parsed_at":"2024-06-05T02:35:59.644Z","dependency_job_id":"5b7ec76b-9bca-41c1-b5de-a82730196090","html_url":"https://github.com/mesqueeb/filter-anything","commit_stats":{"total_commits":72,"total_committers":3,"mean_commits":24.0,"dds":"0.38888888888888884","last_synced_commit":"9e00598362a57d3ce85853daefe187739f8bf7b7"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffilter-anything","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffilter-anything/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffilter-anything/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mesqueeb%2Ffilter-anything/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mesqueeb","download_url":"https://codeload.github.com/mesqueeb/filter-anything/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322609,"owners_count":21084336,"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":["delete-props","fillables","filter","filter-fields","filter-props","guard","guarded","guarded-props","omit","pick","props-stay","typescript","wildcard"],"created_at":"2024-10-05T08:07:41.608Z","updated_at":"2025-04-11T00:51:45.428Z","avatar_url":"https://github.com/mesqueeb.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mesqueeb"],"categories":[],"sub_categories":[],"readme":"# Filter anything ⚔️\n\n\u003ca href=\"https://www.npmjs.com/package/filter-anything\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/filter-anything.svg\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/filter-anything\"\u003e\u003cimg src=\"https://img.shields.io/npm/dw/filter-anything.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\n```\nnpm i filter-anything\n```\n\nAn implementation that filters out object props like the TypeScript \"pick\" and \"omit\".\nIn the Laravel world, this is also called \"fillables\" and \"guard\".\n\n## Motivation\n\nI created this package because I needed:\n\n- be able to filter out object props based on just what we need - aka \"pick\" props\n- be able to filter out object props based on what we don't need - aka \"omit\" props\n- **supports for nested properties**\n- supports wildcards `*` for nested properties\n- the return type must be TypeScript supported! (see screenshots below)\n\n## Meet the family (more tiny utils with TS support)\n\n- [is-what 🙉](https://github.com/mesqueeb/is-what)\n- [is-where 🙈](https://github.com/mesqueeb/is-where)\n- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)\n- [check-anything 👁](https://github.com/mesqueeb/check-anything)\n- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)\n- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)\n- [map-anything 🗺](https://github.com/mesqueeb/map-anything)\n- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)\n- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)\n- [case-anything 🐫](https://github.com/mesqueeb/case-anything)\n- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)\n- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)\n\n## Usage\n\n### Pick\n\nWith `pick` you pass an object and an array of keys of an object - **the props which may stay**.\n\n```js\nimport { pick } from 'filter-anything'\n\nconst squirtle = { id: '007', name: 'Squirtle', type: 'water' }\n\nconst newObject = pick(squirtle, ['name', 'type'])\n// returns { name: 'Squirtle', type: 'water' }\n```\n\n### Omit\n\nWith `omit` you pass an object and an array of keys of an object - the props which should be removed.\n\n```js\nimport { omit } from 'filter-anything'\n\nconst squirtle = { id: '007', name: 'Squirtle', type: 'water' }\n\nconst withoutId = omit(squirtle, ['id'])\n// returns { name: 'Squirtle', type: 'water' }\n```\n\n### Aliases\n\n`pick()` and `omit()` can also be imported with the names `fillable()` and `guard()`. This pays homage to my history with Laravel. 😉\n\n### TypeScript\n\nTypeScript users will love this, because, as you can see, the result has the correct type automatically!\n\n![typescript example pick](https://raw.githubusercontent.com/mesqueeb/filter-anything/master/.github/typescript-pick.png)\n![typescript example omit](https://raw.githubusercontent.com/mesqueeb/filter-anything/master/.github/typescript-omit.png)\n\n### Nested props\n\nIn the example below we want to get rid of the **nested property** called \"discard\".\n\n```js\nconst doc = { items: { keep: '📌', discard: '✂️' } }\n\npick(doc, ['items.keep'])\n// returns {items: {keep: '📌'}}\n\nomit(doc, ['items.discard'])\n// returns {items: {keep: '📌'}}\n```\n\n\u003e Please note that TypeScript users will need to cast the result when using nested props.\n\n## Wildcards\n\nYes! You can also work with wildcards by using `*` in the path.\n\n```js\nconst doc = {\n  123: { keep: '📌', discard: '✂️' },\n  456: { keep: '📌', discard: '✂️' },\n}\n// use wildcard *\nomit(doc, ['*.discard'])\n// returns {\n//   '123': {keep: '📌'},\n//   '456': {keep: '📌'}\n// }\n```\n\n\u003e Please note that TypeScript users will need to cast the result when using wildcards props.\n\nFeel free to open issues for any requests, questions or bugs!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Ffilter-anything","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmesqueeb%2Ffilter-anything","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmesqueeb%2Ffilter-anything/lists"}