{"id":23086803,"url":"https://github.com/papirosko/expressions-parser","last_synced_at":"2025-04-03T16:19:47.671Z","repository":{"id":63675132,"uuid":"569784099","full_name":"papirosko/expressions-parser","owner":"papirosko","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-21T13:21:16.000Z","size":147,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-10T11:02:39.076Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/papirosko.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-11-23T15:52:42.000Z","updated_at":"2022-11-23T16:36:44.000Z","dependencies_parsed_at":"2024-12-16T19:33:53.639Z","dependency_job_id":"2332543e-4b56-46d1-abb3-760fd025d651","html_url":"https://github.com/papirosko/expressions-parser","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"3fbd7b30d586bcac341ac4eea7b24ad2162918b2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papirosko%2Fexpressions-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papirosko%2Fexpressions-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papirosko%2Fexpressions-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/papirosko%2Fexpressions-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/papirosko","download_url":"https://codeload.github.com/papirosko/expressions-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247033815,"owners_count":20872532,"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":[],"created_at":"2024-12-16T19:31:11.046Z","updated_at":"2025-04-03T16:19:47.652Z","avatar_url":"https://github.com/papirosko.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# expressions-parser\n\n`expressions-parser` allows you to parse expression from string and evaluate it.\n\nInstall:\n```\nnpm i expressions-parser\n```\n\nHow to use:\n```typescript\nimport {toAST, parseInput, apply} from 'expressions-parser';\n\nconst ast = toAST(parseInput('1 + 1'));\napply(ast, {}); // return 2\n```\n\n\n# Expressions syntax\nAllowed are:\n* numbers: `1`, `100500`, `-1`\n* strings (both single and double quoted): `'test string'`, `\"another string\"`\n* boolean: `false`, `true`\n* object field access: `obj.field`\n* indexed access: `field[0]`, `field['property']`, `field[propVariable]`\n* method call: `obj.method()`, `obj.method(arg1, 'arg2', 0)`\n\n\n## Pipes\nYou can use pipes the same way as in angular:\n\n```typescript\nimport {toAST, parseInput, apply} from 'expressions-parser';\nconst ast = toAST(parseInput('obj.numbers | min:10 | sum'));\nconst sum = apply(ast, {\n    obj: {\n        numbers: [1, 2, 11, 19, 15]\n    }\n}, {\n    pipes: {\n        min: (arr: number[], min: number) =\u003e arr.filter(x =\u003e x \u003e= min),\n        sum: (arr: number[]) =\u003e arr.reduce((a, b) =\u003e a + b, 0)\n    }\n}); // returns 45\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapirosko%2Fexpressions-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpapirosko%2Fexpressions-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpapirosko%2Fexpressions-parser/lists"}