Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

configcat-common

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

configcat-common - npm Package Compare versions

Comparing version 4.4.6 to 4.5.0

18

lib/AutoPollConfigService.js

@@ -95,6 +95,7 @@ "use strict";

switch (_a.label) {
case 0:
cachedConfig = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
cachedConfig = _a.sent();
return [4 /*yield*/, this.refreshLogicBaseAsync(cachedConfig, forceUpdateCache)];
case 1:
case 2:
newConfig = _a.sent();

@@ -125,13 +126,14 @@ weDontHaveCachedYetButHaveNew = !cachedConfig && newConfig;

switch (_a.label) {
case 0:
p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
if (!(this.maxInitWaitTimeStamp > new Date().getTime() && !p)) return [3 /*break*/, 2];
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
if (!(this.maxInitWaitTimeStamp > new Date().getTime() && !p)) return [3 /*break*/, 3];
diff = this.maxInitWaitTimeStamp - new Date().getTime();
delay = 30 + (tries * tries * 20);
return [4 /*yield*/, this.sleep(Math.min(diff, delay))];
case 1:
case 2:
_a.sent();
tries++;
return [2 /*return*/, this.tryReadFromCache(tries)];
case 2: return [2 /*return*/, new Promise(function (resolve) { return resolve(p); })];
case 3: return [2 /*return*/, new Promise(function (resolve) { return resolve(p); })];
}

@@ -138,0 +140,0 @@ });

@@ -95,6 +95,7 @@ "use strict";

switch (_a.label) {
case 0:
cachedConfig = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
cachedConfig = _a.sent();
return [4 /*yield*/, this.refreshLogicBaseAsync(cachedConfig, forceUpdateCache)];
case 1:
case 2:
newConfig = _a.sent();

@@ -125,13 +126,14 @@ weDontHaveCachedYetButHaveNew = !cachedConfig && newConfig;

switch (_a.label) {
case 0:
p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
if (!(this.maxInitWaitTimeStamp > new Date().getTime() && !p)) return [3 /*break*/, 2];
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
if (!(this.maxInitWaitTimeStamp > new Date().getTime() && !p)) return [3 /*break*/, 3];
diff = this.maxInitWaitTimeStamp - new Date().getTime();
delay = 30 + (tries * tries * 20);
return [4 /*yield*/, this.sleep(Math.min(diff, delay))];
case 1:
case 2:
_a.sent();
tries++;
return [2 /*return*/, this.tryReadFromCache(tries)];
case 2: return [2 /*return*/, new Promise(function (resolve) { return resolve(p); })];
case 3: return [2 /*return*/, new Promise(function (resolve) { return resolve(p); })];
}

@@ -138,0 +140,0 @@ });

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -14,13 +50,22 @@ exports.ConfigServiceBase = void 0;

return new Promise(function (resolve) {
_this.fetchLogic(_this.baseConfig, lastProjectConfig, 0, function (newConfig) {
if (newConfig && newConfig.ConfigJSON) {
if (forceUpdateCache || !ProjectConfig_1.ProjectConfig.equals(newConfig, lastProjectConfig)) {
_this.baseConfig.cache.set(_this.baseConfig.getCacheKey(), newConfig);
_this.fetchLogic(_this.baseConfig, lastProjectConfig, 0, function (newConfig) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(newConfig && newConfig.ConfigJSON)) return [3 /*break*/, 3];
if (!(forceUpdateCache || !ProjectConfig_1.ProjectConfig.equals(newConfig, lastProjectConfig))) return [3 /*break*/, 2];
return [4 /*yield*/, this.baseConfig.cache.set(this.baseConfig.getCacheKey(), newConfig)];
case 1:
_a.sent();
_a.label = 2;
case 2:
resolve(newConfig);
return [3 /*break*/, 4];
case 3:
resolve(lastProjectConfig);
_a.label = 4;
case 4: return [2 /*return*/];
}
resolve(newConfig);
}
else {
resolve(lastProjectConfig);
}
});
});
}); });
});

@@ -27,0 +72,0 @@ };

@@ -60,4 +60,4 @@ import { IConfigCatClient } from "./ConfigCatClient";

export interface ICache {
set(key: string, config: ProjectConfig): void;
get(key: string): ProjectConfig;
set(key: string, config: ProjectConfig): Promise<void> | void;
get(key: string): Promise<ProjectConfig> | ProjectConfig;
}

@@ -64,0 +64,0 @@ export { ProjectConfig } from "./ProjectConfig";

@@ -15,2 +15,38 @@ "use strict";

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -27,13 +63,32 @@ exports.LazyLoadConfigService = void 0;

LazyLoadConfigService.prototype.getConfig = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
if (p && p.Timestamp + (this.cacheTimeToLiveSeconds * 1000) > new Date().getTime()) {
return new Promise(function (resolve) { return resolve(p); });
}
else {
return this.refreshLogicBaseAsync(p);
}
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
if (p && p.Timestamp + (this.cacheTimeToLiveSeconds * 1000) > new Date().getTime()) {
return [2 /*return*/, p];
}
else {
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
return [2 /*return*/];
}
});
});
};
LazyLoadConfigService.prototype.refreshConfigAsync = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
return this.refreshLogicBaseAsync(p);
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
});
});
};

