const moment = require("moment") module.exports = class { onCreate(input) { this.state = { modal: null, deleted: false, date: moment(input.data.time).format("MMM D, YYYY"), } } onInput(input) { if (input && input.data) { this.state.date = moment(input.data.time).format("MMM D, YYYY") } } open(modal) { this.state.modal = modal } close() { this.state.modal = null } removed() { this.state.deleted = true this.emit("removed") } sizeString(bytes) { const order = Math.floor(Math.log2(bytes) / 10) const unit = ["B", "KB", "MB", "GB", "TB", "PB"][order] const number = bytes / Math.pow(2, (order)*10) return `${number.toFixed(2)} ${unit}` } }