mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-20 15:23:50 +02:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import * as workerTimers from 'worker-timers';
|
|
/* eslint-disable no-unused-vars */
|
|
let VRCXStorage = {};
|
|
/* eslint-enable no-unused-vars */
|
|
|
|
export default class {
|
|
constructor(_VRCXStorage) {
|
|
VRCXStorage = _VRCXStorage;
|
|
this.init();
|
|
}
|
|
|
|
init() {
|
|
VRCXStorage.GetArray = async function (key) {
|
|
try {
|
|
var array = JSON.parse(await this.Get(key));
|
|
if (Array.isArray(array)) {
|
|
return array;
|
|
}
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
return [];
|
|
};
|
|
|
|
VRCXStorage.SetArray = function (key, value) {
|
|
this.Set(key, JSON.stringify(value));
|
|
};
|
|
|
|
VRCXStorage.GetObject = async function (key) {
|
|
try {
|
|
var object = JSON.parse(await this.Get(key));
|
|
if (object === Object(object)) {
|
|
return object;
|
|
}
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
return {};
|
|
};
|
|
|
|
VRCXStorage.SetObject = function (key, value) {
|
|
this.Set(key, JSON.stringify(value));
|
|
};
|
|
|
|
workerTimers.setInterval(
|
|
() => {
|
|
VRCXStorage.Flush();
|
|
},
|
|
5 * 60 * 1000
|
|
);
|
|
}
|
|
}
|