### Install @jsep-plugin/template Source: https://github.com/ericsmekens/jsep/blob/master/packages/template/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/template # or yarn add @jsep-plugin/template ``` -------------------------------- ### Install @jsep-plugin/new Source: https://github.com/ericsmekens/jsep/blob/master/packages/new/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/new ``` ```bash yarn add @jsep-plugin/new ``` -------------------------------- ### Install and Build jsep Source: https://github.com/ericsmekens/jsep/blob/master/README.md Commands to install dependencies and build jsep from source. ```bash npm install npm run default ``` -------------------------------- ### Install @jsep-plugin/comment Source: https://github.com/ericsmekens/jsep/blob/master/packages/comment/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/comment # or yarn add @jsep-plugin/comment ``` -------------------------------- ### Install @jsep-plugin/arrow Source: https://github.com/ericsmekens/jsep/blob/master/packages/arrow/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/arrow # or yarn add @jsep-plugin/arrow ``` -------------------------------- ### Install @jsep-plugin/object Source: https://github.com/ericsmekens/jsep/blob/master/packages/object/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/object # or yarn add @jsep-plugin/object ``` -------------------------------- ### Install @jsep-plugin/async-await Source: https://github.com/ericsmekens/jsep/blob/master/packages/async-await/README.md Install the plugin using npm or yarn. This is the first step to enable async/await support in JSEP. ```bash npm install @jsep-plugin/async-await ``` ```bash # or yarn add @jsep-plugin/async-await ``` -------------------------------- ### Install @jsep-plugin/regex Source: https://github.com/ericsmekens/jsep/blob/master/packages/regex/README.md Shows how to install the regex plugin for JSEP using either npm or yarn. ```bash npm install @jsep-plugin/regex ``` ```bash # or yarn add @jsep-plugin/regex ``` -------------------------------- ### Install Ternary Plugin with npm Source: https://github.com/ericsmekens/jsep/blob/master/packages/ternary/README.md Use this command to install the ternary plugin using npm. ```bash npm install @jsep-plugin/ternary ``` -------------------------------- ### Install JSEP Assignment Plugin Source: https://github.com/ericsmekens/jsep/blob/master/packages/assignment/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/assignment # or yarn add @jsep-plugin/assignment ``` -------------------------------- ### Install @jsep-plugin/numbers Source: https://github.com/ericsmekens/jsep/blob/master/packages/numbers/README.md Install the plugin using npm or yarn. ```bash npm install @jsep-plugin/numbers # or yarn add @jsep-plugin/numbers ``` -------------------------------- ### Install Ternary Plugin with yarn Source: https://github.com/ericsmekens/jsep/blob/master/packages/ternary/README.md Use this command to install the ternary plugin using yarn. ```bash yarn add @jsep-plugin/ternary ``` -------------------------------- ### Install @jsep-plugin/spread Source: https://github.com/ericsmekens/jsep/blob/master/packages/spread/README.md Install the spread plugin using npm or yarn. This makes the plugin available for use in your project. ```bash npm install @jsep-plugin/spread # or yarn add @jsep-plugin/spread ``` -------------------------------- ### Object Expression Example Source: https://github.com/ericsmekens/jsep/blob/master/packages/object/README.md Demonstrates the object expression syntax supported by the plugin. ```javascript jsep('{ a: 1, b: { c }}[d]'); ``` -------------------------------- ### JSEP Spread Expression Examples Source: https://github.com/ericsmekens/jsep/blob/master/packages/spread/README.md Examples of how spread expressions can be used with JSEP after the plugin is registered. These demonstrate function calls, object literals, and array literals with spread syntax. ```javascript jsep('fn(1, ...a)'); ``` ```javascript jsep('{ ...a }'); ``` ```javascript jsep('[...a]'); ``` -------------------------------- ### Regex Expression Examples in JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/regex/README.md Demonstrates the basic syntax for using regex literals within JSEP expressions, including flags. ```javascript jsep('/abc/'); ``` ```javascript jsep('/abc/ig'); ``` ```javascript jsep('/[a-z]{3}/ig.test(a)'); ``` -------------------------------- ### JSEP Assignment Expressions Source: https://github.com/ericsmekens/jsep/blob/master/packages/assignment/README.md Examples of assignment expressions supported by the plugin. ```javascript jsep('a = 2'); ``` ```javascript jsep('a += 2'); ``` ```javascript jsep('a++'); ``` ```javascript jsep('--aa'); ``` -------------------------------- ### Register Async/Await Plugin with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/async-await/README.md Import and register the async/await plugin with JSEP to enable its functionality. This setup is required before parsing expressions with async/await. ```javascript import jsep from 'jsep'; import jsepAsyncAwait from '@jsep-plugin/async-await'; jsep.plugins.register(jsepAsyncAwait); ``` -------------------------------- ### Add Custom Binary Operator Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of adding a custom binary operator with a specified precedence. ```javascript // Add a custom ^ binary operator with precedence 10 // (Note that higher number = higher precedence) jsep.addBinaryOp("^", 10); ``` -------------------------------- ### Add Custom Unary Operator Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of adding a custom unary operator. ```javascript // Add a custom @ unary operator jsep.addUnaryOp('@'); ``` -------------------------------- ### Writing a Custom JSEP Plugin Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of a custom JSEP plugin that adds '@' as a custom identifier and defines a new expression type. Plugins require a 'name' and an 'init' function. ```javascript const plugin = { name: 'the plugin', init(jsep) { jsep.addIdentifierChar('@'); jsep.hooks.add('gobble-expression', function myPlugin(env) { if (this.char === '@') { this.index += 1; env.node = { type: 'MyCustom@Detector', }; } }); }, }; ``` -------------------------------- ### Add Custom Right-to-Left Binary Operator Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of adding a custom right-to-left binary operator. ```javascript // Add exponentiation operator (right-to-left) jsep.addBinaryOp('**', 11, true); // now included by default ``` -------------------------------- ### Remove Binary Operator Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of removing a predefined binary operator. ```javascript // Remove a binary operator jsep.removeBinaryOp(">>>"); ``` -------------------------------- ### Add Custom Literal Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of adding a custom literal value to be recognized by the parser. ```javascript // Add standard JS literals: jsep.addLiteral('undefined', undefined); jsep.addLiteral('Infinity', Infinity); jsep.addLiteral('NaN', NaN); ``` -------------------------------- ### Remove Unary Operator Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of removing a predefined unary operator. ```javascript // Remove a unary operator jsep.removeUnaryOp("~"); ``` -------------------------------- ### Add Custom Identifier Character Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of adding a character that will be treated as part of an identifier. ```javascript // Add a custom @ identifier jsep.addIdentifierChar("@"); ``` -------------------------------- ### Remove Literal Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of removing a predefined literal from the parser's recognition. ```javascript // Remove "null" literal from default definition jsep.removeLiteral('null'); ``` -------------------------------- ### Remove Custom Identifier Character Source: https://github.com/ericsmekens/jsep/blob/master/README.md Example of removing a character that was previously treated as part of an identifier. ```javascript // Removes a custom @ identifier jsep.removeIdentifierChar('@'); ``` -------------------------------- ### Registering JSEP Plugins Source: https://github.com/ericsmekens/jsep/blob/master/README.md Demonstrates how to import and register JSEP plugins. Ensure plugins are imported before registration. ```javascript import jsep from 'jsep'; import ternary from '@jsep-plugin/ternary'; import object from '@jsep-plugin/object'; jsep.plugins.register(object); jsep.plugins.register(ternary, object); ``` -------------------------------- ### Register Regex Plugin with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/regex/README.md Illustrates how to import and register the regex plugin with JSEP to enable regex support. ```javascript import jsep from 'jsep'; import jsepRegex from '@jsep-plugin/regex'; jsep.plugins.register(jsepRegex); ``` -------------------------------- ### Async/Await Expressions in JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/async-await/README.md Demonstrates the basic syntax for using async/await within JSEP expressions. This allows for asynchronous operations to be represented as expressions. ```javascript jsep('await a'); ``` ```javascript jsep('await a.find(async (v1, v2) => await v1(v2))'); ``` -------------------------------- ### Client-side Usage with Module Import Source: https://github.com/ericsmekens/jsep/blob/master/README.md How to use jsep when imported as a module in a web browser. ```html ``` -------------------------------- ### Basic Template Literal Expressions with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/template/README.md Demonstrates how to use JSEP to parse standard and tagged template literal expressions. ```javascript jsep('`hi ${name}`'); ``` ```javascript jsep('msg`hi ${name}`'); ``` -------------------------------- ### Parse 'new' expressions with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/new/README.md Demonstrates how to parse expressions involving the 'new' keyword using JSEP. ```javascript jsep('new Date()'); ``` ```javascript jsep('new RegExp("^\\ d+$")'); ``` -------------------------------- ### Basic Ternary Expression Parsing Source: https://github.com/ericsmekens/jsep/blob/master/packages/ternary/README.md Demonstrates how to parse a simple ternary expression using JSEP after registering the ternary plugin. ```javascript jsep('a ? 1 : 2'); ``` -------------------------------- ### Arrow Function Expressions with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/arrow/README.md Demonstrates various forms of arrow functions that can be parsed by JSEP after applying the arrow plugin. ```javascript jsep('a.find(v => v === 1)'); ``` ```javascript jsep('a.map((v, i) => i)'); ``` ```javascript jsep('a.map(() => true)'); ``` -------------------------------- ### Register the 'new' plugin with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/new/README.md Import and register the plugin with JSEP to enable 'new' expression parsing. ```javascript import jsep from 'jsep'; import jsepNew from '@jsep-plugin/new'; jsep.plugins.register(jsepNew); ``` -------------------------------- ### Client-side Usage with IIFE Script Source: https://github.com/ericsmekens/jsep/blob/master/README.md How to use jsep when included via an IIFE script tag in a web browser. ```html ... let parse_tree = jsep("1 + 1"); ``` -------------------------------- ### Register JSEP Assignment Plugin Source: https://github.com/ericsmekens/jsep/blob/master/packages/assignment/README.md Import and register the assignment plugin with JSEP. ```javascript import jsep from 'jsep'; import jsepAssignment from '@jsep-plugin/assignment'; jsep.plugins.register(jsepAssignment); ``` -------------------------------- ### Register Arrow Plugin with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/arrow/README.md Import and register the arrow plugin with JSEP to enable arrow function support. ```javascript import jsep from 'jsep'; import jsepArrow from '@jsep-plugin/arrow'; jsep.plugins.register(jsepArrow); ``` -------------------------------- ### Register Ternary Plugin with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/ternary/README.md Import and register the ternary plugin with JSEP to enable ternary expression support. Ensure JSEP is imported first. ```javascript import jsep from 'jsep'; import jsepTernary from '@jsep-plugin/ternary'; jsep.plugins.register(jsepTernary); ``` -------------------------------- ### Node.js Usage with CJS Import Source: https://github.com/ericsmekens/jsep/blob/master/README.md How to import and use jsep in Node.js using CommonJS Modules (CJS). ```javascript // CJS: const jsep = require('jsep').default; const parsed = jsep('1 + 1'); ``` ```javascript // or: const { Jsep } = require('jsep'); const parse_tree = Jsep.parse('1 + 1'); ``` -------------------------------- ### ESLint Rules for Code Style Source: https://github.com/ericsmekens/jsep/blob/master/CONTRIBUTING.md These are ESLint rules used to enforce code style. Ensure your code adheres to these rules before committing. ```json "semi": 1 ``` ```json "no-dupe-args": 1 ``` ```json "no-dupe-keys": 1 ``` ```json "no-unreachable": 1 ``` ```json "valid-typeof": 1 ``` ```json "curly": 1 ``` ```json "no-useless-call": 1 ``` ```json "brace-style": [1,"stroustrup"] ``` ```json "no-mixed-spaces-and-tabs": [1,"smart-tabs"] ``` ```json "spaced-comment": [1,"always",{"block":{"exceptions":["*"]}}] ``` ```json "arrow-spacing": 1 ``` ```json "comma-spacing": 1 ``` ```json "keyword-spacing": 1 ``` -------------------------------- ### Parsing Expressions with Comments Source: https://github.com/ericsmekens/jsep/blob/master/packages/comment/README.md Demonstrates how JSEP parses expressions containing single-line and multi-line comments. ```javascript jsep('a = 2 // end of line comment'); jsep('a /* ignore this */ += 2'); jsep('a /* ignore this */ ++'); ``` -------------------------------- ### Register Spread Plugin for JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/spread/README.md Import and register the spread plugin with JSEP to enable spread expression support. This is required before parsing expressions with spread syntax. ```javascript import jsep from 'jsep'; import jsepSpread from '@jsep-plugin/spread'; jsep.plugins.register(jsepSpread); ``` -------------------------------- ### Node.js Usage with ESM Import Source: https://github.com/ericsmekens/jsep/blob/master/README.md How to import and use jsep in Node.js using ECMAScript Modules (ESM). ```javascript // ESM: import jsep from 'jsep'; const parse_tree = jsep('1 + 1'); ``` ```javascript // or: import { Jsep } from 'jsep'; const parse_tree = Jsep.parse('1 + 1'); ``` -------------------------------- ### Register JSEP Comment Plugin Source: https://github.com/ericsmekens/jsep/blob/master/packages/comment/README.md Import and register the comment plugin with JSEP to enable comment parsing. ```javascript import jsep from 'jsep'; import jsepComment from '@jsep-plugin/comment'; jsep.plugins.register(jsepComment); ``` -------------------------------- ### Register Numbers Plugin with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/numbers/README.md Import and register the numbers plugin with JSEP to enable support for additional number formats. ```javascript import jsep from 'jsep'; import jsepNumbers from '@jsep-plugin/numbers'; jsep.plugins.register(jsepNumbers); ``` -------------------------------- ### Register JSEP Object Plugin Source: https://github.com/ericsmekens/jsep/blob/master/packages/object/README.md Register the object plugin with JSEP to enable its features. ```javascript import jsep from 'jsep'; import jsepObject from '@jsep-plugin/object'; jsep.plugins.register(jsepObject); ``` -------------------------------- ### Register JSEP Template Literal Plugin Source: https://github.com/ericsmekens/jsep/blob/master/packages/template/README.md Import and register the template literal plugin with JSEP to enable its functionality. ```javascript import jsep from 'jsep'; import jsepTemplateLiteral from '@jsep-plugin/template'; jsep.plugins.register(jsepTemplateLiteral); ``` -------------------------------- ### Parse Additional Number Formats with JSEP Source: https://github.com/ericsmekens/jsep/blob/master/packages/numbers/README.md Use this snippet to parse hexadecimal, binary, octal, and decimal numbers with ignored underscores using the jsep function. ```javascript jsep('0xA'); // hexadecimal (10) ``` ```javascript jsep('0b01001010'); // binary (74) ``` ```javascript jsep('0644'); // octal (420) ``` ```javascript jsep('0o644'); // octal (420) ``` ```javascript jsep('115_200'); // decimal (115200) ``` -------------------------------- ### Commit Message Types Source: https://github.com/ericsmekens/jsep/blob/master/CONTRIBUTING.md The '' field in commit messages controls semantic versioning. Allowed types are build, ci, docs, feat, fix, perf, refactor, test. ```text build | ci | docs | feat | fix | perf | refactor | test ``` -------------------------------- ### Angular Commit Message Format Source: https://github.com/ericsmekens/jsep/blob/master/CONTRIBUTING.md Commit messages must follow the Angular commit-message format for semantic versioning. This includes type, scope, a short summary, and an optional body and footer. ```text (): ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.