Skip to content

Commit

Permalink
docs: add docs for standard JS literals
Browse files Browse the repository at this point in the history
fixes #255
  • Loading branch information
6utt3rfly committed Oct 27, 2024
1 parent f6678fb commit a704d89
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const parse_tree = Jsep.parse('1 + 1');
jsep.addBinaryOp("^", 10);

// Add exponentiation operator (right-to-left)
jsep.addBinaryOp('**', 11, true);
jsep.addBinaryOp('**', 11, true); // now included by default

// Add a custom @ unary operator
jsep.addUnaryOp('@');
Expand All @@ -89,6 +89,19 @@ jsep.addIdentifierChar("@");
jsep.removeIdentifierChar('@');
```

#### Custom Literals

You can add or remove additional valid literals. By default, only `true`, `false`, and `null` are defined
```javascript
// Add standard JS literals:
jsep.addLiteral('undefined', undefined);
jsep.addLiteral('Infinity', Infinity);
jsep.addLiteral('NaN', NaN);

// Remove "null" literal from default definition
jsep.removeLiteral('null');
```

### Plugins
JSEP supports defining custom hooks for extending or modifying the expression parsing.
Plugins are registered by calling `jsep.plugins.register()` with the plugin(s) as the argument(s).
Expand Down

0 comments on commit a704d89

Please sign in to comment.