UNPKG

1.69 kBJavaScriptView Raw
1'use strict'
2
3const core = require('./core/core')
4
5/**
6 * math.js factory function. Creates a new instance of math.js
7 *
8 * @param {Object} [config] Available configuration options:
9 * {number} epsilon
10 * Minimum relative difference between two
11 * compared values, used by all comparison functions.
12 * {string} matrix
13 * A string 'matrix' (default) or 'array'.
14 * {string} number
15 * A string 'number' (default), 'bignumber', or
16 * 'fraction'
17 * {number} precision
18 * The number of significant digits for BigNumbers.
19 * Not applicable for Numbers.
20 * {boolean} predictable
21 * Predictable output type of functions. When true,
22 * output type depends only on the input types. When
23 * false (default), output type can vary depending
24 * on input values. For example `math.sqrt(-4)`
25 * returns `complex('2i')` when predictable is false, and
26 * returns `NaN` when true.
27 */
28function create (config) {
29 // create a new math.js instance
30 const math = core.create(config)
31 math.create = create
32
33 // import data types, functions, constants, expression parser, etc.
34 math['import'](require('./index'))
35
36 return math
37}
38
39// return a new instance of math.js
40module.exports = create()