MCPcopy Index your code
hub / github.com/josdejong/mathjs / getMath

Function getMath

bin/cli.js:61–76  ·  view source on GitHub ↗

* "Lazy" load math.js: only require when we actually start using it. * This ensures the cli application looks like it loads instantly. * When requesting help or version number, math.js isn't even loaded. * @return {{ evalute: function, parse: function, math: Object }}

()

Source from the content-addressed store, hash-verified

59 * @return {{ evalute: function, parse: function, math: Object }}
60 */
61function getMath () {
62 const { create, all } = require('../lib/browser/math.js')
63
64 const math = create(all)
65 const parse = math.parse
66 const evaluate = math.evaluate
67
68 // See https://mathjs.org/docs/expressions/security.html#less-vulnerable-expression-parser
69 math.import({
70 'import': function () { throw new Error('Function import is disabled') },
71 'createUnit': function () { throw new Error('Function createUnit is disabled') },
72 'reviver': function () { throw new Error('Function reviver is disabled') }
73 }, { override: true })
74
75 return { math, parse, evaluate }
76}
77
78/**
79 * Helper function to format a value. Regular numbers will be rounded

Callers 5

formatFunction · 0.85
completerFunction · 0.85
runStreamFunction · 0.85
findSymbolNameFunction · 0.85
cli.jsFile · 0.85

Calls 2

importMethod · 0.80
createFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…