Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expression-compiler

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expression-compiler - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

package.json
{
"name": "expression-compiler",
"repository": "git@github.com:uniphil/expression-compiler.git",
"version": "0.3.0",
"version": "0.3.1",
"description": "",

@@ -6,0 +6,0 @@ "main": "func.js",

@@ -131,3 +131,3 @@ var R = require('ramda');

var pullOps = function(symbol, ary, funcName) {
var pullOps = function(symbol, ary, funcName, options) {
var arys = {

@@ -137,2 +137,10 @@ unary: function(tL, t, tR) {

{ key: funcName, template: t.repr + '#' });
if (options.binarify &&
tL && // it's not the first token
!(tL.type === 'token' && tL.token === 'operator') && // thing before isn't an op
!(tL.type === 'astNode' && tL.node === 'func')) { // thing before isn't an op
var injectedToken = lex.token('operator', options.binarify);
injectedToken.repr = '';
return [[tL, injectedToken, node], null];
}
return [[tL, node], null];

@@ -164,19 +172,2 @@ },

var injectToken = function(tokenToInject, options) {
return function(tokens) {
return R.reduce.idx(function(out, token, i, tokens) {
if (token.type === 'ASTNode' && token.node === 'func' &&
token.options.key === options.beforeOpNode &&
tokens[i - 1]) {
var injectedToken = lex.token('operator', tokenToInject);
injectedToken.repr = '';
out.push(injectedToken);
}
out.push(token);
return out;
}, [], tokens);
};
};
var pullFunctions = stepTrios(function(tL, t, tR) {

@@ -261,4 +252,3 @@ // find [name, expr]s, and swap as fn(key=name, children=expr.children)

pullOps('^', 'binary', 'pow'),
pullOps('-', 'unary', 'neg'),
injectToken('+', {beforeOpNode: 'neg'}),
pullOps('-', 'unary', 'neg', {binarify: '+'}),
pullOps('*', 'nary', 'product'),

@@ -265,0 +255,0 @@ pullOps('/', 'binary', 'div'),

@@ -220,2 +220,5 @@ require('mocha');

});
it('should work for unary negation after operators like 1+-1', function() {
assert.doesNotThrow(function() { parse('1+-1'); }, parse.ParseError);
});
it('should error on dangling close paren', function() {

@@ -222,0 +225,0 @@ assert.throws(function() { parse('1)'); }, parse.ParseError);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc