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

74 lines (68 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createResultSet = void 0; var _factory = require("../../utils/factory.js"); const name = 'ResultSet'; const dependencies = []; const createResultSet = exports.createResultSet = /* #__PURE__ */(0, _factory.factory)(name, dependencies, () => { /** * A ResultSet contains a list or results * @class ResultSet * @param {Array} entries * @constructor ResultSet */ function ResultSet(entries) { if (!(this instanceof ResultSet)) { throw new SyntaxError('Constructor must be called with the new operator'); } this.entries = entries || []; } /** * Attach type information */ ResultSet.prototype.type = 'ResultSet'; ResultSet.prototype.isResultSet = true; /** * Returns the array with results hold by this ResultSet * @memberof ResultSet * @returns {Array} entries */ ResultSet.prototype.valueOf = function () { return this.entries; }; /** * Returns the stringified results of the ResultSet * @memberof ResultSet * @returns {string} string */ ResultSet.prototype.toString = function () { return '[' + this.entries.map(String).join(', ') + ']'; }; /** * Get a JSON representation of the ResultSet * @memberof ResultSet * @returns {Object} Returns a JSON object structured as: * `{"mathjs": "ResultSet", "entries": [...]}` */ ResultSet.prototype.toJSON = function () { return { mathjs: 'ResultSet', entries: this.entries }; }; /** * Instantiate a ResultSet from a JSON object * @memberof ResultSet * @param {Object} json A JSON object structured as: * `{"mathjs": "ResultSet", "entries": [...]}` * @return {ResultSet} */ ResultSet.fromJSON = function (json) { return new ResultSet(json.entries); }; return ResultSet; }, { isClass: true });