{"id":27324069,"url":"https://github.com/qinzhen001/babel-plugin-parcel-function","last_synced_at":"2026-05-02T05:37:20.170Z","repository":{"id":46923148,"uuid":"203927547","full_name":"QinZhen001/babel-plugin-parcel-function","owner":"QinZhen001","description":":full_moon: 一个使用if-else包裹增强函数的babel插件","archived":false,"fork":false,"pushed_at":"2022-12-09T23:46:42.000Z","size":366,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-03T14:42:09.455Z","etag":null,"topics":["babel","babel-plugin"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/babel-plugin-parcel-function","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QinZhen001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-23T05:06:29.000Z","updated_at":"2020-07-30T13:04:48.000Z","dependencies_parsed_at":"2023-01-26T00:32:22.177Z","dependency_job_id":null,"html_url":"https://github.com/QinZhen001/babel-plugin-parcel-function","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/QinZhen001/babel-plugin-parcel-function","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QinZhen001%2Fbabel-plugin-parcel-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QinZhen001%2Fbabel-plugin-parcel-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QinZhen001%2Fbabel-plugin-parcel-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QinZhen001%2Fbabel-plugin-parcel-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QinZhen001","download_url":"https://codeload.github.com/QinZhen001/babel-plugin-parcel-function/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QinZhen001%2Fbabel-plugin-parcel-function/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259377468,"owners_count":22848363,"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":["babel","babel-plugin"],"created_at":"2025-04-12T10:54:36.914Z","updated_at":"2026-05-02T05:37:20.147Z","avatar_url":"https://github.com/QinZhen001.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-parcel-function\n\n[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)\n[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE)\n\n\n一个使用if-else包裹增强函数的babel插件\n\n\n不影响原函数的使用，可以在if中注入一些黑科技方法\n\n\n----\n\n\nA babel plugin that uses the if-else package enhancement function\n\nDoes not affect the use of the original function, you can inject some black technology method in ifStatement\n\n\n## Install\n\n```\nnpm install --save-dev babel-plugin-parcel-function\n```\n\n\n## Usage\n\n.babelrc\n```\n{\n  \"plugins\": \n     [\n          [\"babel-plugin-parcel-function\",\n            {\n              prefixName: \"global.hotUpdate\",\n              addFileName: false\n            }\n          ]\n        ]\n}\n```\n\n\n\n\n## Examples  \n\n\n```javascript\nasync function f(arg) {\n    await aaa();\n    await bbb();\n    console.log('eee');\n    return 'ddd';\n  }\n```\n\n转换后\n\n\n\n```javascript\nasync function f(arg) {\n    if (global.hotUpdate.f) {\n        global.hotUpdate.f.call(this,arg);\n    } else {\n        await aaa();\n        await bbb();\n        console.log('eee');\n        return 'ddd';\n    }\n}\n```\n\n\n\n\n### Options\n\n\n\n| name        | description              | type         | default            |\n| ----------- | ------------------------ | ------------ | ------------------ |\n| prefixName  | if判断和if块中的前缀      | String or Array | \"global.hotUpdate\" |\n| addFileName | 是否将文件名添加到前缀中 | Boolean      | false              |\n\n\n\nwhen Options\n\n```\n{\n       prefixName: \"aaa.bbb.ccc\",\n       addFileName: false\n}\n```\n\n\ncode \n\n```javascript\nfunction f(aa,bb) {\n    let asd = 1 \n    asd = aa + bb\n    console.log(\"aaa\")\n  }\n```\n\n\nafter transform\n\n```javascript\nfunction f(aa, bb) {\n    if (aaa.bbb.ccc.f) {\n        aaa.bbb.ccc.f.call(this, aa, bb);\n    } else {\n        let asd = 1;\n        asd = aa + bb;\n        console.log(\"aaa\");\n    }\n}\n```\n\n\n**if中的判断和if块中的代码由  [prefixName + fileName + 函数名]  决定**\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqinzhen001%2Fbabel-plugin-parcel-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqinzhen001%2Fbabel-plugin-parcel-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqinzhen001%2Fbabel-plugin-parcel-function/lists"}