@@ -40,0 +95,0 @@ return LazyLoadConfigService;

@@ -15,2 +15,38 @@ "use strict";

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,8 +61,26 @@ exports.ManualPollService = void 0;

ManualPollService.prototype.getConfig = function () {
var _this = this;
return new Promise(function (resolve) { return resolve(_this.baseConfig.cache.get(_this.baseConfig.getCacheKey())); });
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, p];
}
});
});
};
ManualPollService.prototype.refreshConfigAsync = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
return this.refreshLogicBaseAsync(p);
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
});
});
};

@@ -33,0 +87,0 @@ return ManualPollService;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = "4.4.6";
exports.default = "4.5.0";
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -14,13 +50,22 @@ exports.ConfigServiceBase = void 0;

return new Promise(function (resolve) {
_this.fetchLogic(_this.baseConfig, lastProjectConfig, 0, function (newConfig) {
if (newConfig && newConfig.ConfigJSON) {
if (forceUpdateCache || !ProjectConfig_1.ProjectConfig.equals(newConfig, lastProjectConfig)) {
_this.baseConfig.cache.set(_this.baseConfig.getCacheKey(), newConfig);
_this.fetchLogic(_this.baseConfig, lastProjectConfig, 0, function (newConfig) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(newConfig && newConfig.ConfigJSON)) return [3 /*break*/, 3];
if (!(forceUpdateCache || !ProjectConfig_1.ProjectConfig.equals(newConfig, lastProjectConfig))) return [3 /*break*/, 2];
return [4 /*yield*/, this.baseConfig.cache.set(this.baseConfig.getCacheKey(), newConfig)];
case 1:
_a.sent();
_a.label = 2;
case 2:
resolve(newConfig);
return [3 /*break*/, 4];
case 3:
resolve(lastProjectConfig);
_a.label = 4;
case 4: return [2 /*return*/];
}
resolve(newConfig);
}
else {
resolve(lastProjectConfig);
}
});
});
}); });
});

@@ -27,0 +72,0 @@ };

@@ -92,6 +92,7 @@ var __extends = (this && this.__extends) || (function () {

switch (_a.label) {
case 0:
cachedConfig = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
cachedConfig = _a.sent();
return [4 /*yield*/, this.refreshLogicBaseAsync(cachedConfig, forceUpdateCache)];
case 1:
case 2:
newConfig = _a.sent();

@@ -122,13 +123,14 @@ weDontHaveCachedYetButHaveNew = !cachedConfig && newConfig;

switch (_a.label) {
case 0:
p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
if (!(this.maxInitWaitTimeStamp > new Date().getTime() && !p)) return [3 /*break*/, 2];
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
if (!(this.maxInitWaitTimeStamp > new Date().getTime() && !p)) return [3 /*break*/, 3];
diff = this.maxInitWaitTimeStamp - new Date().getTime();
delay = 30 + (tries * tries * 20);
return [4 /*yield*/, this.sleep(Math.min(diff, delay))];
case 1:
case 2:
_a.sent();
tries++;
return [2 /*return*/, this.tryReadFromCache(tries)];
case 2: return [2 /*return*/, new Promise(function (resolve) { return resolve(p); })];
case 3: return [2 /*return*/, new Promise(function (resolve) { return resolve(p); })];
}

@@ -135,0 +137,0 @@ });

@@ -0,1 +1,37 @@

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { ConfigFile, Preferences, ProjectConfig } from "./ProjectConfig";

@@ -11,13 +47,22 @@ var ConfigServiceBase = /** @class */ (function () {

return new Promise(function (resolve) {
_this.fetchLogic(_this.baseConfig, lastProjectConfig, 0, function (newConfig) {
if (newConfig && newConfig.ConfigJSON) {
if (forceUpdateCache || !ProjectConfig.equals(newConfig, lastProjectConfig)) {
_this.baseConfig.cache.set(_this.baseConfig.getCacheKey(), newConfig);
_this.fetchLogic(_this.baseConfig, lastProjectConfig, 0, function (newConfig) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!(newConfig && newConfig.ConfigJSON)) return [3 /*break*/, 3];
if (!(forceUpdateCache || !ProjectConfig.equals(newConfig, lastProjectConfig))) return [3 /*break*/, 2];
return [4 /*yield*/, this.baseConfig.cache.set(this.baseConfig.getCacheKey(), newConfig)];
case 1:
_a.sent();
_a.label = 2;
case 2:
resolve(newConfig);
return [3 /*break*/, 4];
case 3:
resolve(lastProjectConfig);
_a.label = 4;
case 4: return [2 /*return*/];
}
resolve(newConfig);
}
else {
resolve(lastProjectConfig);
}
});
});
}); });
});

