mirror of
https://github.com/josdejong/mathjs.git
synced 2025-12-08 19:46:04 +00:00
32 lines
563 B
JavaScript
32 lines
563 B
JavaScript
var Node = require('./Node'),
|
|
string = require('../../util/string');
|
|
|
|
/**
|
|
* @constructor ConstantNode
|
|
* @param {*} value
|
|
* @extends {Node}
|
|
*/
|
|
function ConstantNode(value) {
|
|
this.value = value;
|
|
}
|
|
|
|
ConstantNode.prototype = new Node();
|
|
|
|
/**
|
|
* Evaluate the constant (just return it)
|
|
* @return {*} value
|
|
*/
|
|
ConstantNode.prototype.eval = function () {
|
|
return this.value;
|
|
};
|
|
|
|
/**
|
|
* Get string representation
|
|
* @return {String} str
|
|
*/
|
|
ConstantNode.prototype.toString = function() {
|
|
return string.format(this.value);
|
|
};
|
|
|
|
module.exports = ConstantNode;
|