UNPKG

@unilogin/sdk

Version:

SDK is a JS library, that communicates with relayer. SDK allows managing contract, by creating basic contract-calling messages.

36 lines 1.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var commons_1 = require("@unilogin/commons"); var errors_1 = require("../utils/errors"); var Feature_1 = require("../models/Feature"); var FeatureFlagsService = /** @class */ (function () { function FeatureFlagsService() { this.feature = {}; } FeatureFlagsService.prototype.enableAll = function (featuresList) { var _this = this; featuresList.forEach(function (feature) { return _this.enable(feature); }); }; FeatureFlagsService.prototype.enable = function (feature) { if (typeof feature === 'string') { commons_1.ensure(this.isFeature(feature), errors_1.UnexpectedError, 'Invalid feature'); this.feature[commons_1.stringToEnumKey(Feature_1.Feature, feature)] = true; } else { this.feature[feature] = true; } }; FeatureFlagsService.prototype.isFeature = function (name) { return commons_1.getEnumKeys(Feature_1.Feature).includes(name); }; FeatureFlagsService.prototype.isEnabled = function (feature) { if (typeof feature === 'string') { commons_1.ensure(this.isFeature(feature), errors_1.UnexpectedError, 'Invalid feature'); return this.feature[commons_1.stringToEnumKey(Feature_1.Feature, feature)] || false; } return this.feature[feature] || false; }; return FeatureFlagsService; }()); exports.FeatureFlagsService = FeatureFlagsService; //# sourceMappingURL=FeatureFlagsService.js.map