mirror of
https://github.com/kristoferssolo/solorice.git
synced 2025-10-21 20:10:34 +00:00
38 lines
755 B
JavaScript
38 lines
755 B
JavaScript
'use strict';
|
|
|
|
const Promise = require('bluebird');
|
|
|
|
let ExtensionContextMock = function () {
|
|
this.globalState = {};
|
|
|
|
// Get the cached item
|
|
this.globalState.get = function (key, defaultValue) {
|
|
|
|
// If key does not exist
|
|
if (typeof (this[key]) === 'undefined') {
|
|
|
|
// If default value is provided
|
|
if (typeof (defaultValue) !== 'undefined') {
|
|
return defaultValue;
|
|
} else {
|
|
return undefined;
|
|
}
|
|
|
|
} else {
|
|
|
|
return this[key];
|
|
|
|
}
|
|
}
|
|
|
|
// Update a cached item
|
|
this.globalState.update = function (key, value) {
|
|
this[key] = value;
|
|
|
|
return new Promise((resolve, reject) => {
|
|
resolve(true);
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = ExtensionContextMock; |