{"id":15538908,"url":"https://github.com/buschtoens/combine-type-predicates","last_synced_at":"2025-04-23T15:42:20.533Z","repository":{"id":38358628,"uuid":"252237757","full_name":"buschtoens/combine-type-predicates","owner":"buschtoens","description":"Combine user-defined type guards / type predicates as unions and intersections.","archived":false,"fork":false,"pushed_at":"2023-12-15T14:48:37.000Z","size":85,"stargazers_count":7,"open_issues_count":12,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-09T12:42:36.974Z","etag":null,"topics":["intersection-types","type-guard","type-guards","type-predicates","typescript","union-types"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/buschtoens.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":"2020-04-01T17:06:26.000Z","updated_at":"2022-10-11T00:31:17.000Z","dependencies_parsed_at":"2025-03-05T23:30:53.421Z","dependency_job_id":null,"html_url":"https://github.com/buschtoens/combine-type-predicates","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fcombine-type-predicates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fcombine-type-predicates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fcombine-type-predicates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buschtoens%2Fcombine-type-predicates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buschtoens","download_url":"https://codeload.github.com/buschtoens/combine-type-predicates/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250462442,"owners_count":21434586,"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":["intersection-types","type-guard","type-guards","type-predicates","typescript","union-types"],"created_at":"2024-10-02T12:07:46.891Z","updated_at":"2025-04-23T15:42:20.515Z","avatar_url":"https://github.com/buschtoens.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# combine-type-predicates\n\n[![CI](https://github.com/buschtoens/combine-type-predicates/workflows/CI/badge.svg)](https://github.com/buschtoens/combine-type-predicates/actions)\n[![npm version](https://badge.fury.io/js/combine-type-predicates.svg)](http://badge.fury.io/js/combine-type-predicates)\n[![Download Total](https://img.shields.io/npm/dt/combine-type-predicates.svg)](http://badge.fury.io/js/combine-type-predicates)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)  \n[![Dependabot enabled](https://img.shields.io/badge/dependabot-enabled-blue.svg?logo=dependabot)](https://dependabot.com/)\n[![dependencies Status](https://david-dm.org/buschtoens/combine-type-predicates/status.svg)](https://david-dm.org/buschtoens/combine-type-predicates)\n[![devDependencies Status](https://david-dm.org/buschtoens/combine-type-predicates/dev-status.svg)](https://david-dm.org/buschtoens/combine-type-predicates?type=dev)\n\nCombine [user-defined type guards / type predicates][user-defined-type-guards]\nas [unions][union] and [intersections][intersection].\n\n[user-defined-type-guards]: https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards\n[union]: https://www.typescriptlang.org/docs/handbook/advanced-types.html#union-types\n[intersection]: https://www.typescriptlang.org/docs/handbook/advanced-types.html#intersection-types\n\n```ts\nimport { isSome, isEvery } from 'combine-type-predicates';\n\ntype Foo = { foo: boolean; baz: number };\ntype Bar = { bar: symbol; baz: string };\n\nconst isFoo = (v: unknown): v is Foo\n  =\u003e typeof v.foo === 'boolean' \u0026\u0026 typeof v.baz === 'number';\nconst isBar = (v: unknown): v is Bar\n  =\u003e typeof v.bar === 'symbol' \u0026\u0026 typeof v.baz === 'string';\n\nconst isFooOrBar = isSome(isFoo, isBar);\n// =\u003e (subject: unknown) =\u003e subject is Foo | Bar\n\nconst isFooAndBar = isEvery(isFoo, isBar);\n// =\u003e (subject: unknown) =\u003e subject is Foo \u0026 Bar\n\nconst x: unknown = undefined;\n\nif (isFooOrBar(x)) {\n  x.baz; // =\u003e string | number\n\n  if ('foo' in x) {\n    x.foo; // =\u003e boolean\n  } else {\n    x.bar; // =\u003e symbol\n  }\n}\n\nif (isFooAndBar(x)) {\n  x.foo; // =\u003e boolean\n  x.bar; // =\u003e symbol\n  x.baz; // =\u003e never (no such thing as `string \u0026 number`)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuschtoens%2Fcombine-type-predicates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuschtoens%2Fcombine-type-predicates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuschtoens%2Fcombine-type-predicates/lists"}