suitescript-mocks
Version:
Set of mocks for unit testing Netsuite Suitescript 2.*
34 lines (27 loc) • 750 B
JavaScript
const { assignConstructor, options, required } = require("../../helpers.cjs");
class Cache {
name;
scope;
values = {};
get = (options) => {
if (!(options.key in this.values) && options.loader) {
const value = options.loader();
this.put(options.key, value);
}
return options.key in this.values ? this.values[options.key] : null;
};
put = (options) => {
this.values[options.key] = typeof options.value === "string" ? options.value : JSON.stringify(options.value);
};
remove = (options) => {
delete this.values[options.key];
};
}
module.exports = Cache;