@splitsoftware/splitio 10.17.3-rc.2 → 10.17.3-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/es/factory/browser.js +41 -33
  2. package/es/factory/node.js +41 -36
  3. package/es/index.js +16 -1
  4. package/es/platform/EventEmitter.js +300 -326
  5. package/es/platform/browser.js +4 -4
  6. package/es/platform/getEventSource/browser.js +2 -2
  7. package/es/platform/getEventSource/node.js +13 -12
  8. package/es/platform/getFetch/browser.js +2 -2
  9. package/es/platform/getFetch/node.js +13 -13
  10. package/es/platform/node.js +5 -5
  11. package/es/platform/request/options/node.js +6 -21
  12. package/es/settings/browser.js +9 -9
  13. package/es/settings/defaults/browser.js +13 -13
  14. package/es/settings/defaults/node.js +22 -22
  15. package/es/settings/defaults/version.js +1 -1
  16. package/es/settings/integrations/browser.js +3 -3
  17. package/es/settings/node.js +9 -12
  18. package/es/settings/storage/browser.js +31 -59
  19. package/es/settings/storage/node.js +62 -91
  20. package/es/umd.js +3 -3
  21. package/lib/factory/browser.js +61 -70
  22. package/lib/factory/node.js +59 -69
  23. package/lib/index.js +16 -4
  24. package/lib/platform/EventEmitter.js +303 -330
  25. package/lib/platform/browser.js +10 -18
  26. package/lib/platform/getEventSource/browser.js +5 -6
  27. package/lib/platform/getEventSource/node.js +18 -19
  28. package/lib/platform/getFetch/browser.js +7 -10
  29. package/lib/platform/getFetch/node.js +17 -18
  30. package/lib/platform/node.js +13 -23
  31. package/lib/platform/request/options/node.js +12 -31
  32. package/lib/settings/browser.js +18 -26
  33. package/lib/settings/defaults/browser.js +15 -19
  34. package/lib/settings/defaults/node.js +24 -28
  35. package/lib/settings/defaults/version.js +2 -4
  36. package/lib/settings/integrations/browser.js +7 -12
  37. package/lib/settings/node.js +17 -29
  38. package/lib/settings/storage/browser.js +36 -68
  39. package/lib/settings/storage/node.js +66 -97
  40. package/lib/umd.js +3 -8
  41. package/package.json +23 -28
  42. package/src/factory/browser.js +10 -1
  43. package/src/factory/node.js +10 -1
  44. package/src/index.js +16 -0
  45. package/src/platform/request/options/node.js +0 -15
  46. package/src/settings/.DS_Store +0 -0
  47. package/src/settings/browser.js +2 -0
  48. package/src/settings/defaults/version.js +1 -1
  49. package/src/settings/integrations/browser.js +2 -2
  50. package/src/settings/node.js +2 -3
  51. package/src/settings/storage/browser.js +0 -16
  52. package/src/settings/storage/node.js +0 -15
  53. package/es/settings/integrations/node.js +0 -5
  54. package/es/settings/runtime/node.js +0 -35
  55. package/lib/settings/integrations/node.js +0 -12
  56. package/lib/settings/runtime/node.js +0 -45
  57. package/src/settings/integrations/node.js +0 -5
  58. package/src/settings/runtime/node.js +0 -37
@@ -3,8 +3,8 @@ import { getFetch } from '../platform/getFetch/browser';
3
3
  import { getEventSource } from '../platform/getEventSource/browser';
4
4
  import { BrowserSignalListener } from '@splitsoftware/splitio-commons/esm/listeners/browser';
5
5
  export var platform = {
6
- getFetch: getFetch,
7
- getEventSource: getEventSource,
8
- EventEmitter: EventEmitter
6
+ getFetch: getFetch,
7
+ getEventSource: getEventSource,
8
+ EventEmitter: EventEmitter
9
9
  };
10
- export var SignalListener = BrowserSignalListener;
10
+ export var SignalListener = BrowserSignalListener;
@@ -1,3 +1,3 @@
1
1
  export function getEventSource() {
2
- return typeof EventSource === 'function' ? EventSource : undefined;
3
- }
2
+ return typeof EventSource === 'function' ? EventSource : undefined;
3
+ }
@@ -1,18 +1,19 @@
1
1
  var __isCustom = false;
2
- var __eventSource = undefined; // This function is only exposed for testing purposes.
3
-
2
+ var __eventSource = undefined;
3
+ // This function is only exposed for testing purposes.
4
4
  export function __setEventSource(eventSource) {
5
- __eventSource = eventSource;
6
- __isCustom = true;
5
+ __eventSource = eventSource;
6
+ __isCustom = true;
7
7
  }
8
8
  export function __restore() {
9
- __isCustom = false;
9
+ __isCustom = false;
10
10
  }
11
11
  export function getEventSource() {
12
- // returns EventSource at `eventsource` package. If not available, return global EventSource or undefined
13
- try {
14
- return __isCustom ? __eventSource : require('eventsource');
15
- } catch (error) {
16
- return typeof EventSource === 'function' ? EventSource : undefined;
17
- }
18
- }
12
+ // returns EventSource at `eventsource` package. If not available, return global EventSource or undefined
13
+ try {
14
+ return __isCustom ? __eventSource : require('eventsource');
15
+ }
16
+ catch (error) {
17
+ return typeof EventSource === 'function' ? EventSource : undefined;
18
+ }
19
+ }
@@ -1,4 +1,4 @@
1
1
  import unfetch from 'unfetch';
2
2
  export function getFetch() {
3
- return typeof fetch === 'function' ? fetch : unfetch;
4
- }
3
+ return typeof fetch === 'function' ? fetch : unfetch;
4
+ }
@@ -1,18 +1,18 @@
1
1
  var nodeFetch;
2
-
3
2
  try {
4
- nodeFetch = require('node-fetch'); // Handle node-fetch issue https://github.com/node-fetch/node-fetch/issues/1037
5
-
6
- if (typeof nodeFetch !== 'function') nodeFetch = nodeFetch.default;
7
- } catch (error) {
8
- // Try to access global fetch if `node-fetch` package couldn't be imported (e.g., not in a Node environment)
9
- nodeFetch = typeof fetch === 'function' ? fetch : undefined;
10
- } // This function is only exposed for testing purposes.
11
-
12
-
3
+ nodeFetch = require('node-fetch');
4
+ // Handle node-fetch issue https://github.com/node-fetch/node-fetch/issues/1037
5
+ if (typeof nodeFetch !== 'function')
6
+ nodeFetch = nodeFetch.default;
7
+ }
8
+ catch (error) {
9
+ // Try to access global fetch if `node-fetch` package couldn't be imported (e.g., not in a Node environment)
10
+ nodeFetch = typeof fetch === 'function' ? fetch : undefined;
11
+ }
12
+ // This function is only exposed for testing purposes.
13
13
  export function __setFetch(fetch) {
14
- nodeFetch = fetch;
14
+ nodeFetch = fetch;
15
15
  }
16
16
  export function getFetch() {
17
- return nodeFetch;
18
- }
17
+ return nodeFetch;
18
+ }
@@ -4,9 +4,9 @@ import { getEventSource } from '../platform/getEventSource/node';
4
4
  import { getOptions } from '../platform/request/options/node';
5
5
  import { NodeSignalListener } from '@splitsoftware/splitio-commons/esm/listeners/node';
6
6
  export var platform = {
7
- getOptions: getOptions,
8
- getFetch: getFetch,
9
- getEventSource: getEventSource,
10
- EventEmitter: EventEmitter
7
+ getOptions: getOptions,
8
+ getFetch: getFetch,
9
+ getEventSource: getEventSource,
10
+ EventEmitter: EventEmitter
11
11
  };
12
- export var SignalListener = NodeSignalListener;
12
+ export var SignalListener = NodeSignalListener;
@@ -1,28 +1,13 @@
1
- /**
2
- Copyright 2022 Split Software
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- **/
16
1
  // @TODO
17
2
  // 1- handle multiple protocols automatically
18
3
  // 2- destroy it once the sdk is destroyed
19
4
  import https from 'https';
20
5
  var agent = new https.Agent({
21
- keepAlive: true,
22
- keepAliveMsecs: 1500
6
+ keepAlive: true,
7
+ keepAliveMsecs: 1500
23
8
  });
24
9
  export function getOptions() {
25
- return {
26
- agent: agent
27
- };
28
- }
10
+ return {
11
+ agent: agent
12
+ };
13
+ }
@@ -1,18 +1,18 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
2
2
  import { defaults } from './defaults/browser';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime/browser';
3
4
  import { validateStorage } from './storage/browser';
4
5
  import { validateIntegrations } from './integrations/browser';
5
6
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
6
7
  import { LocalhostFromObject } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromObject';
7
8
  var params = {
8
- defaults: defaults,
9
- storage: validateStorage,
10
- integrations: validateIntegrations,
11
- logger: validateLogger,
12
- localhost: function localhost() {
13
- return LocalhostFromObject();
14
- }
9
+ defaults: defaults,
10
+ runtime: validateRuntime,
11
+ storage: validateStorage,
12
+ integrations: validateIntegrations,
13
+ logger: validateLogger,
14
+ localhost: function () { return LocalhostFromObject(); },
15
15
  };
16
16
  export function settingsFactory(config) {
17
- return settingsValidation(config, params);
18
- }
17
+ return settingsValidation(config, params);
18
+ }
@@ -1,15 +1,15 @@
1
1
  import { packageVersion } from './version';
2
2
  export var defaults = {
3
- startup: {
4
- // Stress the request time used while starting up the SDK.
5
- requestTimeoutBeforeReady: 5,
6
- // How many quick retries we will do while starting up the SDK.
7
- retriesOnFailureBeforeReady: 1,
8
- // Maximum amount of time used before notifies me a timeout.
9
- readyTimeout: 10,
10
- // Amount of time we will wait before the first push of events.
11
- eventsFirstPushWindow: 10
12
- },
13
- // Instance version.
14
- version: "javascript-" + packageVersion
15
- };
3
+ startup: {
4
+ // Stress the request time used while starting up the SDK.
5
+ requestTimeoutBeforeReady: 5,
6
+ // How many quick retries we will do while starting up the SDK.
7
+ retriesOnFailureBeforeReady: 1,
8
+ // Maximum amount of time used before notifies me a timeout.
9
+ readyTimeout: 10,
10
+ // Amount of time we will wait before the first push of events.
11
+ eventsFirstPushWindow: 10
12
+ },
13
+ // Instance version.
14
+ version: "javascript-" + packageVersion,
15
+ };
@@ -1,24 +1,24 @@
1
1
  import { packageVersion } from './version';
2
2
  export var defaults = {
3
- core: {
4
- // Default is true.
5
- IPAddressesEnabled: true
6
- },
7
- startup: {
8
- // Stress the request time used while starting up the SDK.
9
- requestTimeoutBeforeReady: 15,
10
- // How many quick retries we will do while starting up the SDK.
11
- retriesOnFailureBeforeReady: 1,
12
- // Maximum amount of time used before notifies me a timeout.
13
- readyTimeout: 15,
14
- // Don't wait a specific time for first flush on Node, no page load here.
15
- eventsFirstPushWindow: 0
16
- },
17
- scheduler: {
18
- featuresRefreshRate: 5,
19
- impressionsRefreshRate: 300
20
- },
21
- features: '.split',
22
- // Instance version.
23
- version: "nodejs-" + packageVersion
24
- };
3
+ core: {
4
+ // Default is true.
5
+ IPAddressesEnabled: true
6
+ },
7
+ startup: {
8
+ // Stress the request time used while starting up the SDK.
9
+ requestTimeoutBeforeReady: 15,
10
+ // How many quick retries we will do while starting up the SDK.
11
+ retriesOnFailureBeforeReady: 1,
12
+ // Maximum amount of time used before notifies me a timeout.
13
+ readyTimeout: 15,
14
+ // Don't wait a specific time for first flush on Node, no page load here.
15
+ eventsFirstPushWindow: 0
16
+ },
17
+ scheduler: {
18
+ featuresRefreshRate: 5,
19
+ impressionsRefreshRate: 300
20
+ },
21
+ features: '.split',
22
+ // Instance version.
23
+ version: "nodejs-" + packageVersion,
24
+ };
@@ -1 +1 @@
1
- export var packageVersion = '10.17.3-rc.2';
1
+ export var packageVersion = '10.17.3-rc.3';
@@ -1,5 +1,5 @@
1
1
  import { GOOGLE_ANALYTICS_TO_SPLIT, SPLIT_TO_GOOGLE_ANALYTICS } from '@splitsoftware/splitio-commons/esm/utils/constants/browser';
2
2
  import { validateConfigurableIntegrations } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/integrations/configurable';
3
- export var validateIntegrations = function validateIntegrations(settings) {
4
- return validateConfigurableIntegrations(settings, [GOOGLE_ANALYTICS_TO_SPLIT, SPLIT_TO_GOOGLE_ANALYTICS]);
5
- };
3
+ export function validateIntegrations(settings) {
4
+ return validateConfigurableIntegrations(settings, [GOOGLE_ANALYTICS_TO_SPLIT, SPLIT_TO_GOOGLE_ANALYTICS]);
5
+ }
@@ -1,20 +1,17 @@
1
1
  import { settingsValidation } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation';
2
2
  import { defaults } from './defaults/node';
3
- import { validateRuntime } from './runtime/node';
3
+ import { validateRuntime } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/runtime/node';
4
4
  import { validateStorage } from './storage/node';
5
- import { validateIntegrations } from './integrations/node';
6
5
  import { validateLogger } from '@splitsoftware/splitio-commons/esm/utils/settingsValidation/logger/builtinLogger';
7
6
  import { LocalhostFromFile } from '@splitsoftware/splitio-commons/esm/sync/offline/LocalhostFromFile';
8
7
  var params = {
9
- defaults: defaults,
10
- runtime: validateRuntime,
11
- storage: validateStorage,
12
- integrations: validateIntegrations,
13
- logger: validateLogger,
14
- localhost: function localhost() {
15
- return LocalhostFromFile();
16
- }
8
+ defaults: defaults,
9
+ runtime: validateRuntime,
10
+ storage: validateStorage,
11
+ logger: validateLogger,
12
+ localhost: function () { return LocalhostFromFile(); },
13
+ // For now, Node SDK ignores settings.integrations, so no integration validator is passed
17
14
  };
18
15
  export function settingsFactory(config) {
19
- return settingsValidation(config, params);
20
- }
16
+ return settingsValidation(config, params);
17
+ }
@@ -1,63 +1,35 @@
1
- /**
2
- Copyright 2022 Split Software
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- **/
16
1
  import { isLocalStorageAvailable } from '@splitsoftware/splitio-commons/esm/utils/env/isLocalStorageAvailable';
17
2
  import { LOCALHOST_MODE, STORAGE_MEMORY } from '@splitsoftware/splitio-commons/esm/utils/constants';
18
3
  var STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
