fix: prevent asset conflicts between React and Grid.js versions

Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
dwindown
2026-04-18 17:02:14 +07:00
parent bd9cdac02e
commit e8fbfb14c1
74973 changed files with 6658406 additions and 71 deletions

37
node_modules/@tannin/compile/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,37 @@
## 1.1.0 (2020-03-07)
New Features
- Add TypeScript definitions
## 1.0.4 (2019-11-27)
Internal
- Update project inter-dependencies
## 1.0.3 (2019-03-07)
Internal
- Add `repository.directory` to `package.json`
## 1.0.2 (2019-01-19)
Documentation
- Correct documentation unpkg links
Internal
- Use Lerna for managing mono-repo
## 1.0.1 (2018-11-04)
Bug Fixes
- Fix dependencies pointers from local filesystem to npm copies.
## 1.0.0 (2018-11-04)
- Initial release

7
node_modules/@tannin/compile/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
[The MIT License (MIT)](https://opensource.org/licenses/MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

33
node_modules/@tannin/compile/README.md generated vendored Normal file
View File

@@ -0,0 +1,33 @@
`@tannin/compile`
=================
Compiles an evaluating function for a C expression.
## Installation
Using [npm](https://www.npmjs.com/) as a package manager:
```
npm install @tannin/compile
```
Otherwise, download a pre-built copy from unpkg:
[https://unpkg.com/@tannin/compile/dist/compile.min.js](https://unpkg.com/@tannin/compile/dist/compile.min.js)
## Usage
```js
import compile from '@tannin/compile';
const evaluate = compile( 'n > 1' );
evaluate( { n: 2 } );
// ⇒ true
```
## License
Copyright 2019-2020 Andrew Duthie
Released under the [MIT License](https://opensource.org/licenses/MIT).

35
node_modules/@tannin/compile/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var postfix = _interopDefault(require('@tannin/postfix'));
var evaluate = _interopDefault(require('@tannin/evaluate'));
/**
* Given a C expression, returns a function which can be called to evaluate its
* result.
*
* @example
*
* ```js
* import compile from '@tannin/compile';
*
* const evaluate = compile( 'n > 1' );
*
* evaluate( { n: 2 } );
* // ⇒ true
* ```
*
* @param {string} expression C expression.
*
* @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
*/
function compile( expression ) {
var terms = postfix( expression );
return function( variables ) {
return evaluate( terms, variables );
};
}
module.exports = compile;

269
node_modules/@tannin/compile/dist/compile.js generated vendored Normal file
View File

@@ -0,0 +1,269 @@
var compile = (function () {
'use strict';
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
/**
* Operator precedence mapping.
*
* @type {Object}
*/
PRECEDENCE = {
'(': 9,
'!': 8,
'*': 7,
'/': 7,
'%': 7,
'+': 6,
'-': 6,
'<': 5,
'<=': 5,
'>': 5,
'>=': 5,
'==': 4,
'!=': 4,
'&&': 3,
'||': 2,
'?': 1,
'?:': 1,
};
/**
* Characters which signal pair opening, to be terminated by terminators.
*
* @type {string[]}
*/
OPENERS = [ '(', '?' ];
/**
* Characters which signal pair termination, the value an array with the
* opener as its first member. The second member is an optional operator
* replacement to push to the stack.
*
* @type {string[]}
*/
TERMINATORS = {
')': [ '(' ],
':': [ '?', '?:' ],
};
/**
* Pattern matching operators and openers.
*
* @type {RegExp}
*/
PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
/**
* Given a C expression, returns the equivalent postfix (Reverse Polish)
* notation terms as an array.
*
* If a postfix string is desired, simply `.join( ' ' )` the result.
*
* @example
*
* ```js
* import postfix from '@tannin/postfix';
*
* postfix( 'n > 1' );
* // ⇒ [ 'n', '1', '>' ]
* ```
*
* @param {string} expression C expression.
*
* @return {string[]} Postfix terms.
*/
function postfix( expression ) {
var terms = [],
stack = [],
match, operator, term, element;
while ( ( match = expression.match( PATTERN ) ) ) {
operator = match[ 0 ];
// Term is the string preceding the operator match. It may contain
// whitespace, and may be empty (if operator is at beginning).
term = expression.substr( 0, match.index ).trim();
if ( term ) {
terms.push( term );
}
while ( ( element = stack.pop() ) ) {
if ( TERMINATORS[ operator ] ) {
if ( TERMINATORS[ operator ][ 0 ] === element ) {
// Substitution works here under assumption that because
// the assigned operator will no longer be a terminator, it
// will be pushed to the stack during the condition below.
operator = TERMINATORS[ operator ][ 1 ] || operator;
break;
}
} else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
// Push to stack if either an opener or when pop reveals an
// element of lower precedence.
stack.push( element );
break;
}
// For each popped from stack, push to terms.
terms.push( element );
}
if ( ! TERMINATORS[ operator ] ) {
stack.push( operator );
}
// Slice matched fragment from expression to continue match.
expression = expression.substr( match.index + operator.length );
}
// Push remainder of operand, if exists, to terms.
expression = expression.trim();
if ( expression ) {
terms.push( expression );
}
// Pop remaining items from stack into terms.
return terms.concat( stack.reverse() );
}
/**
* Operator callback functions.
*
* @type {Object}
*/
var OPERATORS = {
'!': function( a ) {
return ! a;
},
'*': function( a, b ) {
return a * b;
},
'/': function( a, b ) {
return a / b;
},
'%': function( a, b ) {
return a % b;
},
'+': function( a, b ) {
return a + b;
},
'-': function( a, b ) {
return a - b;
},
'<': function( a, b ) {
return a < b;
},
'<=': function( a, b ) {
return a <= b;
},
'>': function( a, b ) {
return a > b;
},
'>=': function( a, b ) {
return a >= b;
},
'==': function( a, b ) {
return a === b;
},
'!=': function( a, b ) {
return a !== b;
},
'&&': function( a, b ) {
return a && b;
},
'||': function( a, b ) {
return a || b;
},
'?:': function( a, b, c ) {
if ( a ) {
throw b;
}
return c;
},
};
/**
* Given an array of postfix terms and operand variables, returns the result of
* the postfix evaluation.
*
* @example
*
* ```js
* import evaluate from '@tannin/evaluate';
*
* // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
* const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
*
* evaluate( terms, {} );
* // ⇒ 6.333333333333334
* ```
*
* @param {string[]} postfix Postfix terms.
* @param {Object} variables Operand variables.
*
* @return {*} Result of evaluation.
*/
function evaluate( postfix, variables ) {
var stack = [],
i, j, args, getOperatorResult, term, value;
for ( i = 0; i < postfix.length; i++ ) {
term = postfix[ i ];
getOperatorResult = OPERATORS[ term ];
if ( getOperatorResult ) {
// Pop from stack by number of function arguments.
j = getOperatorResult.length;
args = Array( j );
while ( j-- ) {
args[ j ] = stack.pop();
}
try {
value = getOperatorResult.apply( null, args );
} catch ( earlyReturn ) {
return earlyReturn;
}
} else if ( variables.hasOwnProperty( term ) ) {
value = variables[ term ];
} else {
value = +term;
}
stack.push( value );
}
return stack[ 0 ];
}
/**
* Given a C expression, returns a function which can be called to evaluate its
* result.
*
* @example
*
* ```js
* import compile from '@tannin/compile';
*
* const evaluate = compile( 'n > 1' );
*
* evaluate( { n: 2 } );
* // ⇒ true
* ```
*
* @param {string} expression C expression.
*
* @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
*/
function compile( expression ) {
var terms = postfix( expression );
return function( variables ) {
return evaluate( terms, variables );
};
}
return compile;
}());

1
node_modules/@tannin/compile/dist/compile.min.js generated vendored Normal file
View File

@@ -0,0 +1 @@
var compile=function(){"use strict";var o,c,s,a;o={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},c=["(","?"],s={")":["("],":":["?","?:"]},a=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;var p={"!":function(n){return!n},"*":function(n,r){return n*r},"/":function(n,r){return n/r},"%":function(n,r){return n%r},"+":function(n,r){return n+r},"-":function(n,r){return n-r},"<":function(n,r){return n<r},"<=":function(n,r){return n<=r},">":function(n,r){return r<n},">=":function(n,r){return r<=n},"==":function(n,r){return n===r},"!=":function(n,r){return n!==r},"&&":function(n,r){return n&&r},"||":function(n,r){return n||r},"?:":function(n,r,t){if(n)throw r;return t}};return function(n){var r=function(n){for(var r,t,u,e,i=[],f=[];r=n.match(a);){for(t=r[0],(u=n.substr(0,r.index).trim())&&i.push(u);e=f.pop();){if(s[t]){if(s[t][0]===e){t=s[t][1]||t;break}}else if(0<=c.indexOf(e)||o[e]<o[t]){f.push(e);break}i.push(e)}s[t]||f.push(t),n=n.substr(r.index+t.length)}return(n=n.trim())&&i.push(n),i.concat(f.reverse())}(n);return function(n){return function(n,r){var t,u,e,i,f,o,c=[];for(t=0;t<n.length;t++){if(f=n[t],i=p[f]){for(u=i.length,e=Array(u);u--;)e[u]=c.pop();try{o=i.apply(null,e)}catch(n){return n}}else o=r.hasOwnProperty(f)?r[f]:+f;c.push(o)}return c[0]}(r,n)}}}();

22
node_modules/@tannin/compile/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* Given a C expression, returns a function which can be called to evaluate its
* result.
*
* @example
*
* ```js
* import compile from '@tannin/compile';
*
* const evaluate = compile( 'n > 1' );
*
* evaluate( { n: 2 } );
* // ⇒ true
* ```
*
* @param {string} expression C expression.
*
* @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
*/
export default function compile(expression: string): (variables?: {
[variable: string]: any;
}) => any;

29
node_modules/@tannin/compile/index.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
import postfix from '@tannin/postfix';
import evaluate from '@tannin/evaluate';
/**
* Given a C expression, returns a function which can be called to evaluate its
* result.
*
* @example
*
* ```js
* import compile from '@tannin/compile';
*
* const evaluate = compile( 'n > 1' );
*
* evaluate( { n: 2 } );
* // ⇒ true
* ```
*
* @param {string} expression C expression.
*
* @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
*/
export default function compile( expression ) {
var terms = postfix( expression );
return function( variables ) {
return evaluate( terms, variables );
};
}

38
node_modules/@tannin/compile/package.json generated vendored Normal file
View File

@@ -0,0 +1,38 @@
{
"name": "@tannin/compile",
"version": "1.1.0",
"description": "Compiles an evaluating function for a C expression",
"main": "build/index.js",
"module": "index.js",
"types": "index.d.ts",
"keywords": [],
"author": {
"name": "Andrew Duthie",
"email": "andrew@andrewduthie.com",
"url": "https://andrewduthie.com"
},
"homepage": "https://github.com/aduth/tannin",
"repository": {
"type": "git",
"url": "https://github.com/aduth/tannin.git",
"directory": "packages/compile"
},
"bugs": {
"url": "https://github.com/aduth/tannin/issues"
},
"license": "MIT",
"files": [
"index.js",
"index.d.ts",
"build",
"dist"
],
"dependencies": {
"@tannin/evaluate": "^1.2.0",
"@tannin/postfix": "^1.1.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "cd1c7447843df7751c4abd1b92aee03fe56bfba4"
}

31
node_modules/@tannin/evaluate/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,31 @@
## 1.2.0 (2020-03-07)
New Features
- Add TypeScript definitions
## 1.1.2 (2019-11-27)
Internal
- Update project inter-dependencies
## 1.1.1 (2019-03-07)
Internal
- Add `repository.directory` to `package.json`
## 1.1.0 (2019-01-19)
Improvements
- Improve performance by upwards of 4.5x in some common scenarios ([benchmarked optimization](http://jsbench.github.io/#d4e1fe19291d325ae4fdc4e8cc609d1b))
Documentation
- Correct documentation unpkg links
Internal
- Use Lerna for managing mono-repo

7
node_modules/@tannin/evaluate/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
[The MIT License (MIT)](https://opensource.org/licenses/MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

34
node_modules/@tannin/evaluate/README.md generated vendored Normal file
View File

@@ -0,0 +1,34 @@
`@tannin/evaluate`
==================
Evaluates the result of an expression given as postfix terms.
## Installation
Using [npm](https://www.npmjs.com/) as a package manager:
```
npm install @tannin/evaluate
```
Otherwise, download a pre-built copy from unpkg:
[https://unpkg.com/@tannin/evaluate/dist/evaluate.min.js](https://unpkg.com/@tannin/evaluate/dist/evaluate.min.js)
## Usage
```js
import evaluate from '@tannin/evaluate';
// 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
evaluate( terms, {} );
// ⇒ 6.333333333333334
```
## License
Copyright 2019-2020 Andrew Duthie
Released under the [MIT License](https://opensource.org/licenses/MIT).

114
node_modules/@tannin/evaluate/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,114 @@
'use strict';
/**
* Operator callback functions.
*
* @type {Object}
*/
var OPERATORS = {
'!': function( a ) {
return ! a;
},
'*': function( a, b ) {
return a * b;
},
'/': function( a, b ) {
return a / b;
},
'%': function( a, b ) {
return a % b;
},
'+': function( a, b ) {
return a + b;
},
'-': function( a, b ) {
return a - b;
},
'<': function( a, b ) {
return a < b;
},
'<=': function( a, b ) {
return a <= b;
},
'>': function( a, b ) {
return a > b;
},
'>=': function( a, b ) {
return a >= b;
},
'==': function( a, b ) {
return a === b;
},
'!=': function( a, b ) {
return a !== b;
},
'&&': function( a, b ) {
return a && b;
},
'||': function( a, b ) {
return a || b;
},
'?:': function( a, b, c ) {
if ( a ) {
throw b;
}
return c;
},
};
/**
* Given an array of postfix terms and operand variables, returns the result of
* the postfix evaluation.
*
* @example
*
* ```js
* import evaluate from '@tannin/evaluate';
*
* // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
* const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
*
* evaluate( terms, {} );
* // ⇒ 6.333333333333334
* ```
*
* @param {string[]} postfix Postfix terms.
* @param {Object} variables Operand variables.
*
* @return {*} Result of evaluation.
*/
function evaluate( postfix, variables ) {
var stack = [],
i, j, args, getOperatorResult, term, value;
for ( i = 0; i < postfix.length; i++ ) {
term = postfix[ i ];
getOperatorResult = OPERATORS[ term ];
if ( getOperatorResult ) {
// Pop from stack by number of function arguments.
j = getOperatorResult.length;
args = Array( j );
while ( j-- ) {
args[ j ] = stack.pop();
}
try {
value = getOperatorResult.apply( null, args );
} catch ( earlyReturn ) {
return earlyReturn;
}
} else if ( variables.hasOwnProperty( term ) ) {
value = variables[ term ];
} else {
value = +term;
}
stack.push( value );
}
return stack[ 0 ];
}
module.exports = evaluate;

117
node_modules/@tannin/evaluate/dist/evaluate.js generated vendored Normal file
View File

@@ -0,0 +1,117 @@
var evaluate = (function () {
'use strict';
/**
* Operator callback functions.
*
* @type {Object}
*/
var OPERATORS = {
'!': function( a ) {
return ! a;
},
'*': function( a, b ) {
return a * b;
},
'/': function( a, b ) {
return a / b;
},
'%': function( a, b ) {
return a % b;
},
'+': function( a, b ) {
return a + b;
},
'-': function( a, b ) {
return a - b;
},
'<': function( a, b ) {
return a < b;
},
'<=': function( a, b ) {
return a <= b;
},
'>': function( a, b ) {
return a > b;
},
'>=': function( a, b ) {
return a >= b;
},
'==': function( a, b ) {
return a === b;
},
'!=': function( a, b ) {
return a !== b;
},
'&&': function( a, b ) {
return a && b;
},
'||': function( a, b ) {
return a || b;
},
'?:': function( a, b, c ) {
if ( a ) {
throw b;
}
return c;
},
};
/**
* Given an array of postfix terms and operand variables, returns the result of
* the postfix evaluation.
*
* @example
*
* ```js
* import evaluate from '@tannin/evaluate';
*
* // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
* const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
*
* evaluate( terms, {} );
* // ⇒ 6.333333333333334
* ```
*
* @param {string[]} postfix Postfix terms.
* @param {Object} variables Operand variables.
*
* @return {*} Result of evaluation.
*/
function evaluate( postfix, variables ) {
var stack = [],
i, j, args, getOperatorResult, term, value;
for ( i = 0; i < postfix.length; i++ ) {
term = postfix[ i ];
getOperatorResult = OPERATORS[ term ];
if ( getOperatorResult ) {
// Pop from stack by number of function arguments.
j = getOperatorResult.length;
args = Array( j );
while ( j-- ) {
args[ j ] = stack.pop();
}
try {
value = getOperatorResult.apply( null, args );
} catch ( earlyReturn ) {
return earlyReturn;
}
} else if ( variables.hasOwnProperty( term ) ) {
value = variables[ term ];
} else {
value = +term;
}
stack.push( value );
}
return stack[ 0 ];
}
return evaluate;
}());

1
node_modules/@tannin/evaluate/dist/evaluate.min.js generated vendored Normal file
View File

@@ -0,0 +1 @@
var evaluate=function(){"use strict";var a={"!":function(n){return!n},"*":function(n,r){return n*r},"/":function(n,r){return n/r},"%":function(n,r){return n%r},"+":function(n,r){return n+r},"-":function(n,r){return n-r},"<":function(n,r){return n<r},"<=":function(n,r){return n<=r},">":function(n,r){return r<n},">=":function(n,r){return r<=n},"==":function(n,r){return n===r},"!=":function(n,r){return n!==r},"&&":function(n,r){return n&&r},"||":function(n,r){return n||r},"?:":function(n,r,t){if(n)throw r;return t}};return function(n,r){var t,u,e,o,f,c,i=[];for(t=0;t<n.length;t++){if(f=n[t],o=a[f]){for(u=o.length,e=Array(u);u--;)e[u]=i.pop();try{c=o.apply(null,e)}catch(n){return n}}else c=r.hasOwnProperty(f)?r[f]:+f;i.push(c)}return i[0]}}();

22
node_modules/@tannin/evaluate/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
/**
* Given an array of postfix terms and operand variables, returns the result of
* the postfix evaluation.
*
* @example
*
* ```js
* import evaluate from '@tannin/evaluate';
*
* // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
* const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
*
* evaluate( terms, {} );
* // ⇒ 6.333333333333334
* ```
*
* @param {string[]} postfix Postfix terms.
* @param {Object} variables Operand variables.
*
* @return {*} Result of evaluation.
*/
export default function evaluate(postfix: string[], variables: any): any;

110
node_modules/@tannin/evaluate/index.js generated vendored Normal file
View File

@@ -0,0 +1,110 @@
/**
* Operator callback functions.
*
* @type {Object}
*/
var OPERATORS = {
'!': function( a ) {
return ! a;
},
'*': function( a, b ) {
return a * b;
},
'/': function( a, b ) {
return a / b;
},
'%': function( a, b ) {
return a % b;
},
'+': function( a, b ) {
return a + b;
},
'-': function( a, b ) {
return a - b;
},
'<': function( a, b ) {
return a < b;
},
'<=': function( a, b ) {
return a <= b;
},
'>': function( a, b ) {
return a > b;
},
'>=': function( a, b ) {
return a >= b;
},
'==': function( a, b ) {
return a === b;
},
'!=': function( a, b ) {
return a !== b;
},
'&&': function( a, b ) {
return a && b;
},
'||': function( a, b ) {
return a || b;
},
'?:': function( a, b, c ) {
if ( a ) {
throw b;
}
return c;
},
};
/**
* Given an array of postfix terms and operand variables, returns the result of
* the postfix evaluation.
*
* @example
*
* ```js
* import evaluate from '@tannin/evaluate';
*
* // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
* const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
*
* evaluate( terms, {} );
* // ⇒ 6.333333333333334
* ```
*
* @param {string[]} postfix Postfix terms.
* @param {Object} variables Operand variables.
*
* @return {*} Result of evaluation.
*/
export default function evaluate( postfix, variables ) {
var stack = [],
i, j, args, getOperatorResult, term, value;
for ( i = 0; i < postfix.length; i++ ) {
term = postfix[ i ];
getOperatorResult = OPERATORS[ term ];
if ( getOperatorResult ) {
// Pop from stack by number of function arguments.
j = getOperatorResult.length;
args = Array( j );
while ( j-- ) {
args[ j ] = stack.pop();
}
try {
value = getOperatorResult.apply( null, args );
} catch ( earlyReturn ) {
return earlyReturn;
}
} else if ( variables.hasOwnProperty( term ) ) {
value = variables[ term ];
} else {
value = +term;
}
stack.push( value );
}
return stack[ 0 ];
}

34
node_modules/@tannin/evaluate/package.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "@tannin/evaluate",
"version": "1.2.0",
"description": "Evaluates the result of an expression given as postfix terms",
"main": "build/index.js",
"module": "index.js",
"types": "index.d.ts",
"keywords": [],
"author": {
"name": "Andrew Duthie",
"email": "andrew@andrewduthie.com",
"url": "https://andrewduthie.com"
},
"homepage": "https://github.com/aduth/tannin",
"repository": {
"type": "git",
"url": "https://github.com/aduth/tannin.git",
"directory": "packages/evaluate"
},
"bugs": {
"url": "https://github.com/aduth/tannin/issues"
},
"license": "MIT",
"files": [
"index.js",
"index.d.ts",
"build",
"dist"
],
"publishConfig": {
"access": "public"
},
"gitHead": "cd1c7447843df7751c4abd1b92aee03fe56bfba4"
}

37
node_modules/@tannin/plural-forms/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,37 @@
## 1.1.0 (2020-03-07)
New Features
- Add TypeScript definitions
## 1.0.4 (2019-11-27)
Internal
- Update project inter-dependencies
## 1.0.3 (2019-03-07)
Internal
- Add `repository.directory` to `package.json`
## 1.0.2 (2019-01-19)
Documentation
- Correct documentation unpkg links
Internal
- Use Lerna for managing mono-repo
## 1.0.1 (2018-11-04)
Bug Fixes
- Fix dependencies pointers from local filesystem to npm copies.
## 1.0.0 (2018-11-04)
- Initial release

7
node_modules/@tannin/plural-forms/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
[The MIT License (MIT)](https://opensource.org/licenses/MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

38
node_modules/@tannin/plural-forms/README.md generated vendored Normal file
View File

@@ -0,0 +1,38 @@
`@tannin/plural-forms`
======================
Compiles a function to compute the plural forms index for a given value.
Given a C expression, returns a function which, when called with a value, evaluates the result with the value assumed to be the "n" variable of the expression. The result will be coerced to its numeric equivalent.
## Installation
Using [npm](https://www.npmjs.com/) as a package manager:
```
npm install @tannin/plural-forms
```
Otherwise, download a pre-built copy from unpkg:
[https://unpkg.com/@tannin/plural-forms/dist/plural-forms.min.js](https://unpkg.com/@tannin/plural-forms/dist/plural-forms.min.js)
## Usage
```js
import pluralForms from '@tannin/plural-forms';
const evaluate = pluralForms( 'n > 1' );
evaluate( 2 );
// ⇒ 1
evaluate( 1 );
// ⇒ 0
```
## License
Copyright 2019-2020 Andrew Duthie
Released under the [MIT License](https://opensource.org/licenses/MIT).

24
node_modules/@tannin/plural-forms/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var compile = _interopDefault(require('@tannin/compile'));
/**
* Given a C expression, returns a function which, when called with a value,
* evaluates the result with the value assumed to be the "n" variable of the
* expression. The result will be coerced to its numeric equivalent.
*
* @param {string} expression C expression.
*
* @return {Function} Evaluator function.
*/
function pluralForms( expression ) {
var evaluate = compile( expression );
return function( n ) {
return +evaluate( { n: n } );
};
}
module.exports = pluralForms;

286
node_modules/@tannin/plural-forms/dist/plural-forms.js generated vendored Normal file
View File

@@ -0,0 +1,286 @@
var pluralForms = (function () {
'use strict';
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
/**
* Operator precedence mapping.
*
* @type {Object}
*/
PRECEDENCE = {
'(': 9,
'!': 8,
'*': 7,
'/': 7,
'%': 7,
'+': 6,
'-': 6,
'<': 5,
'<=': 5,
'>': 5,
'>=': 5,
'==': 4,
'!=': 4,
'&&': 3,
'||': 2,
'?': 1,
'?:': 1,
};
/**
* Characters which signal pair opening, to be terminated by terminators.
*
* @type {string[]}
*/
OPENERS = [ '(', '?' ];
/**
* Characters which signal pair termination, the value an array with the
* opener as its first member. The second member is an optional operator
* replacement to push to the stack.
*
* @type {string[]}
*/
TERMINATORS = {
')': [ '(' ],
':': [ '?', '?:' ],
};
/**
* Pattern matching operators and openers.
*
* @type {RegExp}
*/
PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
/**
* Given a C expression, returns the equivalent postfix (Reverse Polish)
* notation terms as an array.
*
* If a postfix string is desired, simply `.join( ' ' )` the result.
*
* @example
*
* ```js
* import postfix from '@tannin/postfix';
*
* postfix( 'n > 1' );
* // ⇒ [ 'n', '1', '>' ]
* ```
*
* @param {string} expression C expression.
*
* @return {string[]} Postfix terms.
*/
function postfix( expression ) {
var terms = [],
stack = [],
match, operator, term, element;
while ( ( match = expression.match( PATTERN ) ) ) {
operator = match[ 0 ];
// Term is the string preceding the operator match. It may contain
// whitespace, and may be empty (if operator is at beginning).
term = expression.substr( 0, match.index ).trim();
if ( term ) {
terms.push( term );
}
while ( ( element = stack.pop() ) ) {
if ( TERMINATORS[ operator ] ) {
if ( TERMINATORS[ operator ][ 0 ] === element ) {
// Substitution works here under assumption that because
// the assigned operator will no longer be a terminator, it
// will be pushed to the stack during the condition below.
operator = TERMINATORS[ operator ][ 1 ] || operator;
break;
}
} else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
// Push to stack if either an opener or when pop reveals an
// element of lower precedence.
stack.push( element );
break;
}
// For each popped from stack, push to terms.
terms.push( element );
}
if ( ! TERMINATORS[ operator ] ) {
stack.push( operator );
}
// Slice matched fragment from expression to continue match.
expression = expression.substr( match.index + operator.length );
}
// Push remainder of operand, if exists, to terms.
expression = expression.trim();
if ( expression ) {
terms.push( expression );
}
// Pop remaining items from stack into terms.
return terms.concat( stack.reverse() );
}
/**
* Operator callback functions.
*
* @type {Object}
*/
var OPERATORS = {
'!': function( a ) {
return ! a;
},
'*': function( a, b ) {
return a * b;
},
'/': function( a, b ) {
return a / b;
},
'%': function( a, b ) {
return a % b;
},
'+': function( a, b ) {
return a + b;
},
'-': function( a, b ) {
return a - b;
},
'<': function( a, b ) {
return a < b;
},
'<=': function( a, b ) {
return a <= b;
},
'>': function( a, b ) {
return a > b;
},
'>=': function( a, b ) {
return a >= b;
},
'==': function( a, b ) {
return a === b;
},
'!=': function( a, b ) {
return a !== b;
},
'&&': function( a, b ) {
return a && b;
},
'||': function( a, b ) {
return a || b;
},
'?:': function( a, b, c ) {
if ( a ) {
throw b;
}
return c;
},
};
/**
* Given an array of postfix terms and operand variables, returns the result of
* the postfix evaluation.
*
* @example
*
* ```js
* import evaluate from '@tannin/evaluate';
*
* // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
* const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
*
* evaluate( terms, {} );
* // ⇒ 6.333333333333334
* ```
*
* @param {string[]} postfix Postfix terms.
* @param {Object} variables Operand variables.
*
* @return {*} Result of evaluation.
*/
function evaluate( postfix, variables ) {
var stack = [],
i, j, args, getOperatorResult, term, value;
for ( i = 0; i < postfix.length; i++ ) {
term = postfix[ i ];
getOperatorResult = OPERATORS[ term ];
if ( getOperatorResult ) {
// Pop from stack by number of function arguments.
j = getOperatorResult.length;
args = Array( j );
while ( j-- ) {
args[ j ] = stack.pop();
}
try {
value = getOperatorResult.apply( null, args );
} catch ( earlyReturn ) {
return earlyReturn;
}
} else if ( variables.hasOwnProperty( term ) ) {
value = variables[ term ];
} else {
value = +term;
}
stack.push( value );
}
return stack[ 0 ];
}
/**
* Given a C expression, returns a function which can be called to evaluate its
* result.
*
* @example
*
* ```js
* import compile from '@tannin/compile';
*
* const evaluate = compile( 'n > 1' );
*
* evaluate( { n: 2 } );
* // ⇒ true
* ```
*
* @param {string} expression C expression.
*
* @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
*/
function compile( expression ) {
var terms = postfix( expression );
return function( variables ) {
return evaluate( terms, variables );
};
}
/**
* Given a C expression, returns a function which, when called with a value,
* evaluates the result with the value assumed to be the "n" variable of the
* expression. The result will be coerced to its numeric equivalent.
*
* @param {string} expression C expression.
*
* @return {Function} Evaluator function.
*/
function pluralForms( expression ) {
var evaluate = compile( expression );
return function( n ) {
return +evaluate( { n: n } );
};
}
return pluralForms;
}());

View File

@@ -0,0 +1 @@
var pluralForms=function(){"use strict";var o,c,s,a;o={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},c=["(","?"],s={")":["("],":":["?","?:"]},a=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;var p={"!":function(n){return!n},"*":function(n,r){return n*r},"/":function(n,r){return n/r},"%":function(n,r){return n%r},"+":function(n,r){return n+r},"-":function(n,r){return n-r},"<":function(n,r){return n<r},"<=":function(n,r){return n<=r},">":function(n,r){return r<n},">=":function(n,r){return r<=n},"==":function(n,r){return n===r},"!=":function(n,r){return n!==r},"&&":function(n,r){return n&&r},"||":function(n,r){return n||r},"?:":function(n,r,t){if(n)throw r;return t}};function t(n){var r=function(n){for(var r,t,u,e,i=[],f=[];r=n.match(a);){for(t=r[0],(u=n.substr(0,r.index).trim())&&i.push(u);e=f.pop();){if(s[t]){if(s[t][0]===e){t=s[t][1]||t;break}}else if(0<=c.indexOf(e)||o[e]<o[t]){f.push(e);break}i.push(e)}s[t]||f.push(t),n=n.substr(r.index+t.length)}return(n=n.trim())&&i.push(n),i.concat(f.reverse())}(n);return function(n){return function(n,r){var t,u,e,i,f,o,c=[];for(t=0;t<n.length;t++){if(f=n[t],i=p[f]){for(u=i.length,e=Array(u);u--;)e[u]=c.pop();try{o=i.apply(null,e)}catch(n){return n}}else o=r.hasOwnProperty(f)?r[f]:+f;c.push(o)}return c[0]}(r,n)}}return function(n){var r=t(n);return function(n){return+r({n:n})}}}();

10
node_modules/@tannin/plural-forms/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* Given a C expression, returns a function which, when called with a value,
* evaluates the result with the value assumed to be the "n" variable of the
* expression. The result will be coerced to its numeric equivalent.
*
* @param {string} expression C expression.
*
* @return {Function} Evaluator function.
*/
export default function pluralForms(expression: string): Function;

18
node_modules/@tannin/plural-forms/index.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import compile from '@tannin/compile';
/**
* Given a C expression, returns a function which, when called with a value,
* evaluates the result with the value assumed to be the "n" variable of the
* expression. The result will be coerced to its numeric equivalent.
*
* @param {string} expression C expression.
*
* @return {Function} Evaluator function.
*/
export default function pluralForms( expression ) {
var evaluate = compile( expression );
return function( n ) {
return +evaluate( { n: n } );
};
}

37
node_modules/@tannin/plural-forms/package.json generated vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "@tannin/plural-forms",
"version": "1.1.0",
"description": "Compiles a function to compute the plural forms index for a given value",
"main": "build/index.js",
"module": "index.js",
"types": "index.d.ts",
"keywords": [],
"author": {
"name": "Andrew Duthie",
"email": "andrew@andrewduthie.com",
"url": "https://andrewduthie.com"
},
"homepage": "https://github.com/aduth/tannin",
"repository": {
"type": "git",
"url": "https://github.com/aduth/tannin.git",
"directory": "packages/plural-forms"
},
"bugs": {
"url": "https://github.com/aduth/tannin/issues"
},
"license": "MIT",
"files": [
"index.js",
"index.d.ts",
"build",
"dist"
],
"dependencies": {
"@tannin/compile": "^1.1.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "cd1c7447843df7751c4abd1b92aee03fe56bfba4"
}

27
node_modules/@tannin/postfix/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,27 @@
## 1.1.0 (2020-03-07)
New Features
- Add TypeScript definitions
## 1.0.3 (2019-11-27)
Internal
- Update project inter-dependencies
## 1.0.2 (2019-03-07)
Internal
- Add `repository.directory` to `package.json`
## 1.0.1 (2019-01-19)
Documentation
- Correct documentation unpkg links
Internal
- Use Lerna for managing mono-repo

7
node_modules/@tannin/postfix/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
[The MIT License (MIT)](https://opensource.org/licenses/MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

33
node_modules/@tannin/postfix/README.md generated vendored Normal file
View File

@@ -0,0 +1,33 @@
`@tannin/postfix`
=================
Given a C expression, returns the equivalent postfix (Reverse Polish) notation terms as an array.
If a postfix string is desired, simply `.join( ' ' )` the result.
## Installation
Using [npm](https://www.npmjs.com/) as a package manager:
```
npm install @tannin/postfix
```
Otherwise, download a pre-built copy from unpkg:
[https://unpkg.com/@tannin/postfix/dist/postfix.min.js](https://unpkg.com/@tannin/postfix/dist/postfix.min.js)
## Usage
```js
import postfix from '@tannin/postfix';
postfix( 'n > 1' );
// ⇒ [ 'n', '1', '>' ]
```
## License
Copyright 2019-2020 Andrew Duthie
Released under the [MIT License](https://opensource.org/licenses/MIT).

128
node_modules/@tannin/postfix/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
'use strict';
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
/**
* Operator precedence mapping.
*
* @type {Object}
*/
PRECEDENCE = {
'(': 9,
'!': 8,
'*': 7,
'/': 7,
'%': 7,
'+': 6,
'-': 6,
'<': 5,
'<=': 5,
'>': 5,
'>=': 5,
'==': 4,
'!=': 4,
'&&': 3,
'||': 2,
'?': 1,
'?:': 1,
};
/**
* Characters which signal pair opening, to be terminated by terminators.
*
* @type {string[]}
*/
OPENERS = [ '(', '?' ];
/**
* Characters which signal pair termination, the value an array with the
* opener as its first member. The second member is an optional operator
* replacement to push to the stack.
*
* @type {string[]}
*/
TERMINATORS = {
')': [ '(' ],
':': [ '?', '?:' ],
};
/**
* Pattern matching operators and openers.
*
* @type {RegExp}
*/
PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
/**
* Given a C expression, returns the equivalent postfix (Reverse Polish)
* notation terms as an array.
*
* If a postfix string is desired, simply `.join( ' ' )` the result.
*
* @example
*
* ```js
* import postfix from '@tannin/postfix';
*
* postfix( 'n > 1' );
* // ⇒ [ 'n', '1', '>' ]
* ```
*
* @param {string} expression C expression.
*
* @return {string[]} Postfix terms.
*/
function postfix( expression ) {
var terms = [],
stack = [],
match, operator, term, element;
while ( ( match = expression.match( PATTERN ) ) ) {
operator = match[ 0 ];
// Term is the string preceding the operator match. It may contain
// whitespace, and may be empty (if operator is at beginning).
term = expression.substr( 0, match.index ).trim();
if ( term ) {
terms.push( term );
}
while ( ( element = stack.pop() ) ) {
if ( TERMINATORS[ operator ] ) {
if ( TERMINATORS[ operator ][ 0 ] === element ) {
// Substitution works here under assumption that because
// the assigned operator will no longer be a terminator, it
// will be pushed to the stack during the condition below.
operator = TERMINATORS[ operator ][ 1 ] || operator;
break;
}
} else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
// Push to stack if either an opener or when pop reveals an
// element of lower precedence.
stack.push( element );
break;
}
// For each popped from stack, push to terms.
terms.push( element );
}
if ( ! TERMINATORS[ operator ] ) {
stack.push( operator );
}
// Slice matched fragment from expression to continue match.
expression = expression.substr( match.index + operator.length );
}
// Push remainder of operand, if exists, to terms.
expression = expression.trim();
if ( expression ) {
terms.push( expression );
}
// Pop remaining items from stack into terms.
return terms.concat( stack.reverse() );
}
module.exports = postfix;

131
node_modules/@tannin/postfix/dist/postfix.js generated vendored Normal file
View File

@@ -0,0 +1,131 @@
var postfix = (function () {
'use strict';
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
/**
* Operator precedence mapping.
*
* @type {Object}
*/
PRECEDENCE = {
'(': 9,
'!': 8,
'*': 7,
'/': 7,
'%': 7,
'+': 6,
'-': 6,
'<': 5,
'<=': 5,
'>': 5,
'>=': 5,
'==': 4,
'!=': 4,
'&&': 3,
'||': 2,
'?': 1,
'?:': 1,
};
/**
* Characters which signal pair opening, to be terminated by terminators.
*
* @type {string[]}
*/
OPENERS = [ '(', '?' ];
/**
* Characters which signal pair termination, the value an array with the
* opener as its first member. The second member is an optional operator
* replacement to push to the stack.
*
* @type {string[]}
*/
TERMINATORS = {
')': [ '(' ],
':': [ '?', '?:' ],
};
/**
* Pattern matching operators and openers.
*
* @type {RegExp}
*/
PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
/**
* Given a C expression, returns the equivalent postfix (Reverse Polish)
* notation terms as an array.
*
* If a postfix string is desired, simply `.join( ' ' )` the result.
*
* @example
*
* ```js
* import postfix from '@tannin/postfix';
*
* postfix( 'n > 1' );
* // ⇒ [ 'n', '1', '>' ]
* ```
*
* @param {string} expression C expression.
*
* @return {string[]} Postfix terms.
*/
function postfix( expression ) {
var terms = [],
stack = [],
match, operator, term, element;
while ( ( match = expression.match( PATTERN ) ) ) {
operator = match[ 0 ];
// Term is the string preceding the operator match. It may contain
// whitespace, and may be empty (if operator is at beginning).
term = expression.substr( 0, match.index ).trim();
if ( term ) {
terms.push( term );
}
while ( ( element = stack.pop() ) ) {
if ( TERMINATORS[ operator ] ) {
if ( TERMINATORS[ operator ][ 0 ] === element ) {
// Substitution works here under assumption that because
// the assigned operator will no longer be a terminator, it
// will be pushed to the stack during the condition below.
operator = TERMINATORS[ operator ][ 1 ] || operator;
break;
}
} else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
// Push to stack if either an opener or when pop reveals an
// element of lower precedence.
stack.push( element );
break;
}
// For each popped from stack, push to terms.
terms.push( element );
}
if ( ! TERMINATORS[ operator ] ) {
stack.push( operator );
}
// Slice matched fragment from expression to continue match.
expression = expression.substr( match.index + operator.length );
}
// Push remainder of operand, if exists, to terms.
expression = expression.trim();
if ( expression ) {
terms.push( expression );
}
// Pop remaining items from stack into terms.
return terms.concat( stack.reverse() );
}
return postfix;
}());

1
node_modules/@tannin/postfix/dist/postfix.min.js generated vendored Normal file
View File

@@ -0,0 +1 @@
var postfix=function(){"use strict";var f,p,a,h;return f={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},p=["(","?"],a={")":["("],":":["?","?:"]},h=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/,function(r){for(var e,s,t,i,u=[],n=[];e=r.match(h);){for(s=e[0],(t=r.substr(0,e.index).trim())&&u.push(t);i=n.pop();){if(a[s]){if(a[s][0]===i){s=a[s][1]||s;break}}else if(0<=p.indexOf(i)||f[i]<f[s]){n.push(i);break}u.push(i)}a[s]||n.push(s),r=r.substr(e.index+s.length)}return(r=r.trim())&&u.push(r),u.concat(n.reverse())}}();

20
node_modules/@tannin/postfix/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
/**
* Given a C expression, returns the equivalent postfix (Reverse Polish)
* notation terms as an array.
*
* If a postfix string is desired, simply `.join( ' ' )` the result.
*
* @example
*
* ```js
* import postfix from '@tannin/postfix';
*
* postfix( 'n > 1' );
* // ⇒ [ 'n', '1', '>' ]
* ```
*
* @param {string} expression C expression.
*
* @return {string[]} Postfix terms.
*/
export default function postfix(expression: string): string[];

124
node_modules/@tannin/postfix/index.js generated vendored Normal file
View File

@@ -0,0 +1,124 @@
var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
/**
* Operator precedence mapping.
*
* @type {Object}
*/
PRECEDENCE = {
'(': 9,
'!': 8,
'*': 7,
'/': 7,
'%': 7,
'+': 6,
'-': 6,
'<': 5,
'<=': 5,
'>': 5,
'>=': 5,
'==': 4,
'!=': 4,
'&&': 3,
'||': 2,
'?': 1,
'?:': 1,
};
/**
* Characters which signal pair opening, to be terminated by terminators.
*
* @type {string[]}
*/
OPENERS = [ '(', '?' ];
/**
* Characters which signal pair termination, the value an array with the
* opener as its first member. The second member is an optional operator
* replacement to push to the stack.
*
* @type {string[]}
*/
TERMINATORS = {
')': [ '(' ],
':': [ '?', '?:' ],
};
/**
* Pattern matching operators and openers.
*
* @type {RegExp}
*/
PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
/**
* Given a C expression, returns the equivalent postfix (Reverse Polish)
* notation terms as an array.
*
* If a postfix string is desired, simply `.join( ' ' )` the result.
*
* @example
*
* ```js
* import postfix from '@tannin/postfix';
*
* postfix( 'n > 1' );
* // ⇒ [ 'n', '1', '>' ]
* ```
*
* @param {string} expression C expression.
*
* @return {string[]} Postfix terms.
*/
export default function postfix( expression ) {
var terms = [],
stack = [],
match, operator, term, element;
while ( ( match = expression.match( PATTERN ) ) ) {
operator = match[ 0 ];
// Term is the string preceding the operator match. It may contain
// whitespace, and may be empty (if operator is at beginning).
term = expression.substr( 0, match.index ).trim();
if ( term ) {
terms.push( term );
}
while ( ( element = stack.pop() ) ) {
if ( TERMINATORS[ operator ] ) {
if ( TERMINATORS[ operator ][ 0 ] === element ) {
// Substitution works here under assumption that because
// the assigned operator will no longer be a terminator, it
// will be pushed to the stack during the condition below.
operator = TERMINATORS[ operator ][ 1 ] || operator;
break;
}
} else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
// Push to stack if either an opener or when pop reveals an
// element of lower precedence.
stack.push( element );
break;
}
// For each popped from stack, push to terms.
terms.push( element );
}
if ( ! TERMINATORS[ operator ] ) {
stack.push( operator );
}
// Slice matched fragment from expression to continue match.
expression = expression.substr( match.index + operator.length );
}
// Push remainder of operand, if exists, to terms.
expression = expression.trim();
if ( expression ) {
terms.push( expression );
}
// Pop remaining items from stack into terms.
return terms.concat( stack.reverse() );
}

34
node_modules/@tannin/postfix/package.json generated vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "@tannin/postfix",
"version": "1.1.0",
"description": "Convert a C expression to an array of postfix terms",
"main": "build/index.js",
"module": "index.js",
"types": "index.d.ts",
"keywords": [],
"author": {
"name": "Andrew Duthie",
"email": "andrew@andrewduthie.com",
"url": "https://andrewduthie.com"
},
"homepage": "https://github.com/aduth/tannin",
"repository": {
"type": "git",
"url": "https://github.com/aduth/tannin.git",
"directory": "packages/postfix"
},
"bugs": {
"url": "https://github.com/aduth/tannin/issues"
},
"license": "MIT",
"files": [
"index.js",
"index.d.ts",
"build",
"dist"
],
"publishConfig": {
"access": "public"
},
"gitHead": "cd1c7447843df7751c4abd1b92aee03fe56bfba4"
}