UNPKG

mathjs

Version:

Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with dif

25 lines (20 loc) 605 B
import { factory } from '../utils/factory' const name = 'reviver' const dependencies = [ 'classes' ] export const createReviver = /* #__PURE__ */ factory(name, dependencies, ({ classes }) => { /** * Instantiate mathjs data types from their JSON representation * @param {string} key * @param {*} value * @returns {*} Returns the revived object */ return function reviver (key, value) { const constructor = classes[value && value.mathjs] if (constructor && typeof constructor.fromJSON === 'function') { return constructor.fromJSON(value) } return value } })