{"id":20990223,"url":"https://github.com/shanamaid/akua","last_synced_at":"2025-07-24T21:35:08.931Z","repository":{"id":57175354,"uuid":"144248214","full_name":"ShanaMaid/akua","owner":"ShanaMaid","description":"It can solve your nested if-tree, make it become chainable if!","archived":false,"fork":false,"pushed_at":"2018-08-13T03:27:51.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-29T14:39:44.075Z","etag":null,"topics":["chainable-if","if","if-tree","nested-if"],"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/ShanaMaid.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}},"created_at":"2018-08-10T06:50:37.000Z","updated_at":"2018-11-24T14:34:42.000Z","dependencies_parsed_at":"2022-09-03T08:52:00.442Z","dependency_job_id":null,"html_url":"https://github.com/ShanaMaid/akua","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShanaMaid/akua","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShanaMaid%2Fakua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShanaMaid%2Fakua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShanaMaid%2Fakua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShanaMaid%2Fakua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShanaMaid","download_url":"https://codeload.github.com/ShanaMaid/akua/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShanaMaid%2Fakua/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266905593,"owners_count":24004148,"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","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["chainable-if","if","if-tree","nested-if"],"created_at":"2024-11-19T06:27:58.418Z","updated_at":"2025-07-24T21:35:08.880Z","avatar_url":"https://github.com/ShanaMaid.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Akua\nChainable `if`!\n\n`Akua`  is a very useful tools! It can solve your `nested if-tree`, make it become \n`chainable if`!\n\n`Akua` can help you code maintainable if!\n\n## Install\n```\nnpm install akua --save\n```\n\n## Use\nnormal nested if-tree\n```js\nlet normalIf = '';\nconst normailIfStart = new Date().getTime();\nif (conditionA) {\n  const tempA = 'tempA';\n  normalIf += 'a';\n  if (conditionB) {\n    normalIf += 'b';\n    normalIf += tempA;\n    if (conditionC) {\n      normalIf += 'c';\n      if (conditionD) {\n        normalIf += 'd';\n        if (conditionE) {\n          normalIf += 'e';\n        }\n      }\n    }\n  } else {\n    normalIf += '!b';\n  }\n\n  if (conditionF) {\n    normalIf += 'f';\n    if (conditionG) {\n      normalIf += 'g';\n    }\n  }\n} else {\n  normalIf += '!a';\n}\n```\n\nakua if\n```js\nlet akuaIf = '';\nconst ifTree = new akua();\nifTree\n.inject(conditionA, 'a', (obj) =\u003e {\n  obj.tempA = 'tempA';\n  akuaIf += 'a';\n})\n.inject(!conditionA, '!a', () =\u003e {\n  akuaIf += '!a';\n})\n.inject(conditionB, 'a-\u003eb', (obj) =\u003e {\n  akuaIf += 'b';\n  akuaIf += obj.tempA;\n})\n.inject(!conditionB, 'a-\u003e!b', () =\u003e {\n  akuaIf += '!b';\n})\n.inject(conditionC, 'b-\u003ec', () =\u003e {\n  akuaIf += 'c';\n})\n.inject(conditionD, 'c-\u003ed', () =\u003e {\n  akuaIf += 'd';\n})\n.inject(conditionE, 'd-\u003ee', () =\u003e {\n  akuaIf += 'e';\n})\n.inject(conditionF, 'a-\u003ef', () =\u003e {\n  akuaIf += 'f';\n})\n.inject(conditionG, 'f-\u003eg', () =\u003e {\n  akuaIf += 'g';\n})\n.parse();\n```\n\nFinally, `normalIf === akuaIf`, you can git clone this project and `npm run test` if you doubt！\n\n\n## Unit Test Exampls\n- [unit test](./test/unit.ts)\n\n## Perfomance\n`npm run test`\n```\ntest: 1000， success: 1000, fail: 0\nnormal-if cost time: 2ms\nakua-if cost time: 7ms\n```\n\n```\ntest: 100000， success: 100000, fail: 0\nnormal-if cost time: 19ms\nakua-if cost time: 175ms\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshanamaid%2Fakua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshanamaid%2Fakua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshanamaid%2Fakua/lists"}