solorice/vscode/extensions/patbenatar.advanced-new-file-1.2.2/node_modules/vscode-cache/test/ExtensionContextMock.js
2022-04-28 20:54:44 +03:00

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;