19
4
  export function validateStorage(settings) {
20
- var log = settings.log,
21
- mode = settings.mode,
22
- _settings$storage = settings.storage;
23
- _settings$storage = _settings$storage === void 0 ? {
24
- type: STORAGE_MEMORY
25
- } : _settings$storage;
26
- var type = _settings$storage.type,
27
- _settings$storage$opt = _settings$storage.options,
28
- options = _settings$storage$opt === void 0 ? {} : _settings$storage$opt,
29
- prefix = _settings$storage.prefix;
30
-
31
- var __originalType;
32
-
33
- if (prefix) {
34
- prefix += '.SPLITIO';
35
- } else {
36
- prefix = 'SPLITIO';
37
- }
38
-
39
- var fallbackToMemory = function fallbackToMemory() {
40
- __originalType = type;
41
- type = STORAGE_MEMORY;
42
- }; // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
43
- // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
44
-
45
-
46
- if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
47
- fallbackToMemory();
48
- } // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
49
- // it's not available, fallback into MEMORY
50
-
51
-
52
- if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE || type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
53
- fallbackToMemory();
54
- log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
55
- }
56
-
57
- return {
58
- type: type,
59
- options: options,
60
- prefix: prefix,
61
- __originalType: __originalType
62
- };
63
- }
5
+ var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
6
+ var __originalType;
7
+ if (prefix) {
8
+ prefix += '.SPLITIO';
9
+ }
10
+ else {
11
+ prefix = 'SPLITIO';
12
+ }
13
+ var fallbackToMemory = function () {
14
+ __originalType = type;
15
+ type = STORAGE_MEMORY;
16
+ };
17
+ // In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
18
+ // ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
19
+ if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
20
+ fallbackToMemory();
21
+ }
22
+ // If an invalid storage type is provided OR we want to use LOCALSTORAGE and
23
+ // it's not available, fallback into MEMORY
24
+ if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
25
+ type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
26
+ fallbackToMemory();
27
+ log.error('Invalid or unavailable storage. Fallbacking into MEMORY storage');
28
+ }
29
+ return {
30
+ type: type,
31
+ options: options,
32
+ prefix: prefix,
33
+ __originalType: __originalType
34
+ };
35
+ }
@@ -1,95 +1,66 @@
1
- /**
2
- Copyright 2022 Split Software
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- **/
16
1
  import { LOCALHOST_MODE, STORAGE_MEMORY, STORAGE_REDIS, CONSUMER_MODE, STANDALONE_MODE } from '@splitsoftware/splitio-commons/esm/utils/constants';
