Fix #10, add test
This commit is contained in:
@ -182,7 +182,7 @@ const parseExpression = expression => {
|
||||
stack.push(`-${cur}`);
|
||||
|
||||
// 2 - 5 is also OK, pass
|
||||
} else if (_.isNumber(beforeSign)) {
|
||||
} else if (_.isNumber(beforeSign) || isVariable(beforeSign)) {
|
||||
stack.push(cur);
|
||||
} else {
|
||||
stack[past] += cur;
|
||||
@ -379,9 +379,11 @@ const fixFloat = number => {
|
||||
* @return {Boolean}
|
||||
* true if variable, else false
|
||||
*/
|
||||
|
||||
const SPECIALS = '()[]{}'.split('');
|
||||
export const isVariable = a => {
|
||||
return typeof a === 'string' && !_.isNumber(a) &&
|
||||
!operators[a] && a === a.toLowerCase();
|
||||
!operators[a] && a === a.toLowerCase() && SPECIALS.indexOf(a) === -1;
|
||||
};
|
||||
|
||||
export default Equation;
|
||||
|
Reference in New Issue
Block a user