* Create new Database * @param {String} filepath Path to specified json database * @param {...any} args JSON.stringify arguments
(filepath, ...args)
| 9 | * @param {...any} args JSON.stringify arguments |
| 10 | */ |
| 11 | constructor(filepath, ...args) { |
| 12 | this.file = resolve(filepath) |
| 13 | this.logger = console |
| 14 | |
| 15 | this._load() |
| 16 | |
| 17 | this._jsonargs = args |
| 18 | this._state = false |
| 19 | this._queue = [] |
| 20 | this._interval = setInterval(async () => { |
| 21 | if (!this._state && this._queue && this._queue[0]) { |
| 22 | this._state = true |
| 23 | await this[this._queue.shift()]().catch(this.logger.error) |
| 24 | this._state = false |
| 25 | } |
| 26 | }, 1000) |
| 27 | } |
| 28 | |
| 29 | get data() { |
| 30 | return this._data |