17
2
  export function validateStorage(settings) {
18
- var log = settings.log,
19
- mode = settings.mode,
20
- _settings$storage = settings.storage;
21
- _settings$storage = _settings$storage === void 0 ? {
22
- type: STORAGE_MEMORY
23
- } : _settings$storage;
24
- var type = _settings$storage.type,
25
- _settings$storage$opt = _settings$storage.options,
26
- options = _settings$storage$opt === void 0 ? {} : _settings$storage$opt,
27
- prefix = _settings$storage.prefix;
28
-
29
- if (prefix) {
30
- prefix += '.SPLITIO';
31
- } else {
32
- prefix = 'SPLITIO';
33
- } // We can have MEMORY, REDIS or an invalid storage type
34
-
35
-
36
- switch (type) {
37
- case STORAGE_REDIS:
38
- {
39
- // If passing REDIS storage in localhost or standalone mode, we log an error and fallback to MEMORY storage
40
- if (mode === STANDALONE_MODE || mode === LOCALHOST_MODE) {
41
- log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallbacking into default MEMORY storage.');
42
- return {
43
- type: STORAGE_MEMORY,
44
- prefix: prefix
45
- };
3
+ var log = settings.log, mode = settings.mode, _a = settings.storage, _b = _a === void 0 ? { type: STORAGE_MEMORY } : _a, type = _b.type, _c = _b.options, options = _c === void 0 ? {} : _c, prefix = _b.prefix;
4
+ if (prefix) {
5
+ prefix += '.SPLITIO';
6
+ }
7
+ else {
8
+ prefix = 'SPLITIO';
9
+ }
10
+ // We can have MEMORY, REDIS or an invalid storage type
11
+ switch (type) {
12
+ case STORAGE_REDIS: {
13
+ // If passing REDIS storage in localhost or standalone mode, we log an error and fallback to MEMORY storage
14
+ if (mode === STANDALONE_MODE || mode === LOCALHOST_MODE) {
15
+ log.error('The provided REDIS storage is invalid for this mode. It requires consumer mode. Fallbacking into default MEMORY storage.');
16
+ return {
17
+ type: STORAGE_MEMORY,
18
+ prefix: prefix
19
+ };
20
+ }
21
+ var host = options.host, port = options.port, db = options.db, pass = options.pass, url = options.url, connectionTimeout = options.connectionTimeout, operationTimeout = options.operationTimeout;
22
+ if (process.env.REDIS_HOST)
23
+ host = process.env.REDIS_HOST;
24
+ if (process.env.REDIS_PORT)
25
+ port = process.env.REDIS_PORT;
26
+ if (process.env.REDIS_DB)
27
+ db = process.env.REDIS_DB;
28
+ if (process.env.REDIS_PASS)
29
+ pass = process.env.REDIS_PASS;
30
+ if (process.env.REDIS_URL)
31
+ url = process.env.REDIS_URL;
32
+ var newOpts = {
33
+ connectionTimeout: connectionTimeout,
34
+ operationTimeout: operationTimeout
35
+ };
36
+ if (url) {
37
+ newOpts.url = url;
38
+ }
39
+ else {
40
+ newOpts.host = host;
41
+ newOpts.port = port;
42
+ newOpts.db = db;
43
+ newOpts.pass = pass;
44
+ }
45
+ return {
46
+ type: type,
47
+ prefix: prefix,
48
+ options: newOpts
49
+ };
46
50
  }
47
-
48
- var host = options.host,
49
- port = options.port,
50
- db = options.db,
51
- pass = options.pass,
52
- url = options.url,
53
- connectionTimeout = options.connectionTimeout,
54
- operationTimeout = options.operationTimeout;
55
- if (process.env.REDIS_HOST) host = process.env.REDIS_HOST;
56
- if (process.env.REDIS_PORT) port = process.env.REDIS_PORT;
57
- if (process.env.REDIS_DB) db = process.env.REDIS_DB;
58
- if (process.env.REDIS_PASS) pass = process.env.REDIS_PASS;
59
- if (process.env.REDIS_URL) url = process.env.REDIS_URL;
60
- var newOpts = {
61
- connectionTimeout: connectionTimeout,
62
- operationTimeout: operationTimeout
63
- };
64
-
65
- if (url) {
66
- newOpts.url = url;
67
- } else {
68
- newOpts.host = host;
69
- newOpts.port = port;
70
- newOpts.db = db;
71
- newOpts.pass = pass;
51
+ // For now, we don't have modifiers or settings for MEMORY in NodeJS
52
+ case STORAGE_MEMORY:
53
+ default: {
54
+ // If passing MEMORY storage in consumer mode, throw an error (no way to fallback to REDIS storage)
55
+ if (mode === CONSUMER_MODE)
56
+ throw new Error('A REDIS storage is required on consumer mode');
57
+ // If passing an invalid storage type, log an error
58
+ if (type !== STORAGE_MEMORY)
59
+ log.error("The provided '" + type + "' storage type is invalid. Fallbacking into default MEMORY storage.");
60
+ return {
61
+ type: STORAGE_MEMORY,
62
+ prefix: prefix
63
+ };
72
64
  }
73
-
74
- return {
75
- type: type,
76
- prefix: prefix,
77
- options: newOpts
78
- };
79
- }
80
- // For now, we don't have modifiers or settings for MEMORY in NodeJS
81
-
82
- case STORAGE_MEMORY:
83
- default:
84
- {
85
- // If passing MEMORY storage in consumer mode, throw an error (no way to fallback to REDIS storage)
86
- if (mode === CONSUMER_MODE) throw new Error('A REDIS storage is required on consumer mode'); // If passing an invalid storage type, log an error
87
-
88
- if (type !== STORAGE_MEMORY) log.error("The provided '" + type + "' storage type is invalid. Fallbacking into default MEMORY storage.");
89
- return {
90
- type: STORAGE_MEMORY,
91
- prefix: prefix
92
- };
93
- }
94
- }
95
- }
65
+ }
66
+ }
package/es/umd.js CHANGED
@@ -1,3 +1,3 @@
1
- import { SplitFactory } from './index'; // eslint-disable-next-line import/no-default-export
2
-
3
- export default SplitFactory;
1
+ import { SplitFactory } from './index';
2
+ // eslint-disable-next-line import/no-default-export
3
+ export default SplitFactory;