{"id":17774814,"url":"https://github.com/rickwong/match-with","last_synced_at":"2025-04-21T23:32:09.273Z","repository":{"id":57291867,"uuid":"172674556","full_name":"RickWong/match-with","owner":"RickWong","description":"🧩 Pattern matching objects","archived":false,"fork":false,"pushed_at":"2020-08-27T00:41:35.000Z","size":386,"stargazers_count":4,"open_issues_count":9,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T20:56:52.122Z","etag":null,"topics":["compare","deep","exists","fasly","match","matching","object","pattern","structures","truthy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RickWong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-26T08:57:42.000Z","updated_at":"2021-03-26T14:18:46.000Z","dependencies_parsed_at":"2022-08-27T12:20:35.982Z","dependency_job_id":null,"html_url":"https://github.com/RickWong/match-with","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/RickWong%2Fmatch-with","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Fmatch-with/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Fmatch-with/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RickWong%2Fmatch-with/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RickWong","download_url":"https://codeload.github.com/RickWong/match-with/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250150876,"owners_count":21383240,"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":["compare","deep","exists","fasly","match","matching","object","pattern","structures","truthy"],"created_at":"2024-10-26T21:52:22.895Z","updated_at":"2025-04-21T23:32:09.013Z","avatar_url":"https://github.com/RickWong.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧩 match-with\n\nPattern matching object structures. Semi-related to [tc39/proposal-pattern-matching](https://github.com/tc39/proposal-pattern-matching).\n\n## Installation\n\n```bash\nyarn add match-with\n```\n\n## Usage\n\nBasic syntax:\n\n```ts\nimport { match } from \"match-with\";\n\nmatch(subject: any)\n  .with(pattern1: any, callback1: (subject, pattern1) =\u003e result: any)\n  .with(pattern2: any, callback2: (subject, pattern2) =\u003e result: any)\n  .default(callback3: (subject) =\u003e result: any)\n  .result;\n```\n\nExamples:\n\n```ts\n...\nconst subject = {\n  one: 1,\n  two: undefined,\n  three: \"3\",\n};\n\nmatch(subject)\n  .with({ one: 1, two: undefined }, () =\u003e {\n    return \"match\";\n  })\n  .result; // \"match\";\n\nmatch(subject)\n  .with({ one: 2 }, () =\u003e {\n    // Skipped.\n  })\n  .default(() =\u003e {\n    return 1;\n  });\n\nmatch(subject)\n  .with({ one: n =\u003e n \u003c 2 }, () =\u003e {\n    console.log(true);\n  });\n\nmatch(subject)\n  .with({ four: match.EXISTS }, () =\u003e {\n    // Skipped.\n  })\n  .with({ four: undefined }, () =\u003e {\n    return 4;\n  });\n```\n\n## Community\n\nLet me know what you think. After you ★ this project, follow me [@Rygu](https://twitter.com/rygu) on Twitter.\n\n## License\n\nBSD 3-Clause license. Copyright © 2019, Rick Wong. All rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickwong%2Fmatch-with","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickwong%2Fmatch-with","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickwong%2Fmatch-with/lists"}