diff --git a/download.md b/download.md index fe7a01be7..b1934d7ae 100644 --- a/download.md +++ b/download.md @@ -29,7 +29,7 @@ Math.js can be downloaded or linked from various content delivery networks:
| - - Development (version 7.0.1) + + Development (version 7.0.2) | - 1822 kB, uncompressed with comments + 1823 kB, uncompressed with comments |
| - - Production (version 7.0.1) + + Production (version 7.0.2) |
diff --git a/examples/advanced/custom_evaluate_using_factories.js b/examples/advanced/custom_evaluate_using_factories.js
new file mode 100644
index 000000000..e8788453b
--- /dev/null
+++ b/examples/advanced/custom_evaluate_using_factories.js
@@ -0,0 +1,19 @@
+const { create, evaluateDependencies, factory } = require('../..')
+
+// custom implementations of all functions you want to support
+const add = (a, b) => a + b
+const subtract = (a, b) => a - b
+const multiply = (a, b) => a * b
+const divide = (a, b) => a / b
+
+// create factories for the functions, and create an evaluate function with those
+// these functions will also be used by the classes like Unit.
+const { evaluate } = create({
+ evaluateDependencies,
+ createAdd: factory('add', [], () => add),
+ createSubtract: factory('subtract', [], () => subtract),
+ createMultiply: factory('multiply', [], () => multiply),
+ createDivide: factory('divide', [], () => divide)
+})
+
+console.log(evaluate('2 + 3 * 4')) // 14
diff --git a/examples/advanced/custom_evaluate_using_factories.js.md b/examples/advanced/custom_evaluate_using_factories.js.md
new file mode 100644
index 000000000..7a0053128
--- /dev/null
+++ b/examples/advanced/custom_evaluate_using_factories.js.md
@@ -0,0 +1,33 @@
+---
+layout: default
+---
+
+# Custom evaluate using factories
+
+File: [custom_evaluate_using_factories.js](custom_evaluate_using_factories.js)
+
+```js
+const { create, evaluateDependencies, factory } = require('../..')
+
+// custom implementations of all functions you want to support
+const add = (a, b) => a + b
+const subtract = (a, b) => a - b
+const multiply = (a, b) => a * b
+const divide = (a, b) => a / b
+
+// create factories for the functions, and create an evaluate function with those
+// these functions will also be used by the classes like Unit.
+const { evaluate } = create({
+ evaluateDependencies,
+ createAdd: factory('add', [], () => add),
+ createSubtract: factory('subtract', [], () => subtract),
+ createMultiply: factory('multiply', [], () => multiply),
+ createDivide: factory('divide', [], () => divide)
+})
+
+console.log(evaluate('2 + 3 * 4')) // 14
+
+```
+
+
+
diff --git a/examples/advanced/custom_evaluate_using_import.js b/examples/advanced/custom_evaluate_using_import.js
new file mode 100644
index 000000000..3c486b3be
--- /dev/null
+++ b/examples/advanced/custom_evaluate_using_import.js
@@ -0,0 +1,18 @@
+const { create, evaluateDependencies } = require('../..')
+
+// custom implementations of all functions you want to support
+const add = (a, b) => a + b
+const subtract = (a, b) => a - b
+const multiply = (a, b) => a * b
+const divide = (a, b) => a / b
+
+// create a mathjs instance with hardly any functions
+// there are some functions created which are used internally by evaluate though,
+// for example by the Unit class which has dependencies on addScalar, subtract,
+// multiplyScalar, etc.
+const math = create(evaluateDependencies)
+
+// import your own functions
+math.import({ add, subtract, multiply, divide }, { override: true })
+
+console.log(math.evaluate('2 + 3 * 4')) // 14
diff --git a/examples/advanced/custom_evaluate_using_import.js.md b/examples/advanced/custom_evaluate_using_import.js.md
new file mode 100644
index 000000000..585e78dcb
--- /dev/null
+++ b/examples/advanced/custom_evaluate_using_import.js.md
@@ -0,0 +1,32 @@
+---
+layout: default
+---
+
+# Custom evaluate using import
+
+File: [custom_evaluate_using_import.js](custom_evaluate_using_import.js)
+
+```js
+const { create, evaluateDependencies } = require('../..')
+
+// custom implementations of all functions you want to support
+const add = (a, b) => a + b
+const subtract = (a, b) => a - b
+const multiply = (a, b) => a * b
+const divide = (a, b) => a / b
+
+// create a mathjs instance with hardly any functions
+// there are some functions created which are used internally by evaluate though,
+// for example by the Unit class which has dependencies on addScalar, subtract,
+// multiplyScalar, etc.
+const math = create(evaluateDependencies)
+
+// import your own functions
+math.import({ add, subtract, multiply, divide }, { override: true })
+
+console.log(math.evaluate('2 + 3 * 4')) // 14
+
+```
+
+
+
diff --git a/examples/browser/angle_configuration.html b/examples/browser/angle_configuration.html
index 774554260..5c6502b1e 100644
--- a/examples/browser/angle_configuration.html
+++ b/examples/browser/angle_configuration.html
@@ -15,7 +15,7 @@
}
-
+
diff --git a/examples/browser/angle_configuration.html.md b/examples/browser/angle_configuration.html.md
index aea782f2d..a6b84cc5d 100644
--- a/examples/browser/angle_configuration.html.md
+++ b/examples/browser/angle_configuration.html.md
@@ -24,7 +24,7 @@ File: [angle_configuration.html](angle_configuration.html) (click for a live dem
}
-
+
diff --git a/examples/browser/basic_usage.html b/examples/browser/basic_usage.html
index 096c530d4..11577b161 100644
--- a/examples/browser/basic_usage.html
+++ b/examples/browser/basic_usage.html
@@ -3,7 +3,7 @@
|