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

eval-formula

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eval-formula - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

16

grammar.js

@@ -88,2 +88,16 @@ // Generated automatically by nearley, version 2.15.1

{"name": "N", "symbols": ["N$string$9", "_", "P"], "postprocess": function(d) {return new BigNumber(Math.log(d[2].toNumber())); }},
{"name": "N$string$10", "symbols": [{"literal":"m"}, {"literal":"i"}, {"literal":"n"}, {"literal":"("}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "N$subexpression$1$ebnf$1", "symbols": [/[0-9\,\s]/]},
{"name": "N$subexpression$1$ebnf$1", "symbols": ["N$subexpression$1$ebnf$1", /[0-9\,\s]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "N$subexpression$1", "symbols": ["N$subexpression$1$ebnf$1"]},
{"name": "N", "symbols": ["N$string$10", "_", "N$subexpression$1", "_", {"literal":")"}], "postprocess": function(d) {var params = d[2][0].join('').split(','); return new BigNumber.min(...params); }},
{"name": "N$string$11", "symbols": [{"literal":"m"}, {"literal":"a"}, {"literal":"x"}, {"literal":"("}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "N$subexpression$2$ebnf$1", "symbols": [/[0-9\,\s]/]},
{"name": "N$subexpression$2$ebnf$1", "symbols": ["N$subexpression$2$ebnf$1", /[0-9\,\s]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "N$subexpression$2", "symbols": ["N$subexpression$2$ebnf$1"]},
{"name": "N", "symbols": ["N$string$11", "_", "N$subexpression$2", "_", {"literal":")"}], "postprocess": function(d) {var params = d[2][0].join('').split(','); return new BigNumber.max(...params); }},
{"name": "N$string$12", "symbols": [{"literal":"c"}, {"literal":"e"}, {"literal":"i"}, {"literal":"l"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "N", "symbols": ["N$string$12", "_", "P"], "postprocess": function(d) {return d[2].dp(0, 2); }},
{"name": "N$string$13", "symbols": [{"literal":"f"}, {"literal":"l"}, {"literal":"o"}, {"literal":"o"}, {"literal":"r"}], "postprocess": function joiner(d) {return d.join('');}},
{"name": "N", "symbols": ["N$string$13", "_", "P"], "postprocess": function(d) {return d[2].dp(0, 3); }},
{"name": "float", "symbols": ["int", {"literal":"."}, "int"], "postprocess": function(d) {return new BigNumber(d[0] + d[1] + d[2])}},

@@ -97,3 +111,3 @@ {"name": "float", "symbols": ["int"], "postprocess": function(d) {return new BigNumber(d[0])}},

{"name": "string$ebnf$1", "symbols": ["string$ebnf$1", /[\w\s]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},
{"name": "string", "symbols": ["string$ebnf$1"], "postprocess": function(d) {return d[0].join("").trim(); }},
{"name": "string", "symbols": [{"literal":"\""}, "string$ebnf$1", {"literal":"\""}], "postprocess": function(d) {return d[1].join("").trim(); }},
{"name": "_$ebnf$1", "symbols": []},

@@ -100,0 +114,0 @@ {"name": "_$ebnf$1", "symbols": ["_$ebnf$1", /[\s]/], "postprocess": function arrpush(d) {return d[0].concat([d[1]]);}},

50

index.test.js

@@ -108,20 +108,20 @@ var evalFormula = require('./index');

test('test == test', t => {
t.deepEqual(evalFormula("test == test"), true);
test('"test" == "test"', t => {
t.deepEqual(evalFormula('"test" == "test"'), true);
});
test('test != test', t => {
t.deepEqual(evalFormula("test != test"), false);
test('"test" != "test"', t => {
t.deepEqual(evalFormula('"test" != "test"'), false);
});
test('test 1 != test 2', t => {
t.deepEqual(evalFormula("test 1 != test 2"), true);
test('"test 1" != "test 2"', t => {
t.deepEqual(evalFormula('"test 1" != "test 2"'), true);
});
test('test 2 != test 2', t => {
t.deepEqual(evalFormula("test 2 != test 2"), false);
test('"test 2" != "test 2"', t => {
t.deepEqual(evalFormula('"test 2" != "test 2"'), false);
});
test('test 3 == test 3', t => {
t.deepEqual(evalFormula("test 3 == test 3"), true);
test('"test 3" == "test 3"', t => {
t.deepEqual(evalFormula('"test 3" == "test 3"'), true);
});

@@ -183,1 +183,31 @@

});
test('min 1,2', t => {
t.deepEqual(evalFormula('min(1,2)').eq(1), true);
});
test('min 1,2,4', t => {
t.deepEqual(evalFormula('min(1,2,4)').eq(1), true);
});
test('min 2,3,5,7', t => {
t.deepEqual(evalFormula('min(2,3,5,7)').eq(2), true);
});
test('max 1,2', t => {
t.deepEqual(evalFormula('max(1,2)').eq(2), true);
});
test('max 1,2,4', t => {
t.deepEqual(evalFormula('max(1,2,4)').eq(4), true);
});
test('max 2,3,5,7', t => {
t.deepEqual(evalFormula('max(2,3,5,7)').eq(7), true);
});
test('ceil 2.5', t => {
t.deepEqual(evalFormula('ceil(2.5)').eq(3), true);
});
test('floor 2.5', t => {
t.deepEqual(evalFormula('floor(2.5)').eq(2), true);
});
{
"name": "eval-formula",
"version": "1.0.0",
"version": "1.0.1",
"dependencies": {

@@ -5,0 +5,0 @@ "bignumber.js": "^8.0.1",

Sorry, the diff of this file is not supported yet

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