bernie-core 982.772.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bernie-core might be problematic. Click here for more details.

Files changed (46) hide show
  1. package/dist/code-split.js +172 -0
  2. package/dist/components/get-providers.js +17 -0
  3. package/dist/components/index.js +14 -0
  4. package/dist/controller/get-controllers.js +25 -0
  5. package/dist/controller/index.js +18 -0
  6. package/dist/controller/match-route.js +34 -0
  7. package/dist/controller/result.js +21 -0
  8. package/dist/index.js +22 -0
  9. package/dist/logger/bernie-core-events.js +14 -0
  10. package/dist/logger/index.js +18 -0
  11. package/dist/logger/logger-provider.js +45 -0
  12. package/dist/logger/logger.js +44 -0
  13. package/dist/routing/close-dialog.js +19 -0
  14. package/dist/routing/dialog-route.js +69 -0
  15. package/dist/routing/index.js +24 -0
  16. package/dist/routing/matches-query.js +47 -0
  17. package/dist/routing/merge-query-string.js +29 -0
  18. package/dist/routing/query-route.js +90 -0
  19. package/dist/routing/query-switch.js +75 -0
  20. package/dist/routing/update-search.js +19 -0
  21. package/dist/source/bff-source.js +33 -0
  22. package/dist/source/index.js +16 -0
  23. package/dist/source/options/index.js +3 -0
  24. package/dist/source/spi/index.js +3 -0
  25. package/dist/store/common/analytics-store.js +250 -0
  26. package/dist/store/common/context-store.js +140 -0
  27. package/dist/store/common/experiment-store.js +64 -0
  28. package/dist/store/common/get-experiment-logger.js +80 -0
  29. package/dist/store/common/index.js +13 -0
  30. package/dist/store/common/page-store.js +102 -0
  31. package/dist/store/index.js +15 -0
  32. package/dist/store/spi/index.js +7 -0
  33. package/dist/store/spi/store-container.js +27 -0
  34. package/dist/store/spi/store.js +37 -0
  35. package/dist/util/autobind.js +44 -0
  36. package/dist/util/batch-queue.js +33 -0
  37. package/dist/util/brand-config.js +32 -0
  38. package/dist/util/debounce.js +19 -0
  39. package/dist/util/index.js +44 -0
  40. package/dist/util/merge.js +120 -0
  41. package/dist/util/not-serialize.js +43 -0
  42. package/dist/util/retry.js +21 -0
  43. package/dist/util/timeout-promise.js +17 -0
  44. package/dist/util/unique-batch-queue.js +40 -0
  45. package/index.js +28 -0
  46. package/package.json +22 -0
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
16
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
18
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
19
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.ExperimentStore = void 0;
23
+ var spi_1 = require("../spi");
24
+ var bernie_logger_1 = require("bernie-logger");
25
+ var mobx_1 = require("mobx");
26
+ /**
27
+ * Future home of Abacus related data. Currently just allows
28
+ * `.logExperiment` to be injected.
29
+ */
30
+ var ExperimentStore = /** @class */ (function (_super) {
31
+ __extends(ExperimentStore, _super);
32
+ /**
33
+ * @param experimentLogger The experiment logger
34
+ * @param logger The standard logger
35
+ */
36
+ function ExperimentStore(experimentContext, experimentLogger, logger) {
37
+ if (logger === void 0) { logger = bernie_logger_1.NOOP_LOGGER; }
38
+ var _this = _super.call(this, {}, logger) || this;
39
+ _this.experimentLogger = experimentLogger;
40
+ _this.exposures = experimentContext && experimentContext.exposures;
41
+ return _this;
42
+ }
43
+ /**
44
+ * Using the Abacus public API, log a batch of exposures.
45
+ * @param context The platform `Context`.
46
+ * @param pageData The `PageData` store containing `pageName`.
47
+ * @param exposure An Abacus exposure.
48
+ */
49
+ ExperimentStore.prototype.logExperiment = function (context, pageData, exposure) {
50
+ this.experimentLogger(context, pageData, exposure);
51
+ };
52
+ /**
53
+ * Does nothing for now.
54
+ */
55
+ ExperimentStore.prototype.hydrate = function (data) {
56
+ this.exposures = data.exposures;
57
+ };
58
+ __decorate([
59
+ mobx_1.observable
60
+ ], ExperimentStore.prototype, "exposures", void 0);
61
+ return ExperimentStore;
62
+ }(spi_1.Store));
63
+ exports.ExperimentStore = ExperimentStore;
64
+ //# sourceMappingURL=experiment-store.js.map
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getExperimentLogger = void 0;
15
+ var fetch = require("isomorphic-fetch");
16
+ var bernie_logger_1 = require("bernie-logger");
17
+ var __1 = require("../..");
18
+ var util_1 = require("../../util");
19
+ var TIMEOUT = 400;
20
+ /**
21
+ * Retrieves and configures an `ExperimentLogger`.
22
+ * @param options Configuration options, e.g. the base URL for server side calls
23
+ */
24
+ exports.getExperimentLogger = function (options) {
25
+ var baseUrl = options.baseUrl || '';
26
+ var logger = options.logger || bernie_logger_1.NOOP_LOGGER;
27
+ var loggedExperiments = new Set();
28
+ var queue;
29
+ var fetchWithTimeout = function (url, requestOptions) {
30
+ var fetchOptions = requestOptions;
31
+ if (typeof window === 'undefined' && typeof options.timeout === 'number') {
32
+ fetchOptions = __assign(__assign({}, fetchOptions), { timeout: options.timeout });
33
+ }
34
+ return fetch(url, __assign({}, fetchOptions));
35
+ };
36
+ /**
37
+ * Using the Abacus public API, log a batch of exposures.
38
+ * @param context The platform `Context`.
39
+ * @param pageData The `PageData` store containing `pageName`.
40
+ * @param exposure An Abacus exposure.
41
+ */
42
+ return function (context, pageData, exposure) {
43
+ var overrides = (context && context.debugContext && context.debugContext.abacusOverrides) || [];
44
+ if (queue === undefined) {
45
+ queue = new util_1.UniqueBatchQueue(TIMEOUT, function (e) { return e.name; }, function (exposures) {
46
+ fetchWithTimeout(baseUrl + "/api/bucketing/v1/evaluateExperimentsAndLog", {
47
+ body: JSON.stringify({
48
+ guid: context.deviceId,
49
+ tpid: context.site.tpid,
50
+ eapid: context.site.eapid,
51
+ pageName: pageData.pageName,
52
+ name: exposures.map(function (item) { return item.name; }),
53
+ overrides: overrides.map(function (override) { return override.id + "|0|" + override.bucket; }).join(':') || undefined
54
+ }),
55
+ headers: {
56
+ 'Content-Type': 'application/json',
57
+ Accept: 'application/json'
58
+ },
59
+ method: 'POST'
60
+ })
61
+ .then(function (res) { return res.json(); })
62
+ .then(function () {
63
+ exposures.forEach(function (e) {
64
+ loggedExperiments.add(e.name);
65
+ });
66
+ })
67
+ .catch(function (error) {
68
+ if (logger) {
69
+ logger.logEvent(__1.BERNIE_CORE_EVENTS.LOG_EXPERIMENT_ERROR, bernie_logger_1.getErrorString(error));
70
+ }
71
+ });
72
+ });
73
+ }
74
+ if (!loggedExperiments.has(exposure.name)) {
75
+ queue.add(exposure);
76
+ }
77
+ return true;
78
+ };
79
+ };
80
+ //# sourceMappingURL=get-experiment-logger.js.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var context_store_1 = require("./context-store");
4
+ Object.defineProperty(exports, "ContextStore", { enumerable: true, get: function () { return context_store_1.ContextStore; } });
5
+ var page_store_1 = require("./page-store");
6
+ Object.defineProperty(exports, "PageStore", { enumerable: true, get: function () { return page_store_1.PageStore; } });
7
+ var analytics_store_1 = require("./analytics-store");
8
+ Object.defineProperty(exports, "AnalyticsStore", { enumerable: true, get: function () { return analytics_store_1.AnalyticsStore; } });
9
+ var experiment_store_1 = require("./experiment-store");
10
+ Object.defineProperty(exports, "ExperimentStore", { enumerable: true, get: function () { return experiment_store_1.ExperimentStore; } });
11
+ var get_experiment_logger_1 = require("./get-experiment-logger");
12
+ Object.defineProperty(exports, "getExperimentLogger", { enumerable: true, get: function () { return get_experiment_logger_1.getExperimentLogger; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
16
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
17
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
18
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
19
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.PageStore = void 0;
23
+ var spi_1 = require("../spi");
24
+ var mobx_1 = require("mobx");
25
+ /**
26
+ * MobX store that houses page specific data, such
27
+ * as SEO information or the page title.
28
+ */
29
+ var PageStore = /** @class */ (function (_super) {
30
+ __extends(PageStore, _super);
31
+ /**
32
+ * Constructs a new page store.
33
+ * @param title The HTML page title.
34
+ * @param seo SEO specific information.
35
+ * @param scripts JS scripts to include on page.
36
+ */
37
+ function PageStore(pageData, logger) {
38
+ return _super.call(this, pageData, logger) || this;
39
+ }
40
+ /**
41
+ * {@inheritDoc}
42
+ */
43
+ PageStore.prototype.hydrate = function (data) {
44
+ Object.assign(this, data);
45
+ };
46
+ PageStore.prototype.fetch = function (meta, site, locale) {
47
+ var _this = this;
48
+ this.loading = true;
49
+ var metadata = PageStore.getMeta(meta, site, locale);
50
+ this.title = metadata.title;
51
+ this.meta = metadata;
52
+ return new Promise(function (resolve) {
53
+ _this.loading = false;
54
+ resolve(_this.toJSON());
55
+ });
56
+ };
57
+ PageStore.getMeta = function (meta, site, locale) {
58
+ var robots = meta.robots;
59
+ var localeSpecificMeta = PageStore.localeSpecificMeta(meta, site.id, locale);
60
+ var description = localeSpecificMeta.description;
61
+ var title = localeSpecificMeta.title;
62
+ var canonical = meta.canonical && meta.canonical(site);
63
+ return {
64
+ title: title,
65
+ robots: robots,
66
+ description: description,
67
+ canonical: canonical
68
+ };
69
+ };
70
+ PageStore.localeSpecificMeta = function (meta, siteId, locale) {
71
+ var siteMeta = meta[siteId];
72
+ if (siteMeta) {
73
+ var result = siteMeta[locale];
74
+ if (!result) {
75
+ result = siteMeta.default || {};
76
+ }
77
+ return result;
78
+ }
79
+ return {};
80
+ };
81
+ __decorate([
82
+ mobx_1.observable
83
+ ], PageStore.prototype, "title", void 0);
84
+ __decorate([
85
+ mobx_1.observable
86
+ ], PageStore.prototype, "navigationId", void 0);
87
+ __decorate([
88
+ mobx_1.observable
89
+ ], PageStore.prototype, "meta", void 0);
90
+ __decorate([
91
+ mobx_1.observable
92
+ ], PageStore.prototype, "seo", void 0);
93
+ __decorate([
94
+ mobx_1.action
95
+ ], PageStore.prototype, "hydrate", null);
96
+ __decorate([
97
+ mobx_1.action
98
+ ], PageStore.prototype, "fetch", null);
99
+ return PageStore;
100
+ }(spi_1.Store));
101
+ exports.PageStore = PageStore;
102
+ //# sourceMappingURL=page-store.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./spi"), exports);
14
+ __exportStar(require("./common"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var store_1 = require("./store");
4
+ Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return store_1.Store; } });
5
+ var store_container_1 = require("./store-container");
6
+ Object.defineProperty(exports, "StoreContainer", { enumerable: true, get: function () { return store_container_1.StoreContainer; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StoreContainer = void 0;
4
+ /**
5
+ * Wraps an object containing MobX stores to all for
6
+ * typed access.
7
+ */
8
+ var StoreContainer = /** @class */ (function () {
9
+ /**
10
+ * Constructs a new `StoreContainer` from an object
11
+ * containing stores.
12
+ * @param stores A `Stores` object.
13
+ */
14
+ function StoreContainer(stores) {
15
+ this.stores = stores;
16
+ }
17
+ /**
18
+ * Retrieves an individual store from the container.
19
+ * @param name The name of the store.
20
+ */
21
+ StoreContainer.prototype.get = function (name) {
22
+ return this.stores[name];
23
+ };
24
+ return StoreContainer;
25
+ }());
26
+ exports.StoreContainer = StoreContainer;
27
+ //# sourceMappingURL=store-container.js.map
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Store = void 0;
4
+ var mobx_1 = require("mobx");
5
+ var merge_1 = require("../../util/merge");
6
+ var Store = /** @class */ (function () {
7
+ /**
8
+ * Constructs a new `Store`.
9
+ * @param state Serialized state JSON.
10
+ * @param logger Bernie logger
11
+ */
12
+ function Store(state, logger) {
13
+ var _this = this;
14
+ if (state === void 0) { state = {}; }
15
+ var defaults = this.constructor['DEFAULTS'] || {};
16
+ mobx_1.runInAction(function () { return Object.assign(_this, defaults, state, { logger: logger }); });
17
+ }
18
+ /**
19
+ * Creates a basic JSON object from the store, excluding
20
+ * any fields provided in `excludedFields`.
21
+ */
22
+ Store.prototype.toJSON = function (ignoreAdditionalKeys) {
23
+ if (ignoreAdditionalKeys === void 0) { ignoreAdditionalKeys = []; }
24
+ if (!Array.isArray(ignoreAdditionalKeys)) {
25
+ ignoreAdditionalKeys = ignoreAdditionalKeys.constructor === String ? [ignoreAdditionalKeys] : [];
26
+ }
27
+ var regexIgnorePrivate = /^_.+/;
28
+ var simpleObject = mobx_1.toJS(this);
29
+ var ignoreKeys = Object.keys(simpleObject)
30
+ .filter(function (key) { return regexIgnorePrivate.test(key) || typeof simpleObject[key] === 'function'; })
31
+ .concat(ignoreAdditionalKeys, 'logger');
32
+ return merge_1.withoutKeys(ignoreKeys).merge({}, simpleObject);
33
+ };
34
+ return Store;
35
+ }());
36
+ exports.Store = Store;
37
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.autobind = void 0;
4
+ /*
5
+ * Code pulled from https://github.com/andreypopp/autobind-decorator/blob/master/src/index.js
6
+ *
7
+ * A decorator that automatically bind a class method to an instance of that class.
8
+ */
9
+ exports.autobind = function (target, key, descriptor) {
10
+ var fn = descriptor.value;
11
+ if (typeof fn !== 'function') {
12
+ throw new Error("@autobind decorator can only be applied to methods not: " + typeof fn);
13
+ }
14
+ // In IE11 calling Object.defineProperty has a side-effect of evaluating the
15
+ // getter for the property which is being replaced. This causes infinite
16
+ // recursion and an "Out of stack space" error.
17
+ var definingProperty = false;
18
+ return {
19
+ configurable: true,
20
+ get: function () {
21
+ if (definingProperty || this === target.prototype || this.hasOwnProperty(key) || typeof fn !== 'function') {
22
+ return fn;
23
+ }
24
+ var boundFn = fn.bind(this);
25
+ definingProperty = true;
26
+ Object.defineProperty(this, key, {
27
+ configurable: true,
28
+ get: function () {
29
+ return boundFn;
30
+ },
31
+ set: function (value) {
32
+ fn = value;
33
+ delete this[key];
34
+ }
35
+ });
36
+ definingProperty = false;
37
+ return boundFn;
38
+ },
39
+ set: function (value) {
40
+ fn = value;
41
+ }
42
+ };
43
+ };
44
+ //# sourceMappingURL=autobind.js.map
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BatchQueue = void 0;
4
+ /**
5
+ * A Queue which will process elements at intervals, only if the
6
+ * queue contains any elements.
7
+ */
8
+ var BatchQueue = /** @class */ (function () {
9
+ function BatchQueue(batchPeriod, handler) {
10
+ this.batchPeriod = batchPeriod;
11
+ this.handler = handler;
12
+ this.timeoutId = null;
13
+ this.items = [];
14
+ }
15
+ BatchQueue.prototype.add = function (item) {
16
+ var _this = this;
17
+ this.items.push(item);
18
+ if (this.timeoutId === null) {
19
+ this.timeoutId = setTimeout(function () {
20
+ _this.handleBatch();
21
+ }, this.batchPeriod);
22
+ }
23
+ };
24
+ BatchQueue.prototype.handleBatch = function () {
25
+ var batch = this.items;
26
+ this.timeoutId = null;
27
+ this.items = [];
28
+ this.handler(batch);
29
+ };
30
+ return BatchQueue;
31
+ }());
32
+ exports.BatchQueue = BatchQueue;
33
+ //# sourceMappingURL=batch-queue.js.map
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getBrandConfiguration = void 0;
15
+ var React = require("react");
16
+ exports.getBrandConfiguration = function (brandData) {
17
+ var iconSet = (brandData && brandData.iconData) || null;
18
+ var getIcon = function (name) {
19
+ if (!iconSet || (!iconSet.icons[name] && !iconSet.nameMapping[name])) {
20
+ return null;
21
+ }
22
+ var iconDataVal = iconSet.nameMapping[name] || name;
23
+ return function (props) {
24
+ var innerSvgProps = __assign({ dangerouslySetInnerHTML: { __html: iconSet.icons[iconDataVal].data } }, props);
25
+ return React.createElement("svg", __assign({}, innerSvgProps));
26
+ };
27
+ };
28
+ return {
29
+ getIcon: getIcon
30
+ };
31
+ };
32
+ //# sourceMappingURL=brand-config.js.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.debounce = void 0;
4
+ exports.debounce = function (func, delay, thisContext) {
5
+ var timer;
6
+ return function () {
7
+ var args = [];
8
+ for (var _i = 0; _i < arguments.length; _i++) {
9
+ args[_i] = arguments[_i];
10
+ }
11
+ var callback = function () {
12
+ timer = null;
13
+ func.apply(thisContext || null, args);
14
+ };
15
+ clearTimeout(timer);
16
+ timer = setTimeout(callback, delay);
17
+ };
18
+ };
19
+ //# sourceMappingURL=debounce.js.map
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.isValidDate = exports.parseDate = exports.autobind = exports.merge = void 0;
14
+ var merge = require("./merge");
15
+ exports.merge = merge;
16
+ var autobind_1 = require("./autobind");
17
+ Object.defineProperty(exports, "autobind", { enumerable: true, get: function () { return autobind_1.autobind; } });
18
+ var BernieL10n = require("bernie-l10n");
19
+ __exportStar(require("./timeout-promise"), exports);
20
+ __exportStar(require("./retry"), exports);
21
+ var batch_queue_1 = require("./batch-queue");
22
+ Object.defineProperty(exports, "BatchQueue", { enumerable: true, get: function () { return batch_queue_1.BatchQueue; } });
23
+ var unique_batch_queue_1 = require("./unique-batch-queue");
24
+ Object.defineProperty(exports, "UniqueBatchQueue", { enumerable: true, get: function () { return unique_batch_queue_1.UniqueBatchQueue; } });
25
+ var not_serialize_1 = require("./not-serialize");
26
+ Object.defineProperty(exports, "serializable", { enumerable: true, get: function () { return not_serialize_1.serializable; } });
27
+ Object.defineProperty(exports, "toJSON", { enumerable: true, get: function () { return not_serialize_1.toJSON; } });
28
+ var debounce_1 = require("./debounce");
29
+ Object.defineProperty(exports, "debounce", { enumerable: true, get: function () { return debounce_1.debounce; } });
30
+ __exportStar(require("./brand-config"), exports);
31
+ /***/
32
+ /*** previously from: ./parse-data ***/
33
+ /************************************/
34
+ /**
35
+ * @deprecated
36
+ * @see bernie-l10n for replacement
37
+ */
38
+ exports.parseDate = BernieL10n.parseDate;
39
+ /**
40
+ * @deprecated
41
+ * @see bernie-l10n for replacement
42
+ */
43
+ exports.isValidDate = BernieL10n.isValidDate;
44
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flattenFields = exports.withoutKeys = exports.withKeys = exports.allKeys = void 0;
4
+ /* tslint:disable */
5
+ function _mergeWithKeys(keys, objects) {
6
+ if (keys === void 0) { keys = []; }
7
+ if (objects.length === 0 || keys instanceof Array === false) {
8
+ return {};
9
+ }
10
+ // only use objects for the merge, ignore null which is also typeof object
11
+ objects = objects.filter(function (object) { return typeof object === 'object' && object; });
12
+ var base = {};
13
+ objects.forEach(function (object) {
14
+ keys.forEach(function (key) {
15
+ if (object.hasOwnProperty(key)) {
16
+ base[key] = object[key];
17
+ }
18
+ });
19
+ });
20
+ return base;
21
+ }
22
+ function _mergeWithoutKeys(keys, objects) {
23
+ if (keys === void 0) { keys = []; }
24
+ if (objects.length === 0 || keys instanceof Array === false) {
25
+ return {};
26
+ }
27
+ // only use objects for the merge, ignore null which is also typeof object
28
+ objects = objects.filter(function (object) { return typeof object === 'object' && object; });
29
+ // bracket notation lookup should be faster than repeated indexOf
30
+ var omittedKeys = keys.reduce(function (holder, key) {
31
+ holder[key] = true;
32
+ return holder;
33
+ }, {});
34
+ var base = {};
35
+ objects.forEach(function (object) {
36
+ Object.keys(object).forEach(function (key) {
37
+ if (omittedKeys[key] !== true) {
38
+ base[key] = object[key];
39
+ }
40
+ });
41
+ });
42
+ return base;
43
+ }
44
+ function _validKeys(keys) {
45
+ if (Array.isArray(keys)) {
46
+ // only use strings as keys, and make sure they're unique
47
+ return keys.filter(function (key, index, array) { return typeof key === 'string' && array.indexOf(key) === index && key.length > 0; });
48
+ }
49
+ return [];
50
+ }
51
+ function _flattenFields(refObject, delimiter, flattenArrays, newObject, prefix) {
52
+ if (delimiter === void 0) { delimiter = '_'; }
53
+ if (flattenArrays === void 0) { flattenArrays = false; }
54
+ if (newObject === void 0) { newObject = {}; }
55
+ var label;
56
+ var currentItem;
57
+ if (typeof delimiter !== 'string' || delimiter.length > 5) {
58
+ delimiter = '_';
59
+ }
60
+ flattenArrays = Boolean(flattenArrays);
61
+ if (typeof refObject === 'object' && refObject) {
62
+ Object.keys(refObject).forEach(function (key) {
63
+ label = prefix ? "" + prefix + delimiter + key : key;
64
+ currentItem = refObject[key];
65
+ if (currentItem !== null &&
66
+ ((typeof currentItem === 'object' && Object.keys(currentItem).length > 0) || Array.isArray(currentItem))) {
67
+ if (Array.isArray(currentItem) && flattenArrays === false) {
68
+ newObject[label] = currentItem.concat();
69
+ }
70
+ else {
71
+ _flattenFields(currentItem, delimiter, flattenArrays, newObject, label);
72
+ }
73
+ }
74
+ else {
75
+ newObject[label] = currentItem;
76
+ }
77
+ });
78
+ }
79
+ return newObject;
80
+ }
81
+ // public exports
82
+ function allKeys() {
83
+ return withoutKeys([]);
84
+ }
85
+ exports.allKeys = allKeys;
86
+ function withKeys(keys) {
87
+ if (keys === void 0) { keys = []; }
88
+ keys = _validKeys(keys);
89
+ return {
90
+ merge: function () {
91
+ var objects = [];
92
+ for (var _i = 0; _i < arguments.length; _i++) {
93
+ objects[_i] = arguments[_i];
94
+ }
95
+ return _mergeWithKeys(keys, objects);
96
+ }
97
+ };
98
+ }
99
+ exports.withKeys = withKeys;
100
+ function withoutKeys(keys) {
101
+ if (keys === void 0) { keys = []; }
102
+ keys = _validKeys(keys);
103
+ return {
104
+ merge: function () {
105
+ var objects = [];
106
+ for (var _i = 0; _i < arguments.length; _i++) {
107
+ objects[_i] = arguments[_i];
108
+ }
109
+ return _mergeWithoutKeys(keys, objects);
110
+ }
111
+ };
112
+ }
113
+ exports.withoutKeys = withoutKeys;
114
+ function flattenFields(refObject, delimiter, flattenArrays) {
115
+ if (delimiter === void 0) { delimiter = '_'; }
116
+ if (flattenArrays === void 0) { flattenArrays = false; }
117
+ return _flattenFields(refObject, delimiter, flattenArrays, {}, '');
118
+ }
119
+ exports.flattenFields = flattenFields;
120
+ //# sourceMappingURL=merge.js.map