Files
VRCX/src/service/jsonStorage.js
2025-10-16 13:28:19 +11:00

43 lines
1.1 KiB
JavaScript

let VRCXStorage = {};
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));
};
}
}