{"id":15170734,"url":"https://github.com/pugjs/is-expression-babylon","last_synced_at":"2026-01-16T04:59:22.188Z","repository":{"id":57277162,"uuid":"70654493","full_name":"pugjs/is-expression-babylon","owner":"pugjs","description":"Check if a string is a valid JavaScript expression using Babylon","archived":false,"fork":false,"pushed_at":"2017-01-23T02:12:31.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-09T10:42:42.880Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/pugjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-12T02:26:09.000Z","updated_at":"2017-01-23T02:09:52.000Z","dependencies_parsed_at":"2022-08-25T01:20:16.450Z","dependency_job_id":null,"html_url":"https://github.com/pugjs/is-expression-babylon","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fis-expression-babylon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fis-expression-babylon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fis-expression-babylon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pugjs%2Fis-expression-babylon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pugjs","download_url":"https://codeload.github.com/pugjs/is-expression-babylon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247092372,"owners_count":20882218,"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-09-27T08:22:34.064Z","updated_at":"2026-01-16T04:59:22.148Z","avatar_url":"https://github.com/pugjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=center\u003e!!!DEPRECATED!!!\u003c/h1\u003e\n\nThis module has stopped working since\n[babylon@6.13.1](https://github.com/babel/babylon/commit/beb8db62646081a88b8db31fe95d4b37aa28d98f).\nPlease use Babylon's `babylon.parseExpression()` instead.\n\n----\n\n# is-expression-babylon\n\nValidates a string as a JavaScript expression using Babylon\n\nAn alternative version of this module using [Acorn] instead of Babylon is\navailable at [is-expression]. While this module aims to support all ECMAScript\nfeatures, even spec proposals in Stage 0, is-expression is more conservative on\nthe features it implements. Pick your poison.\n\n[Acorn]: https://github.com/ternjs/acorn\n[Babylon]: https://github.com/babel/babylon\n[is-expression]: https://github.com/pugjs/is-expression\n\n[![Build Status](https://img.shields.io/travis/pugjs/is-expression-babylon/master.svg)](https://travis-ci.org/pugjs/is-expression-babylon)\n[![Dependency Status](https://img.shields.io/david/pugjs/is-expression-babylon.svg)](https://david-dm.org/pugjs/is-expression-babylon)\n[![npm version](https://img.shields.io/npm/v/is-expression-babylon.svg)](https://www.npmjs.org/package/is-expression-babylon)\n\n## Installation\n\n    npm install is-expression-babylon\n\n## Usage\n\n```js\nconst isExpression = require('is-expression-babylon');\n```\n\n### `isExpression(src[, options])`\n\nValidates a string as a JavaScript expression.\n\n`src` contains the source.\n\n`options` can contain any Babylon options, or any of the following:\n\n- `throw`: Throw an error if the string is not an expression. The error can\n  be an Acorn error, with location information in `err.loc` and `err.pos`.\n  Defaults to `false`.\n- `strict`: Use strict mode when trying to parse the string. Defaults to\n  `false`. Even if this option is `false`, if you have provided\n  `options.sourceType === 'module'` which imples strict mode under ES2015,\n  strict mode will be used.\n- `lineComment`: When `true`, allows line comments in the expression.\n  Defaults to `false` for safety.\n\nSee the examples below for usage.\n\n### `isExpression.getExpression(src[, options])`\n\nGet the Babylon Expression AST node of a string.\n\n`src` contains the source.\n\n`options` can contain any Babylon options, or any of the following:\n\n- `strict`: Use strict mode when trying to parse the string. Defaults to\n  `false`. Even if this option is `false`, if you have provided\n  `options.sourceType === 'module'` which imples strict mode under ES2015,\n  strict mode will be used.\n- `lineComment`: When `true`, allows line comments in the expression.\n  Defaults to `false` for safety.\n\nIf the string is not an expression, an error is thrown.\n\n## Examples\n\n```js\nconst isExpression = require('is-expression-babylon');\n\nisExpression('myVar');\n//=\u003e true\nisExpression('var');\n//=\u003e false\nisExpression('[\"an\", \"array\", \"\\'s\"].indexOf(\"index\")');\n//=\u003e true\n\nisExpression('var', {throw: true});\n// SyntaxError: Unexpected token (1:0)\n//     at Parser.pp.raise (acorn/dist/acorn.js:940:13)\n//     at ...\n\nisExpression('public');\n//=\u003e true\nisExpression('public', {strict: true});\n//=\u003e false\n\nisExpression('abc // my comment');\n//=\u003e false\nisExpression('abc // my comment', {lineComment: true});\n//=\u003e true\n\nconst expression = isExpression.getExpression('abc');\n//=\u003e Node { type: 'Identifier', ... }\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpugjs%2Fis-expression-babylon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpugjs%2Fis-expression-babylon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpugjs%2Fis-expression-babylon/lists"}