subscript 7.1.0 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +6 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -62,22 +62,20 @@ Default literals:
62
62
  * `"abc"` strings
63
63
  * `1.2e+3` numbers
64
64
 
65
- Everything else can be extended via `unary`, `binary` or `nary` for operators, or via `token(str, prec, parse, compile)` for custom tokens.
65
+ Everything else can be extended via `subscript.set(str, prec, fn)` for unary, binary or n-ary operators (detected by number of arguments in `fn`), or via `subscript.set(str, prec, [parse, compile])` for custom tokens.
66
66
 
67
67
  ```js
68
- import script, { compile, unary, nary, binary, token } from './subscript.js'
68
+ import script, { compile } from './subscript.js'
69
69
 
70
70
  // add ~ unary operator with precedence 15
71
- unary('~', 15, a => ~a)
71
+ script.set('~', 15, a => ~a)
72
72
 
73
73
  // add === binary operator with precedence 9
74
- binary('===', 9, (a, b) => a===b)
74
+ script.set('===', 9, (a, b) => a===b)
75
75
 
76
76
  // add literals
77
- token('true', 20, a => ['',true], a => ctx => a[1])
78
- token('false', 20, a => ['',false], a => ctx => a[1])
79
-
80
- script(`true === false`)() // false
77
+ script.set('true', 20, [a => ['',true], a => ctx => a[1]])
78
+ script.set('false', 20, [a => ['',false], a => ctx => a[1]])
81
79
  ```
82
80
 
83
81
  See [subscript.js](subscript.js) or [justin.js](./justin.js) for examples.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "subscript",
3
- "version": "7.1.0",
3
+ "version": "7.1.1",
4
4
  "description": "Fast and tiny expression evaluator with common syntax microlanguage.",
5
5
  "main": "subscript.js",
6
6
  "module": "subscript.js",