@splitsoftware/splitio-browserjs
Version:
Split SDK for JavaScript on Browser
29 lines (28 loc) • 1.5 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.SplitFactory = void 0;
var full_1 = require("../settings/full");
var getModules_1 = require("../platform/getModules");
var index_1 = require("@splitsoftware/splitio-commons/cjs/sdkFactory/index");
var getFetchFull_1 = require("../platform/getFetchFull");
var getEventSource_1 = require("../platform/getEventSource");
var MinEvents_1 = require("@splitsoftware/splitio-commons/cjs/utils/MinEvents");
var browser_1 = require("@splitsoftware/splitio-commons/cjs/utils/timeTracker/now/browser");
var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSource_1.getEventSource, EventEmitter: MinEvents_1.EventEmitter, now: browser_1.now };
/**
* SplitFactory with pluggable modules for Browser.
* It includes a `fetch` polyfill out-of-the-box.
*
* @param config - configuration object used to instantiate the SDK
* @param __updateModules - optional function that lets redefine internal SDK modules. Use with
* caution since, unlike `config`, this param is not validated neither considered part of the public API.
* @throws Will throw an error if the provided config is invalid.
*/
function SplitFactory(config, __updateModules) {
var settings = (0, full_1.settingsFactory)(config);
var modules = (0, getModules_1.getModules)(settings, platform);
if (__updateModules)
__updateModules(modules);
return (0, index_1.sdkFactory)(modules);
}
exports.SplitFactory = SplitFactory;
;