mathjs
Version:
Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser and offers an integrated solution to work with numbers, big numbers, complex numbers, units, and matrices.
22 lines (18 loc) • 470 B
JavaScript
;
module.exports = function (math) {
/**
* Instantiate mathjs data types from their JSON representation
* @param {string} key
* @param {*} value
* @returns {*} Returns the revived object
*/
function reviver(key, value) {
var name = value && value.mathjs;
var constructor = math.type[name];
if (constructor && constructor.fromJSON) {
return constructor.fromJSON(value);
}
return value;
}
return reviver;
};