{"id":15042856,"url":"https://github.com/sindresorhus/filter-obj","last_synced_at":"2025-04-12T14:18:28.978Z","repository":{"id":36161050,"uuid":"40465124","full_name":"sindresorhus/filter-obj","owner":"sindresorhus","description":"Filter object keys and values into a new object","archived":false,"fork":false,"pushed_at":"2024-05-27T10:48:45.000Z","size":38,"stargazers_count":101,"open_issues_count":1,"forks_count":9,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-03T12:11:45.445Z","etag":null,"topics":[],"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/sindresorhus.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":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2015-08-10T05:42:04.000Z","updated_at":"2025-02-07T08:42:26.000Z","dependencies_parsed_at":"2024-04-15T01:01:29.704Z","dependency_job_id":"a32f8349-5099-4ea7-9af1-430c1cd0060f","html_url":"https://github.com/sindresorhus/filter-obj","commit_stats":{"total_commits":41,"total_committers":8,"mean_commits":5.125,"dds":0.4390243902439024,"last_synced_commit":"7bcfe43cb7bfa8fd553110e0a04043e73f5e78f9"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-obj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-obj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-obj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Ffilter-obj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/filter-obj/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125583,"owners_count":21051769,"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":[],"created_at":"2024-09-24T20:48:08.938Z","updated_at":"2025-04-12T14:18:28.944Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# filter-obj\n\n\u003e Filter object keys and values into a new object\n\n## Install\n\n```sh\nnpm install filter-obj\n```\n\n## Usage\n\n```js\nimport {includeKeys, excludeKeys} from 'filter-obj';\n\nconst object = {\n\tfoo: true,\n\tbar: false\n};\n\nconst newObject = includeKeys(object, (key, value) =\u003e value === true);\n//=\u003e {foo: true}\n\nconst newObject2 = includeKeys(object, ['bar']);\n//=\u003e {bar: false}\n\nconst newObject = excludeKeys(object, (key, value) =\u003e value === true);\n//=\u003e {bar: false}\n\nconst newObject3 = excludeKeys(object, ['bar']);\n//=\u003e {foo: true}\n```\n\n## API\n\n### includeKeys(source, filter)\n### includeKeys(source, keys)\n### excludeKeys(source, filter)\n### excludeKeys(source, keys)\n\n#### source\n\nType: `object`\n\nThe source object to filter properties from.\n\n#### filter\n\nType: `(sourceKey: string | symbol, sourceValue: unknown, source: object) =\u003e boolean`\n\nA predicate function that determines whether a property should be filtered.\n\n#### keys\n\nType: `Array\u003cstring | symbol\u003e | Set\u003cstring | symbol\u003e`\n\nAn array or [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) of property keys to be filtered.\n\n## Related\n\n- [map-obj](https://github.com/sindresorhus/map-obj) - Map object keys and values into a new object\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Modules","模块"],"sub_categories":["Object","对象"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffilter-obj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Ffilter-obj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Ffilter-obj/lists"}