From 2c7d86f4071aa441e80f4263baea48259eb1b7f9 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 13 Feb 2018 12:36:31 +0100 Subject: [PATCH] mathjs: update to v4rc --- package.json | 2 +- src/browser/js/app/widgets/utils.js | 33 ++++++++++++++++++----------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 2e909cae..7a45d5b6 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "keyboardjs": "jean-emmanuel/KeyboardJS", "kiwi.js": "1.0.1", "licensify": "3.1.3", - "mathjs": "3.20.2", + "mathjs": "^4.0.0-rc.1", "minimatch": "^3.0.4", "nanomorph": "^5.1.3", "node-sass": "4.7.2", diff --git a/src/browser/js/app/widgets/utils.js b/src/browser/js/app/widgets/utils.js index 8ec9d743..cceeb7bb 100644 --- a/src/browser/js/app/widgets/utils.js +++ b/src/browser/js/app/widgets/utils.js @@ -1,14 +1,3 @@ -var math = require('mathjs/dist/math.min.js').create({ - matrix: 'Array' -}) -math.import({ - unpack: function(a) { return Array.isArray(a) ? a.toString() : a } -}) - -// set math's parser array index base to zero -math.expression.mathWithTransform = Object.assign({}, math) - - module.exports = { clip: function(value,range) { @@ -81,5 +70,25 @@ module.exports = { return hsb }, - math: math + math: (()=>{ + var math = require('mathjs/dist/math.min.js').create({ + matrix: 'Array' + }) + math.import({ + unpack: function(a) { return Array.isArray(a) ? a.toString() : a }, + // basic relationnal to keep alphabetical string comparison (v4 change) + equal: function (a, b) { return a == b }, + unequal: function (a, b) { return a != b }, + smaller: function (a, b) { return a < b }, + larger: function (a, b) { return a > b }, + smallerEq: function (a, b) { return a <= b }, + largerEq: function (a, b) { return a >= b } + }, {override:true}) + + // set math's parser array index base to zero + math.expression.mathWithTransform = Object.assign({}, math) + + return math + })() + }