@@ -24,0 +69,0 @@ };

@@ -60,4 +60,4 @@ import { IConfigCatClient } from "./ConfigCatClient";

export interface ICache {
set(key: string, config: ProjectConfig): void;
get(key: string): ProjectConfig;
set(key: string, config: ProjectConfig): Promise<void> | void;
get(key: string): Promise<ProjectConfig> | ProjectConfig;
}

@@ -64,0 +64,0 @@ export { ProjectConfig } from "./ProjectConfig";

@@ -14,2 +14,38 @@ var __extends = (this && this.__extends) || (function () {

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { ConfigServiceBase } from "./ConfigServiceBase";

@@ -24,13 +60,32 @@ var LazyLoadConfigService = /** @class */ (function (_super) {

LazyLoadConfigService.prototype.getConfig = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
if (p && p.Timestamp + (this.cacheTimeToLiveSeconds * 1000) > new Date().getTime()) {
return new Promise(function (resolve) { return resolve(p); });
}
else {
return this.refreshLogicBaseAsync(p);
}
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
if (p && p.Timestamp + (this.cacheTimeToLiveSeconds * 1000) > new Date().getTime()) {
return [2 /*return*/, p];
}
else {
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
return [2 /*return*/];
}
});
});
};
LazyLoadConfigService.prototype.refreshConfigAsync = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
return this.refreshLogicBaseAsync(p);
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
});
});
};

@@ -37,0 +92,0 @@ return LazyLoadConfigService;

@@ -14,2 +14,38 @@ var __extends = (this && this.__extends) || (function () {

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
import { ConfigServiceBase } from "./ConfigServiceBase";

@@ -22,8 +58,26 @@ var ManualPollService = /** @class */ (function (_super) {

ManualPollService.prototype.getConfig = function () {
var _this = this;
return new Promise(function (resolve) { return resolve(_this.baseConfig.cache.get(_this.baseConfig.getCacheKey())); });
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, p];
}
});
});
};
ManualPollService.prototype.refreshConfigAsync = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
return this.refreshLogicBaseAsync(p);
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
});
});
};

@@ -30,0 +84,0 @@ return ManualPollService;

@@ -1,1 +0,1 @@

export default "4.4.6";
export default "4.5.0";

@@ -60,4 +60,4 @@ import { IConfigCatClient } from "./ConfigCatClient";

export interface ICache {
set(key: string, config: ProjectConfig): void;
get(key: string): ProjectConfig;
set(key: string, config: ProjectConfig): Promise<void> | void;
get(key: string): Promise<ProjectConfig> | ProjectConfig;
}

@@ -64,0 +64,0 @@ export { ProjectConfig } from "./ProjectConfig";

@@ -15,2 +15,38 @@ "use strict";

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -27,13 +63,32 @@ exports.LazyLoadConfigService = void 0;

LazyLoadConfigService.prototype.getConfig = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
if (p && p.Timestamp + (this.cacheTimeToLiveSeconds * 1000) > new Date().getTime()) {
return new Promise(function (resolve) { return resolve(p); });
}
else {
return this.refreshLogicBaseAsync(p);
}
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
if (p && p.Timestamp + (this.cacheTimeToLiveSeconds * 1000) > new Date().getTime()) {
return [2 /*return*/, p];
}
else {
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
return [2 /*return*/];
}
});
});
};
LazyLoadConfigService.prototype.refreshConfigAsync = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
return this.refreshLogicBaseAsync(p);
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
});
});
};

@@ -40,0 +95,0 @@ return LazyLoadConfigService;

@@ -15,2 +15,38 @@ "use strict";

})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -25,8 +61,26 @@ exports.ManualPollService = void 0;

ManualPollService.prototype.getConfig = function () {
var _this = this;
return new Promise(function (resolve) { return resolve(_this.baseConfig.cache.get(_this.baseConfig.getCacheKey())); });
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, p];
}
});
});
};
ManualPollService.prototype.refreshConfigAsync = function () {
var p = this.baseConfig.cache.get(this.baseConfig.getCacheKey());
return this.refreshLogicBaseAsync(p);
return __awaiter(this, void 0, void 0, function () {
var p;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.baseConfig.cache.get(this.baseConfig.getCacheKey())];
case 1:
p = _a.sent();
return [2 /*return*/, this.refreshLogicBaseAsync(p)];
}
});
});
};

@@ -33,0 +87,0 @@ return ManualPollService;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = "4.4.6";
exports.default = "4.5.0";
{
"name": "configcat-common",
"version": "4.4.6",
"version": "4.5.0",
"description": "ConfigCat is a configuration as a service that lets you manage your features and configurations without actually deploying new code.",

@@ -41,3 +41,3 @@ "main": "lib/index.js",

"mocha": "^8.1.3",
"moq.ts": "^6.4.0",
"moq.ts": "^7.4.1",
"nyc": "^15.1.0",

@@ -44,0 +44,0 @@ "source-map-support": "^0.5.19",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc