{"id":19068590,"url":"https://github.com/lydanne/ctxexp-parser","last_synced_at":"2025-04-28T13:25:36.311Z","repository":{"id":57211026,"uuid":"409526680","full_name":"Lydanne/ctxexp-parser","owner":"Lydanne","description":"In the dynamic execution of JS language environment (wechat applet) to execute JS class calling function.","archived":false,"fork":false,"pushed_at":"2021-11-04T02:59:10.000Z","size":708,"stargazers_count":20,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-08-10T07:48:15.117Z","etag":null,"topics":["ast","eval","javascript","jsonpath","parser"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Lydanne.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":"2021-09-23T09:22:42.000Z","updated_at":"2024-08-10T07:48:15.118Z","dependencies_parsed_at":"2022-08-29T07:40:38.920Z","dependency_job_id":null,"html_url":"https://github.com/Lydanne/ctxexp-parser","commit_stats":null,"previous_names":["lydanne/ctxexp-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lydanne%2Fctxexp-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lydanne%2Fctxexp-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lydanne%2Fctxexp-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lydanne%2Fctxexp-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lydanne","download_url":"https://codeload.github.com/Lydanne/ctxexp-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223772076,"owners_count":17199978,"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":["ast","eval","javascript","jsonpath","parser"],"created_at":"2024-11-09T01:10:09.282Z","updated_at":"2024-11-09T01:10:10.327Z","avatar_url":"https://github.com/Lydanne.png","language":"JavaScript","readme":"# Ctxexp Parser\n\n\u003e 上下文表达式解析器\n\n在不能动态执行 JS 语言的环境（微信小程序）里执行类 JS 的调用函数。\n\n## Feature\n\n- [x] 轻量包，未压缩 16k，压缩 4k\n- [x] 单元测试 \u003e85% 的代码覆盖\n- [x] 使用状态机编写词法分析\n- [x] 动态执行表达式\n- [x] 调用方法支持传入 Number `+1 -1 1.1`\n- [x] 调用方法支持传入 String\n- [x] 调用方法支持传入 Callback `([参数])=\u003e\u003c上下文表达式\u003e`\n- [x] 支持传入多个参数\n- [x] 支持嵌套调用\n- [x] 语法错误检查\n- [x] 支持链式调用、链式访问\n- [x] 支持数组的访问\n\n## Tip\n\n- 不支持在表达式中使用空格 如 `$.fn(1, 2)`\n- 回调函数只支持简单的箭头函数\n\n## Install\n\n```\nnpm i ctxexp-parser\n# yarn add ctxexp-parser\n```\n\n## Uses\n\n```js\nconst { CtxexpParser } = require(\"ctxexp-parser\");\n// import { CtxexpParser } from \"ctxexp-parser\";\n\nconst $ = {\n  a: \"hello\",\n  fn(str, str2) {\n    return str + str2;\n  },\n  runs(...cbs) {\n    return cbs.map((cb, index) =\u003e cb(index));\n  },\n  Type(i) {\n    return [\"A\", \"D\", \"C\"][i];\n  },\n};\n\nconst exp = `$.a`;\nconst res = new CtxexpParser($, exp).exec();\nconsole.log(res); // hello\n\nconst exp1 = `$.fn($.a,\" cxtexp\")`;\nconst res1 = new CtxexpParser($, exp1).exec();\nconsole.log(res1); // hello cxtexp\n\nconst exp2 = `$.runs((i)=\u003e$.Type(i)).join(\"\")`;\nconst res2 = new CtxexpParser($, exp2).exec();\nconsole.log(res2); // A\n```\n\n[查看更多例子](https://github.com/WumaCoder/ctxexp-parser/blob/main/test/index.spec.ts)\n\n## State\n\n![state](./status.png)\n\n## About\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flydanne%2Fctxexp-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flydanne%2Fctxexp-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flydanne%2Fctxexp-parser/lists"}