@splitsoftware/splitio-commons 1.16.1-rc.7 → 1.16.1-rc.8

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.
@@ -20,6 +20,8 @@ var murmur3_1 = require("../../utils/murmur3/murmur3");
20
20
  var murmur3_64_1 = require("../../utils/murmur3/murmur3_64");
21
21
  var constants_3 = require("../../utils/constants");
22
22
  function getDelay(parsedData, matchingKey) {
23
+ if (parsedData.h === 0)
24
+ return 0;
23
25
  var interval = parsedData.i || 60000;
24
26
  var seed = parsedData.s || 0;
25
27
  return (0, murmur3_1.hash)(matchingKey, seed) % interval;
@@ -17,6 +17,8 @@ import { hash } from '../../utils/murmur3/murmur3';
17
17
  import { hash64 } from '../../utils/murmur3/murmur3_64';
18
18
  import { TOKEN_REFRESH, AUTH_REJECTION, MY_LARGE_SEGMENT, MY_SEGMENT } from '../../utils/constants';
19
19
  export function getDelay(parsedData, matchingKey) {
20
+ if (parsedData.h === 0)
21
+ return 0;
20
22
  var interval = parsedData.i || 60000;
21
23
  var seed = parsedData.s || 0;
22
24
  return hash(matchingKey, seed) % interval;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.16.1-rc.7",
3
+ "version": "1.16.1-rc.8",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -22,7 +22,7 @@ function userKeyToQueryParam(userKey: string) {
22
22
  */
23
23
  export function splitApiFactory(
24
24
  settings: ISettings,
25
- platform: IPlatform,
25
+ platform: Pick<IPlatform, 'getOptions' | 'getFetch'>,
26
26
  telemetryTracker: ITelemetryTracker
27
27
  ): ISplitApi {
28
28
 
@@ -12,7 +12,7 @@ const messageNoFetch = 'Global fetch API is not available.';
12
12
  * @param settings SDK settings, used to access authorizationKey, logger instance and metadata (SDK version, ip and hostname) to set additional headers
13
13
  * @param platform object containing environment-specific dependencies
14
14
  */
15
- export function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }: IPlatform): ISplitHttpClient {
15
+ export function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }: Pick<IPlatform, 'getOptions' | 'getFetch'>): ISplitHttpClient {
16
16
 
17
17
  const { log, core: { authorizationKey }, version, runtime: { ip, hostname } } = settings;
18
18
  const options = getOptions && getOptions(settings);
@@ -43,7 +43,7 @@ export interface IMyLargeSegmentsUpdateData {
43
43
  d: string,
44
44
  u: UpdateStrategy,
45
45
  i?: number, // time interval in millis
46
- h?: number, // hash function. 0 for murmur3_32, 1 for murmur3_64
46
+ h?: number, // hash function
47
47
  s?: number, // seed for hash function
48
48
  }
49
49
 
@@ -36,7 +36,7 @@ export function MySegmentsUpdateWorker(mySegmentsSyncTask: IMySegmentsSyncTask,
36
36
 
37
37
  syncTask.then((result) => {
38
38
  if (!isHandlingEvent) return; // halt if `stop` has been called
39
- if (result !== false) {// Unlike `Splits|SegmentsUpdateWorker`, we cannot use `mySegmentsCache.getChangeNumber` since `/mySegments` endpoint doesn't provide this value.
39
+ if (result !== false) { // Unlike `Splits|SegmentsUpdateWorker`, we cannot use `mySegmentsCache.getChangeNumber` since `/mySegments` endpoint doesn't provide this value.
40
40
  if (_segmentsData) telemetryTracker.trackUpdatesFromSSE(updateType);
41
41
  currentChangeNumber = Math.max(currentChangeNumber, currentMaxChangeNumber); // use `currentMaxChangeNumber`, in case that `maxChangeNumber` was updated during fetch.
42
42
  }
@@ -23,6 +23,8 @@ import { TOKEN_REFRESH, AUTH_REJECTION, MY_LARGE_SEGMENT, MY_SEGMENT } from '../
23
23
  import { ISdkFactoryContextSync } from '../../sdkFactory/types';
24
24
 
25
25
  export function getDelay(parsedData: Pick<IMyLargeSegmentsUpdateData, 'i' | 'h' | 's'>, matchingKey: string) {
26
+ if (parsedData.h === 0) return 0;
27
+
26
28
  const interval = parsedData.i || 60000;
27
29
  const seed = parsedData.s || 0;
28
30
 
@@ -9,4 +9,4 @@ import { ITelemetryTracker } from '../trackers/types';
9
9
  * @param platform object containing environment-specific dependencies
10
10
  * @param telemetryTracker telemetry tracker
11
11
  */
12
- export declare function splitApiFactory(settings: ISettings, platform: IPlatform, telemetryTracker: ITelemetryTracker): ISplitApi;
12
+ export declare function splitApiFactory(settings: ISettings, platform: Pick<IPlatform, 'getOptions' | 'getFetch'>, telemetryTracker: ITelemetryTracker): ISplitApi;
@@ -7,4 +7,4 @@ import { IPlatform } from '../sdkFactory/types';
7
7
  * @param settings SDK settings, used to access authorizationKey, logger instance and metadata (SDK version, ip and hostname) to set additional headers
8
8
  * @param platform object containing environment-specific dependencies
9
9
  */
10
- export declare function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }: IPlatform): ISplitHttpClient;
10
+ export declare function splitHttpClientFactory(settings: ISettings, { getOptions, getFetch }: Pick<IPlatform, 'getOptions' | 'getFetch'>): ISplitHttpClient;