From 8b5eb89a02c28b9fbc6830d45e7ca2aa293d153d Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 16 Jun 2018 14:57:28 +0200 Subject: [PATCH] Minor tweaks in the docs --- README.md | 4 ++-- docs/core/serialization.md | 4 ++-- docs/datatypes/complex_numbers.md | 8 ++++---- docs/expressions/html_classes.md | 2 +- docs/expressions/syntax.md | 4 ++-- docs/getting_started.md | 12 ++++++++++++ docs/reference/units.md | 3 --- examples/bignumbers.js | 2 +- 8 files changed, 24 insertions(+), 15 deletions(-) delete mode 100644 docs/reference/units.md diff --git a/README.md b/README.md index 0a5cd0adf..e55c40ea9 100644 --- a/README.md +++ b/README.md @@ -75,8 +75,8 @@ See the [Getting Started](http://mathjs.org/docs/getting_started.html) for a mor Math.js works on any ES5 compatible JavaScript engine: node.js 4 or newer, Chrome, Firefox, Safari, Edge, and IE11. -Though there is no official support for older browsers, -math.js should still work when using the [es5-shim](https://github.com/kriskowal/es5-shim). +Though there is no official support for older browsers, math.js should still work on older browsers +when using the [es5-shim](https://github.com/kriskowal/es5-shim). ## Documentation diff --git a/docs/core/serialization.md b/docs/core/serialization.md index 9554daf60..81751c170 100644 --- a/docs/core/serialization.md +++ b/docs/core/serialization.md @@ -13,7 +13,7 @@ Math.js types can be serialized using JavaScript's built-in `JSON.stringify` function: ```js -const x = math.complex('2 + 3i') +const x = math.complex('2 + 3i') const str = JSON.stringify(x) console.log(str) // outputs a string '{"mathjs":"Complex","re":2,"im":3}' @@ -25,7 +25,7 @@ be called with the reviver function of math.js: ```js const json = '{"mathjs":"Unit","value":5,"unit":"cm","fixPrefix":false}' -const x = JSON.parse(json, math.json.reviver) // Unit 5 cm +const x = JSON.parse(json, math.json.reviver) // Unit 5 cm ``` Note that if math.js is used in conjunction with other data types, it is diff --git a/docs/datatypes/complex_numbers.md b/docs/datatypes/complex_numbers.md index 01e0a6ece..d427780e2 100644 --- a/docs/datatypes/complex_numbers.md +++ b/docs/datatypes/complex_numbers.md @@ -159,10 +159,10 @@ Returns the comparision result of two complex number: Example: ```js -var a = math.complex(2, 3); // Complex 2 + 3i -var b = math.complex(2, 1); // Complex 2 + 1i -math.type.Complex.compare(a,b); // returns 1 +const a = math.complex(2, 3) // Complex 2 + 3i +const b = math.complex(2, 1) // Complex 2 + 1i +math.type.Complex.compare(a,b) // returns 1 //create from json -var c = math.type.Complex.fromJSON({mathjs: 'Complex', re: 4, im: 3}); // Complex 4 + 3i +const c = math.type.Complex.fromJSON({mathjs: 'Complex', re: 4, im: 3}) // Complex 4 + 3i ``` diff --git a/docs/expressions/html_classes.md b/docs/expressions/html_classes.md index a9f469ec2..8922765d9 100644 --- a/docs/expressions/html_classes.md +++ b/docs/expressions/html_classes.md @@ -35,4 +35,4 @@ highlight the syntax or change the default layout (e.g. spaces around operators) -`math-round-parenthesis` (`(` and `)`) -`math-square-parenthesis` (`[` and `]`) -`math-curly-parenthesis` (`{` and `}`) -- `math-separator` (�,`, `;` and `
`) \ No newline at end of file +- `math-separator` (�,`, `;` and <br />) \ No newline at end of file diff --git a/docs/expressions/syntax.md b/docs/expressions/syntax.md index d1c9caf62..f50479189 100644 --- a/docs/expressions/syntax.md +++ b/docs/expressions/syntax.md @@ -278,7 +278,7 @@ When outputting results, the function `math.format` can be used to hide these round-off errors when outputting results for the user: ```js -const ans = math.eval('0.1 + 0.2') // 0.30000000000000004 +const ans = math.eval('0.1 + 0.2') // 0.30000000000000004 math.format(ans, {precision: 14}) // "0.3" ``` @@ -370,7 +370,7 @@ math.eval('5.4 kg') // Unit, 5.4 kg // convert a unit math.eval('2 inch to cm') // Unit, 5.08 cm math.eval('20 celsius in fahrenheit') // Unit, ~68 fahrenheit -math.eval('90 km/h to m/s'); // Unit, 25 m / s +math.eval('90 km/h to m/s') // Unit, 25 m / s // convert a unit to a number // A second parameter with the unit for the exported number must be provided diff --git a/docs/getting_started.md b/docs/getting_started.md index fbed87272..bf0f9cd33 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -21,6 +21,18 @@ and instantiated. When creating an instance, one can optionally provide configuration options as described in [Configuration](configuration.md). +### ES6 modules + +Load math.js using ES6 import: + +```js +// load math.js +import * as math from 'mathjs' + +// use math.js +math.sqrt(-4) // 2i +``` + ### Node.js Load math.js in [node.js](http://nodejs.org/): diff --git a/docs/reference/units.md b/docs/reference/units.md deleted file mode 100644 index 806ce9145..000000000 --- a/docs/reference/units.md +++ /dev/null @@ -1,3 +0,0 @@ -# Unit reference - -The unit reference has been moved to [Units](../datatypes/units.md). \ No newline at end of file diff --git a/examples/bignumbers.js b/examples/bignumbers.js index d6ea50d4b..b892dac4e 100644 --- a/examples/bignumbers.js +++ b/examples/bignumbers.js @@ -26,7 +26,7 @@ print(math.bignumber('1.2e+500')) // BigNumber, 1.2e+500 console.log() console.log('BigNumbers still have a limited precision and are no silve bullet') -const third = math.divide(math.bignumber(1), math.bignumber(3)); +const third = math.divide(math.bignumber(1), math.bignumber(3)) const total = math.add(third, third, third) print(total) // BigNumber, 0.99999999999999999999 console.log()