{"id":17888673,"url":"https://github.com/trs/expression","last_synced_at":"2025-04-03T03:16:07.907Z","repository":{"id":51226702,"uuid":"488843616","full_name":"trs/expression","owner":"trs","description":":arrows_counterclockwise: Parse and evaluate Javascript-like expressions","archived":false,"fork":false,"pushed_at":"2023-10-28T21:35:49.000Z","size":233,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-26T11:12:02.758Z","etag":null,"topics":["ast","expression","hacktoberfest","javascript","syntax"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/trs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-05T05:31:04.000Z","updated_at":"2023-10-06T16:16:40.000Z","dependencies_parsed_at":"2024-10-28T14:27:49.811Z","dependency_job_id":"7b34021a-1788-445a-bc42-fe54ce2046df","html_url":"https://github.com/trs/expression","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/trs%2Fexpression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trs%2Fexpression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trs%2Fexpression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trs%2Fexpression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trs","download_url":"https://codeload.github.com/trs/expression/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927843,"owners_count":20856198,"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","expression","hacktoberfest","javascript","syntax"],"created_at":"2024-10-28T13:42:05.850Z","updated_at":"2025-04-03T03:16:07.856Z","avatar_url":"https://github.com/trs.png","language":"TypeScript","readme":"# `@trs/expression`\n\nEvaluate arbitrary expressions using a Javascript-like syntax.\n\nSupported expressions:\n- Arithmetic - evaluates to a number\n- String - evaluates to a string\n- Logical - evaluates to a boolean\n\n## Install\n\n```sh\nnpm install @trs/expression\n# or\nyarn add @trs/expression\n# or\npnpm add @trs/expression\n```\n\n## Evaluate Expression String\n\nExpression strings can be evaluated to a single value.\n\n```ts\nimport { evaluate } from '@trs/expression';\n\nconst ast = evaluate('1 + 2 == 3');\n\nassert(ast === true);\n```\n\n## Parse Expression String\n\nExpression strings can be parsed into an expression tree.\n\n```ts\nimport { parse } from '@trs/expression';\n\nconst ast = parse('1 + 2 == 3');\n\nassert(ast == {\n  type: \"BinaryExpression\",\n  ... etc\n});\n```\n\n## Evaluate Expression Tree\n\nExpression trees can be evaluated to a single value.\n\n```ts\nimport { evaluate } from '@trs/expression';\n\nconst result = evaluate({\n  type: \"BinaryExpression\",\n  operator: \"==\",\n  left: {\n    type: \"BinaryExpression\",\n    operator: \"+\",\n    left: {\n      type: \"Literal\",\n      kind: \"number\",\n      value: \"1\"\n    },\n    right: {\n      type: \"Literal\",\n      kind: \"number\",\n      value: \"2\"\n    }\n  },\n  right: {\n    type: \"Literal\",\n    kind: \"number\",\n    value: \"3\"\n  }\n});\n\nassert(result === true);\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrs%2Fexpression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrs%2Fexpression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrs%2Fexpression/lists"}