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: unpkg - https://unpkg.com/mathjs@7.0.1/ + https://unpkg.com/mathjs@7.0.2/ cdnjs @@ -51,18 +51,18 @@ Here some direct download links from [unpkg](https://unpkg.com):
- - 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 @@ math.js | basic usage - + diff --git a/examples/browser/basic_usage.html.md b/examples/browser/basic_usage.html.md index 6b1ca8bfa..cd5a28ec0 100644 --- a/examples/browser/basic_usage.html.md +++ b/examples/browser/basic_usage.html.md @@ -12,7 +12,7 @@ File: [basic_usage.html](basic_usage.html) (click for a live demo) math.js | basic usage - + diff --git a/examples/browser/currency_conversion.html b/examples/browser/currency_conversion.html index 86eaa427b..38fc988a1 100644 --- a/examples/browser/currency_conversion.html +++ b/examples/browser/currency_conversion.html @@ -4,7 +4,7 @@ math.js | currency conversion - + - + diff --git a/examples/browser/custom_separators.html.md b/examples/browser/custom_separators.html.md index 929fc695d..96d160a8f 100644 --- a/examples/browser/custom_separators.html.md +++ b/examples/browser/custom_separators.html.md @@ -24,7 +24,7 @@ File: [custom_separators.html](custom_separators.html) (click for a live demo) } - + diff --git a/examples/browser/plot.html b/examples/browser/plot.html index c4eb7efc7..b205849e2 100644 --- a/examples/browser/plot.html +++ b/examples/browser/plot.html @@ -3,7 +3,7 @@ math.js | plot - + diff --git a/examples/browser/plot.html.md b/examples/browser/plot.html.md index b4b922efe..0df606a4f 100644 --- a/examples/browser/plot.html.md +++ b/examples/browser/plot.html.md @@ -12,7 +12,7 @@ File: [plot.html](plot.html) (click for a live demo) math.js | plot - + diff --git a/examples/browser/pretty_printing_with_mathjax.html b/examples/browser/pretty_printing_with_mathjax.html index 1885b5210..4661e4997 100644 --- a/examples/browser/pretty_printing_with_mathjax.html +++ b/examples/browser/pretty_printing_with_mathjax.html @@ -4,7 +4,7 @@ math.js | pretty printing with MathJax - +