@nebulaglitch/shopbot
Version:
A library to generate shopbot output
60 lines (53 loc) • 1.66 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
const numeral = require('numeral');
const _interopDefault = e => e && e.__esModule ? e : { default: e };
const numeral__default = /*#__PURE__*/_interopDefault(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__default.default(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 = [];
}
}
exports.default = Command;
//# sourceMappingURL=command.cjs.map