@nebulaglitch/shopbot
Version:
A library to generate shopbot output
52 lines (49 loc) • 1.38 kB
JavaScript
import numeral from 'numeral';
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Command {
processArgs() {
const processedArgs = this.args.map((current)=>{
let result = current;
if (typeof current === 'number') {
if (Number.isInteger(current)) {
result = current;
} else if (isNaN(current)) {
result = '';
} else if (!isFinite(current)) {
result = '';
} else {
result = numeral(current).format('0.0000');
}
}
return result;
});
return processedArgs;
}
toString() {
let output = this.code;
if (this.args.length > 0) {
output += ', ' + this.processArgs().join(',');
}
return output;
}
constructor(code){
_define_property(this, "code", void 0);
_define_property(this, "args", void 0);
this.code = code;
this.args = [];
}
}
export { Command as default };
//# sourceMappingURL=command.js.map