{"id":16611297,"url":"https://github.com/shalldie/lessif","last_synced_at":"2026-04-18T21:01:21.264Z","repository":{"id":90549189,"uuid":"450431925","full_name":"shalldie/lessif","owner":"shalldie","description":"Conbination condition with less if. 用更少的代码实现组合判断。","archived":false,"fork":false,"pushed_at":"2022-02-15T04:09:18.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-20T08:12:39.324Z","etag":null,"topics":["condition","if","javascript"],"latest_commit_sha":null,"homepage":"","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/shalldie.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":"2022-01-21T09:35:12.000Z","updated_at":"2022-02-15T04:08:23.000Z","dependencies_parsed_at":"2023-04-29T21:46:55.813Z","dependency_job_id":null,"html_url":"https://github.com/shalldie/lessif","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"c1b4e353062909f904224e98fd5534b9e16fc325"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalldie%2Flessif","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalldie%2Flessif/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalldie%2Flessif/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shalldie%2Flessif/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shalldie","download_url":"https://codeload.github.com/shalldie/lessif/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242901331,"owners_count":20203920,"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":["condition","if","javascript"],"created_at":"2024-10-12T01:36:34.617Z","updated_at":"2026-04-18T21:01:16.221Z","avatar_url":"https://github.com/shalldie.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lessif\n\nConbination condition with less if. 用更少的代码实现组合判断。\n\n[![npm][lessif-icon]][lessif-npm]\n[![test status](https://img.shields.io/github/workflow/status/shalldie/lessif/ci?label=test\u0026logo=github\u0026style=flat-square)](https://github.com/shalldie/lessif/actions)\n[![license](https://img.shields.io/npm/l/lessif?logo=github\u0026style=flat-square)](https://github.com/shalldie/lessif)\n\n[English](./README.md) | [中文](./README.zh-CN.md)\n\n## Installation\n\n    npm install lessif --save\n\n## Usage \u0026 Example\n\n### and\n\nWhether all provided rules pass.\n\n```ts\nand\u003cboolean\u003e(true, true, true)(true); // true\n```\n\n```ts\ninterface IPerson {\n    name: string;\n    age: number;\n    sex: 1 | 0;\n}\n\nconst person: IPerson = {\n    name: 'tom',\n    age: 12,\n    sex: 1\n};\n\nconst predicate = and\u003cIPerson\u003e(\n    // true\n    n =\u003e n.name === 'tom',\n    and(\n        // true\n        n =\u003e n.name.length === 3,\n        and(\n            // true\n            and(\n                // true\n                and(n =\u003e n.age === 12)\n            )\n        )\n    ),\n    // true\n    {\n        sex: 1\n    }\n);\n\npredicate(person); // true\n```\n\n### or\n\nWhether at least one provided rule passes.\n\n```ts\nor\u003cboolean\u003e(true, false, false)(true); // true\n```\n\n```ts\ninterface IPerson {\n    name: string;\n    age: number;\n    sex: 1 | 0;\n}\n\nconst person: IPerson = {\n    name: 'tom',\n    age: 12,\n    sex: 1\n};\n\nconst predicate = or\u003cIPerson\u003e(\n    // false\n    n =\u003e n.name === 'lily',\n    // false\n    or(\n        n =\u003e n.age === 23,\n        n =\u003e n.age \u003e 23\n    ),\n    // true\n    {\n        name: 'tom'\n    }\n);\npredicate(person); // true\n```\n\n### none\n\nWhether none of provided rules pass.\n\n```ts\nnone\u003cboolean\u003e(false, false, false)(true); // true\n```\n\n```ts\ninterface IPerson {\n    name: string;\n    age: number;\n    sex: 1 | 0;\n}\n\nconst person: IPerson = {\n    name: 'tom',\n    age: 12,\n    sex: 1\n};\n\nconst predicate = or\u003cIPerson\u003e(\n    // false\n    n =\u003e n.name === 'lily',\n    // false\n    or(\n        n =\u003e n.age === 23,\n        n =\u003e n.age \u003e 23\n    ),\n    // true\n    {\n        name: 'tom'\n    }\n);\npredicate(person); // false\n```\n\n### and\u0026or\u0026none\n\nPut them together!\n\n```ts\ninterface IPerson {\n    name: string;\n    age: number;\n    sex: 1 | 0;\n}\n\nconst person: IPerson = {\n    name: 'tom',\n    age: 12,\n    sex: 1\n};\n\nconst predicate = and\u003cIPerson\u003e(\n    // true\n    and({ name: 'tom' }),\n    // true\n    or(\n        n =\u003e n.age === 23,\n        n =\u003e n.age \u003c 23\n    ),\n    // true\n    none({\n        sex: 0\n    })\n);\npredicate(person); // true\n```\n\n## License\n\nMIT\n\n\u003c!-- lessif --\u003e\n\n[lessif-icon]: https://img.shields.io/npm/v/lessif.svg?logo=npm\u0026style=flat-square\n[lessif-npm]: https://www.npmjs.com/package/lessif\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshalldie%2Flessif","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshalldie%2Flessif","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshalldie%2Flessif/lists"}