I have a form where I want the user to be able to specify a custom formula and then have this formula calculated.
I am using the npm module expressions-parser/func
to achieve this in a Blaze helper like this:
Template.calculated.helpers({
value(){
const mkFunc = require('expression-parser/func');
console.log(mkFunc.express(this.rowArgs.row.formula));
const fn = mkFunc(this.rowArgs.row.formula);
let rv = this.rowArgs.formData.get();
console.log(rv, fn, fn(rv));
const value = fn(rv);
return round(value, 3);
}
});
This works really well for even complex functions when I test this on local development.
My debug console messages return on localhost for an input formula that is simply Number
symbols["Number"]
Object {Number: "123"}
function anonymous(symbols/*``*/) {
symbols = symbols || {}; // 80
return (symbols["Number"]);
"123"
Doing the same once deployed onto Galaxy I get instead:
symbols["Number"]
Object {Number: "123"}
function anonymous(symbols/*``*/) {}
undefined
I have no idea how to even start debugging this.
I’m using Meteor 1.4.3.1
My packages:
accounts-base 1.2.14* A user account system
accounts-password 1.3.4* Password support for accounts
aldeed:autoform 5.8.1* Easily create forms with automatic insert and update, and automatic reactive validation.
aldeed:collection2 2.10.0 Automatic validation of insert and update operations on the client and server.
blaze-html-templates 1.1.0* Compile HTML templates into reactive UI with Meteor Blaze
ecmascript 0.6.3* Compiler plugin that supports ES2015+ in all .js files
email 1.1.18* Send email messages
es5-shim 4.6.15 Shims and polyfills to improve ECMAScript 5 support
fourseven:scss 3.13.0* Style with attitude. Sass and SCSS support for Meteor.js.
jquery 1.11.10 Manipulate the DOM using CSS selectors
kadira:blaze-layout 2.3.0 Layout Manager for Blaze (works well with FlowRouter)
kadira:flow-router 2.12.1 Carefully Designed Client Side Router for Meteor
less 2.7.9 Leaner CSS language
mdg:validated-method 1.1.0 A simple wrapper for Meteor.methods
meteor-base 1.0.4 Packages that every Meteor app needs
meteortoys:allthings 3.0.0 Insanely Handy Development Tools
mobile-experience 1.0.4 Packages for a great mobile user experience
mongo 1.1.15* Adaptor for using MongoDB and Minimongo over DDP
percolate:migrations 0.9.8 Define and run db migrations.
practicalmeteor:mocha 2.4.5_6 Write package tests with mocha and run them in the browser or from the command line with spacejam.
reactive-dict 1.1.8 Reactive dictionary
reactive-var 1.0.11 Reactive variable
sacha:spin 2.3.1 Simple spinner package for Meteor
session 1.1.7 Session variable
shell-server 0.2.2* Server-side component of the `meteor shell` command.
standard-minifier-css 1.3.4 Standard css minifier used with Meteor apps by default.
standard-minifier-js 1.2.3* Standard javascript minifiers used with Meteor apps by default.
supermongol 2.0.0+
tracker 1.1.2 Dependency tracker to allow reactive callbacks
twbs:bootstrap 3.3.6 The most popular front-end framework for developing responsive, mobile first projects on the web.
+-- babel-plugin-lodash@3.2.11
| `-- glob@7.1.1
| +-- fs.realpath@1.0.0
| +-- inflight@1.0.6
| | `-- wrappy@1.0.2
| +-- inherits@2.0.3
| +-- minimatch@3.0.3
| | `-- brace-expansion@1.1.6
| | +-- balanced-match@0.4.2
| | `-- concat-map@0.0.1
| +-- once@1.4.0
| `-- path-is-absolute@1.0.1
+-- babel-runtime@6.23.0
| +-- core-js@2.4.1
| `-- regenerator-runtime@0.10.3
+-- UNMET DEPENDENCY bcrypt@^0.8.7
+-- bootstrap-slider@9.8.0
+-- clipboard@1.6.1
| +-- good-listener@1.2.2
| | `-- delegate@3.1.2
| +-- select@1.1.2
| `-- tiny-emitter@1.1.0
+-- download-csv@1.1.1
+-- expression-parser@1.0.0
| `-- ramda@0.8.0
+-- guid@0.0.12
+-- lodash@4.17.4
+-- mailcomposer@3.12.0
| +-- buildmail@3.10.0
| | +-- addressparser@1.0.1
| | +-- libbase64@0.1.0
| | +-- libqp@1.1.0
| | +-- nodemailer-fetch@1.6.0
| | `-- nodemailer-shared@1.1.0
| `-- libmime@2.1.0
| `-- iconv-lite@0.4.13
+-- mailgun-js@0.7.15
| +-- async@2.1.5
| +-- debug@2.2.0
| | `-- ms@0.7.1
| +-- form-data@2.1.2
| | +-- asynckit@0.4.0
| | +-- combined-stream@1.0.5
| | | `-- delayed-stream@1.0.0
| | `-- mime-types@2.1.14
| | `-- mime-db@1.26.0
| +-- inflection@1.10.0
| +-- is-stream@1.1.0
| +-- path-proxy@1.0.0
| | `-- inflection@1.3.8
| +-- proxy-agent@2.0.0
| | +-- agent-base@2.0.1
| | | `-- semver@5.0.3
| | +-- extend@3.0.0
| | +-- http-proxy-agent@1.0.0
| | +-- https-proxy-agent@1.0.0
| | +-- lru-cache@2.6.5
| | +-- pac-proxy-agent@1.0.0
| | | +-- get-uri@1.1.0
| | | | +-- data-uri-to-buffer@0.0.4
| | | | +-- file-uri-to-path@0.0.2
| | | | +-- ftp@0.3.10
| | | | | +-- readable-stream@1.1.14
| | | | | | `-- isarray@0.0.1
| | | | | `-- xregexp@2.0.0
| | | | `-- readable-stream@2.2.3
| | | | +-- buffer-shims@1.0.0
| | | | +-- core-util-is@1.0.2
| | | | +-- isarray@1.0.0
| | | | +-- process-nextick-args@1.0.7
| | | | +-- string_decoder@0.10.31
| | | | `-- util-deprecate@1.0.2
| | | +-- pac-resolver@1.2.6
| | | | +-- co@3.0.6
| | | | +-- degenerator@1.0.4
| | | | | +-- ast-types@0.9.5
| | | | | +-- escodegen@1.8.1
| | | | | | +-- esprima@2.7.3
| | | | | | +-- estraverse@1.9.3
| | | | | | +-- esutils@2.0.2
| | | | | | +-- optionator@0.8.2
| | | | | | | +-- deep-is@0.1.3
| | | | | | | +-- fast-levenshtein@2.0.6
| | | | | | | +-- levn@0.3.0
| | | | | | | +-- prelude-ls@1.1.2
| | | | | | | +-- type-check@0.3.2
| | | | | | | `-- wordwrap@1.0.0
| | | | | | `-- source-map@0.2.0
| | | | | | `-- amdefine@1.0.1
| | | | | `-- esprima@3.1.3
| | | | +-- netmask@1.0.6
| | | | +-- regenerator@0.8.46
| | | | | +-- commoner@0.10.8
| | | | | | +-- commander@2.9.0
| | | | | | | `-- graceful-readlink@1.0.1
| | | | | | +-- detective@4.5.0
| | | | | | | +-- acorn@4.0.11
| | | | | | | `-- defined@1.0.0
| | | | | | +-- glob@5.0.15
| | | | | | +-- graceful-fs@4.1.11
| | | | | | +-- mkdirp@0.5.1
| | | | | | | `-- minimist@0.0.8
| | | | | | `-- recast@0.11.22
| | | | | | `-- source-map@0.5.6
| | | | | +-- defs@1.1.1
| | | | | | +-- alter@0.2.0
| | | | | | | `-- stable@0.1.5
| | | | | | +-- ast-traverse@0.1.1
| | | | | | +-- breakable@1.0.0
| | | | | | +-- esprima-fb@15001.1001.0-dev-harmony-fb
| | | | | | +-- simple-fmt@0.1.0
| | | | | | +-- simple-is@0.2.0
| | | | | | +-- stringmap@0.2.2
| | | | | | +-- stringset@0.2.1
| | | | | | +-- tryor@0.1.2
| | | | | | `-- yargs@3.27.0
| | | | | | +-- camelcase@1.2.1
| | | | | | +-- cliui@2.1.0
| | | | | | | +-- center-align@0.1.3
| | | | | | | | +-- align-text@0.1.4
| | | | | | | | | +-- kind-of@3.1.0
| | | | | | | | | | `-- is-buffer@1.1.4
| | | | | | | | | +-- longest@1.0.1
| | | | | | | | | `-- repeat-string@1.6.1
| | | | | | | | `-- lazy-cache@1.0.4
| | | | | | | +-- right-align@0.1.3
| | | | | | | `-- wordwrap@0.0.2
| | | | | | +-- decamelize@1.2.0
| | | | | | +-- os-locale@1.4.0
| | | | | | | `-- lcid@1.0.0
| | | | | | | `-- invert-kv@1.0.0
| | | | | | +-- window-size@0.1.4
| | | | | | `-- y18n@3.2.1
| | | | | +-- esprima-fb@15001.1001.0-dev-harmony-fb
| | | | | +-- private@0.1.7
| | | | | +-- recast@0.10.33
| | | | | | +-- ast-types@0.8.12
| | | | | | +-- esprima-fb@15001.1001.0-dev-harmony-fb
| | | | | | `-- source-map@0.5.6
| | | | | +-- regenerator-runtime@0.9.6
| | | | | `-- through@2.3.8
| | | | `-- thunkify@2.1.2
| | | `-- stream-to-buffer@0.1.0
| | | `-- stream-to@0.2.2
| | `-- socks-proxy-agent@2.0.0
| | `-- socks@1.1.10
| | +-- ip@1.1.5
| | `-- smart-buffer@1.1.15
| +-- q@1.4.1
| `-- tsscmp@1.0.5
+-- meteor-node-stubs@0.2.5
| +-- assert@1.4.1
| +-- browserify-zlib@0.1.4
| | `-- pako@0.2.9
| +-- buffer@4.9.1
| | +-- base64-js@1.2.0
| | +-- ieee754@1.1.8
| | `-- isarray@1.0.0
| +-- console-browserify@1.1.0
| | `-- date-now@0.1.4
| +-- constants-browserify@1.0.0
| +-- crypto-browserify@3.11.0
| | +-- browserify-cipher@1.0.0
| | | +-- browserify-aes@1.0.6
| | | | `-- buffer-xor@1.0.3
| | | +-- browserify-des@1.0.0
| | | | `-- des.js@1.0.0
| | | | `-- minimalistic-assert@1.0.0
| | | `-- evp_bytestokey@1.0.0
| | +-- browserify-sign@4.0.0
| | | +-- bn.js@4.11.6
| | | +-- browserify-rsa@4.0.1
| | | +-- elliptic@6.3.2
| | | | +-- brorand@1.0.6
| | | | `-- hash.js@1.0.3
| | | `-- parse-asn1@5.0.0
| | | `-- asn1.js@4.9.0
| | +-- create-ecdh@4.0.0
| | +-- create-hash@1.1.2
| | | +-- cipher-base@1.0.3
| | | +-- ripemd160@1.0.1
| | | `-- sha.js@2.4.8
| | +-- create-hmac@1.1.4
| | +-- diffie-hellman@5.0.2
| | | `-- miller-rabin@4.0.0
| | +-- inherits@2.0.1
| | +-- pbkdf2@3.0.9
| | +-- public-encrypt@4.0.0
| | `-- randombytes@2.0.3
| +-- domain-browser@1.1.7
| +-- events@1.1.1
| +-- http-browserify@1.7.0
| | `-- Base64@0.2.1
| +-- https-browserify@0.0.1
| +-- os-browserify@0.2.1
| +-- path-browserify@0.0.0
| +-- process@0.11.9
| +-- punycode@1.4.1
| +-- querystring-es3@0.2.1
| +-- readable-stream@2.2.1
| | +-- buffer-shims@1.0.0
| | +-- core-util-is@1.0.2
| | +-- process-nextick-args@1.0.7
| | `-- util-deprecate@1.0.2
| +-- stream-browserify@2.0.1
| +-- string_decoder@0.10.31
| +-- timers-browserify@1.4.2
| +-- tty-browserify@0.0.0
| +-- url@0.11.0
| | +-- punycode@1.3.2
| | `-- querystring@0.2.0
| +-- util@0.10.3
| `-- vm-browserify@0.0.4
| `-- indexof@0.0.1
+-- moment@2.17.1
+-- moment-round@1.0.1
`-- momentjs@2.0.0