@splitsoftware/splitio-commons 1.2.1-rc.0 → 1.2.1-rc.11

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 (316) hide show
  1. package/cjs/evaluator/Engine.js +6 -6
  2. package/cjs/evaluator/combiners/and.js +1 -1
  3. package/cjs/evaluator/combiners/ifelseif.js +2 -2
  4. package/cjs/evaluator/condition/engineUtils.js +2 -2
  5. package/cjs/evaluator/condition/index.js +4 -4
  6. package/cjs/evaluator/index.js +5 -5
  7. package/cjs/evaluator/matchers/cont_all.js +1 -1
  8. package/cjs/evaluator/matchers/cont_any.js +1 -1
  9. package/cjs/evaluator/matchers/cont_str.js +1 -1
  10. package/cjs/evaluator/matchers/dependency.js +1 -1
  11. package/cjs/evaluator/matchers/eq_set.js +1 -1
  12. package/cjs/evaluator/matchers/ew.js +3 -3
  13. package/cjs/evaluator/matchers/part_of.js +1 -1
  14. package/cjs/evaluator/matchers/segment.js +1 -1
  15. package/cjs/evaluator/matchers/sw.js +1 -1
  16. package/cjs/evaluator/matchers/whitelist.js +1 -1
  17. package/cjs/evaluator/matchersTransform/index.js +12 -12
  18. package/cjs/evaluator/parser/index.js +6 -6
  19. package/cjs/evaluator/treatments/index.js +1 -1
  20. package/cjs/evaluator/value/index.js +1 -1
  21. package/cjs/evaluator/value/sanitize.js +4 -4
  22. package/cjs/integrations/browser.js +3 -3
  23. package/cjs/integrations/ga/GaToSplit.js +14 -14
  24. package/cjs/integrations/ga/GoogleAnalyticsToSplit.js +5 -3
  25. package/cjs/integrations/ga/SplitToGa.js +1 -1
  26. package/cjs/integrations/ga/SplitToGoogleAnalytics.js +4 -2
  27. package/cjs/listeners/browser.js +15 -11
  28. package/cjs/listeners/node.js +1 -1
  29. package/cjs/logger/constants.js +9 -3
  30. package/cjs/logger/index.js +2 -2
  31. package/cjs/logger/messages/debug.js +4 -4
  32. package/cjs/logger/messages/error.js +5 -4
  33. package/cjs/logger/messages/info.js +8 -5
  34. package/cjs/logger/messages/warn.js +1 -1
  35. package/cjs/logger/sdkLogger.js +1 -1
  36. package/cjs/readiness/readinessManager.js +2 -2
  37. package/cjs/readiness/sdkReadinessManager.js +4 -4
  38. package/cjs/sdkClient/client.js +12 -11
  39. package/cjs/sdkClient/clientAttributesDecoration.js +4 -4
  40. package/cjs/sdkClient/clientCS.js +3 -3
  41. package/cjs/sdkClient/clientInputValidation.js +20 -22
  42. package/cjs/sdkClient/sdkClient.js +3 -6
  43. package/cjs/sdkClient/sdkClientMethod.js +1 -1
  44. package/cjs/sdkClient/sdkClientMethodCS.js +6 -10
  45. package/cjs/sdkClient/sdkClientMethodCSWithTT.js +7 -15
  46. package/cjs/sdkFactory/index.js +14 -12
  47. package/cjs/sdkFactory/userConsentProps.js +40 -0
  48. package/cjs/sdkManager/index.js +11 -11
  49. package/cjs/services/splitApi.js +3 -2
  50. package/cjs/services/splitHttpClient.js +2 -2
  51. package/cjs/storages/KeyBuilder.js +2 -6
  52. package/cjs/storages/KeyBuilderCS.js +13 -3
  53. package/cjs/storages/KeyBuilderSS.js +1 -1
  54. package/cjs/storages/findLatencyIndex.js +1 -1
  55. package/cjs/storages/inLocalStorage/MySegmentsCacheInLocal.js +24 -4
  56. package/cjs/storages/inLocalStorage/SplitsCacheInLocal.js +12 -12
  57. package/cjs/storages/inLocalStorage/index.js +4 -4
  58. package/cjs/storages/inMemory/AttributesCacheInMemory.js +1 -1
  59. package/cjs/storages/inMemory/ImpressionCountsCacheInMemory.js +1 -1
  60. package/cjs/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
  61. package/cjs/storages/inMemory/InMemoryStorage.js +1 -1
  62. package/cjs/storages/inMemory/InMemoryStorageCS.js +1 -1
  63. package/cjs/storages/inMemory/LatenciesCacheInMemory.js +1 -1
  64. package/cjs/storages/inMemory/MySegmentsCacheInMemory.js +1 -1
  65. package/cjs/storages/inMemory/SegmentsCacheInMemory.js +2 -2
  66. package/cjs/storages/inMemory/SplitsCacheInMemory.js +5 -5
  67. package/cjs/storages/inRedis/LatenciesCacheInRedis.js +1 -1
  68. package/cjs/storages/inRedis/RedisAdapter.js +24 -11
  69. package/cjs/storages/inRedis/SegmentsCacheInRedis.js +1 -1
  70. package/cjs/storages/inRedis/SplitsCacheInRedis.js +3 -3
  71. package/cjs/storages/inRedis/index.js +1 -1
  72. package/cjs/storages/pluggable/SegmentsCachePluggable.js +1 -1
  73. package/cjs/storages/pluggable/SplitsCachePluggable.js +3 -3
  74. package/cjs/storages/pluggable/inMemoryWrapper.js +4 -4
  75. package/cjs/storages/pluggable/index.js +6 -6
  76. package/cjs/sync/offline/LocalhostFromFile.js +1 -1
  77. package/cjs/sync/offline/LocalhostFromObject.js +1 -1
  78. package/cjs/sync/offline/splitsParser/parseCondition.js +1 -1
  79. package/cjs/sync/offline/splitsParser/splitsParserFromFile.js +13 -13
  80. package/cjs/sync/offline/splitsParser/splitsParserFromSettings.js +3 -3
  81. package/cjs/sync/offline/syncManagerOffline.js +1 -1
  82. package/cjs/sync/offline/syncTasks/fromObjectSyncTask.js +2 -2
  83. package/cjs/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
  84. package/cjs/sync/polling/fetchers/segmentChangesFetcher.js +1 -1
  85. package/cjs/sync/polling/pollingManagerCS.js +8 -7
  86. package/cjs/sync/polling/pollingManagerSS.js +5 -4
  87. package/cjs/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
  88. package/cjs/sync/polling/syncTasks/segmentsSyncTask.js +1 -1
  89. package/cjs/sync/polling/syncTasks/splitsSyncTask.js +1 -1
  90. package/cjs/sync/polling/updaters/mySegmentsUpdater.js +3 -3
  91. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +2 -2
  92. package/cjs/sync/polling/updaters/splitChangesUpdater.js +2 -2
  93. package/cjs/sync/streaming/AuthClient/index.js +3 -3
  94. package/cjs/sync/streaming/SSEClient/index.js +2 -1
  95. package/cjs/sync/streaming/SSEHandler/NotificationParser.js +1 -1
  96. package/cjs/sync/streaming/SSEHandler/index.js +3 -3
  97. package/cjs/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
  98. package/cjs/sync/streaming/mySegmentsV2utils.js +1 -1
  99. package/cjs/sync/streaming/pushManager.js +27 -19
  100. package/cjs/sync/submitters/eventsSyncTask.js +17 -5
  101. package/cjs/sync/submitters/impressionCountsSyncTask.js +1 -1
  102. package/cjs/sync/submitters/impressionsSyncTask.js +15 -3
  103. package/cjs/sync/submitters/metricsSyncTask.js +3 -3
  104. package/cjs/sync/submitters/submitterManager.js +6 -5
  105. package/cjs/sync/submitters/submitterSyncTask.js +1 -1
  106. package/cjs/sync/syncManagerOnline.js +14 -15
  107. package/cjs/trackers/eventTracker.js +11 -4
  108. package/cjs/trackers/impressionObserver/impressionObserverCS.js +1 -1
  109. package/cjs/trackers/impressionObserver/impressionObserverSS.js +1 -1
  110. package/cjs/trackers/impressionObserver/utils.js +8 -1
  111. package/cjs/trackers/impressionsTracker.js +9 -8
  112. package/cjs/utils/MinEvents.js +2 -1
  113. package/cjs/utils/consent.js +10 -0
  114. package/cjs/utils/constants/index.js +5 -1
  115. package/cjs/utils/inputValidation/apiKey.js +1 -1
  116. package/cjs/utils/inputValidation/attribute.js +4 -4
  117. package/cjs/utils/inputValidation/attributes.js +2 -2
  118. package/cjs/utils/inputValidation/event.js +1 -1
  119. package/cjs/utils/inputValidation/eventProperties.js +7 -5
  120. package/cjs/utils/inputValidation/eventValue.js +1 -1
  121. package/cjs/utils/inputValidation/key.js +6 -5
  122. package/cjs/utils/inputValidation/preloadedData.js +8 -8
  123. package/cjs/utils/inputValidation/split.js +1 -1
  124. package/cjs/utils/inputValidation/splits.js +2 -2
  125. package/cjs/utils/inputValidation/trafficType.js +1 -1
  126. package/cjs/utils/inputValidation/trafficTypeExistance.js +1 -1
  127. package/cjs/utils/jwt/index.js +1 -1
  128. package/cjs/utils/key/index.js +3 -3
  129. package/cjs/utils/lang/index.js +13 -16
  130. package/cjs/utils/lang/maps.js +16 -2
  131. package/cjs/utils/murmur3/common.js +1 -1
  132. package/cjs/utils/murmur3/murmur3.js +10 -10
  133. package/cjs/utils/murmur3/murmur3_128.js +1 -1
  134. package/cjs/utils/murmur3/murmur3_128_x86.js +37 -37
  135. package/cjs/utils/murmur3/murmur3_64.js +1 -1
  136. package/cjs/utils/settingsValidation/consent.js +16 -0
  137. package/cjs/utils/settingsValidation/impressionsMode.js +6 -6
  138. package/cjs/utils/settingsValidation/index.js +32 -14
  139. package/cjs/utils/settingsValidation/integrations/configurable.js +1 -1
  140. package/cjs/utils/settingsValidation/integrations/pluggable.js +1 -1
  141. package/cjs/utils/settingsValidation/localhost/builtin.js +2 -2
  142. package/cjs/utils/settingsValidation/logger/builtinLogger.js +3 -3
  143. package/cjs/utils/settingsValidation/logger/commons.js +1 -1
  144. package/cjs/utils/settingsValidation/logger/pluggableLogger.js +1 -1
  145. package/cjs/utils/settingsValidation/runtime.js +11 -0
  146. package/cjs/utils/settingsValidation/splitFilters.js +1 -1
  147. package/cjs/utils/settingsValidation/storage/storageCS.js +1 -1
  148. package/cjs/utils/timeTracker/index.js +3 -3
  149. package/esm/evaluator/matchers/ew.js +4 -4
  150. package/esm/integrations/ga/GoogleAnalyticsToSplit.js +4 -2
  151. package/esm/integrations/ga/SplitToGoogleAnalytics.js +4 -2
  152. package/esm/listeners/browser.js +14 -10
  153. package/esm/logger/constants.js +6 -2
  154. package/esm/logger/messages/debug.js +3 -3
  155. package/esm/logger/messages/error.js +4 -3
  156. package/esm/logger/messages/info.js +7 -4
  157. package/esm/sdkClient/client.js +3 -2
  158. package/esm/sdkClient/clientCS.js +1 -1
  159. package/esm/sdkClient/clientInputValidation.js +6 -8
  160. package/esm/sdkClient/sdkClient.js +1 -4
  161. package/esm/sdkClient/sdkClientMethodCS.js +1 -5
  162. package/esm/sdkClient/sdkClientMethodCSWithTT.js +1 -9
  163. package/esm/sdkFactory/index.js +8 -6
  164. package/esm/sdkFactory/userConsentProps.js +36 -0
  165. package/esm/services/splitApi.js +2 -1
  166. package/esm/storages/KeyBuilder.js +2 -6
  167. package/esm/storages/KeyBuilderCS.js +11 -1
  168. package/esm/storages/inLocalStorage/MySegmentsCacheInLocal.js +23 -3
  169. package/esm/storages/inLocalStorage/index.js +1 -1
  170. package/esm/storages/inMemory/ImpressionsCacheInMemory.js +15 -1
  171. package/esm/storages/inMemory/InMemoryStorage.js +1 -1
  172. package/esm/storages/inMemory/InMemoryStorageCS.js +1 -1
  173. package/esm/storages/inRedis/RedisAdapter.js +15 -2
  174. package/esm/storages/pluggable/index.js +2 -2
  175. package/esm/sync/offline/splitsParser/splitsParserFromFile.js +1 -1
  176. package/esm/sync/polling/fetchers/mySegmentsFetcher.js +2 -2
  177. package/esm/sync/polling/fetchers/segmentChangesFetcher.js +2 -2
  178. package/esm/sync/polling/pollingManagerCS.js +2 -1
  179. package/esm/sync/polling/pollingManagerSS.js +2 -1
  180. package/esm/sync/polling/syncTasks/mySegmentsSyncTask.js +1 -1
  181. package/esm/sync/polling/updaters/mySegmentsUpdater.js +2 -2
  182. package/esm/sync/streaming/SSEClient/index.js +2 -1
  183. package/esm/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.js +1 -1
  184. package/esm/sync/streaming/pushManager.js +13 -5
  185. package/esm/sync/submitters/eventsSyncTask.js +18 -6
  186. package/esm/sync/submitters/impressionsSyncTask.js +13 -1
  187. package/esm/sync/submitters/submitterManager.js +2 -1
  188. package/esm/sync/syncManagerOnline.js +14 -15
  189. package/esm/trackers/eventTracker.js +8 -1
  190. package/esm/trackers/impressionObserver/utils.js +7 -1
  191. package/esm/trackers/impressionsTracker.js +6 -5
  192. package/esm/utils/consent.js +6 -0
  193. package/esm/utils/constants/index.js +4 -0
  194. package/esm/utils/inputValidation/attributes.js +1 -1
  195. package/esm/utils/inputValidation/eventProperties.js +4 -2
  196. package/esm/utils/inputValidation/key.js +2 -1
  197. package/esm/utils/lang/index.js +12 -15
  198. package/esm/utils/lang/maps.js +14 -1
  199. package/esm/utils/settingsValidation/consent.js +12 -0
  200. package/esm/utils/settingsValidation/impressionsMode.js +7 -7
  201. package/esm/utils/settingsValidation/index.js +28 -10
  202. package/esm/utils/settingsValidation/runtime.js +7 -0
  203. package/package.json +6 -6
  204. package/src/evaluator/matchers/ew.ts +4 -4
  205. package/src/evaluator/parser/index.ts +1 -1
  206. package/src/evaluator/types.ts +2 -2
  207. package/src/evaluator/value/index.ts +2 -2
  208. package/src/evaluator/value/sanitize.ts +2 -2
  209. package/src/integrations/ga/GoogleAnalyticsToSplit.ts +7 -4
  210. package/src/integrations/ga/SplitToGoogleAnalytics.ts +7 -4
  211. package/src/integrations/pluggable.ts +2 -2
  212. package/src/integrations/types.ts +5 -0
  213. package/src/listeners/browser.ts +13 -9
  214. package/src/logger/constants.ts +6 -2
  215. package/src/logger/messages/debug.ts +3 -3
  216. package/src/logger/messages/error.ts +4 -3
  217. package/src/logger/messages/info.ts +7 -4
  218. package/src/logger/types.ts +4 -0
  219. package/src/sdkClient/client.ts +3 -2
  220. package/src/sdkClient/clientCS.ts +1 -1
  221. package/src/sdkClient/clientInputValidation.ts +8 -7
  222. package/src/sdkClient/sdkClient.ts +2 -5
  223. package/src/sdkClient/sdkClientMethodCS.ts +1 -6
  224. package/src/sdkClient/sdkClientMethodCSWithTT.ts +2 -11
  225. package/src/sdkFactory/index.ts +9 -7
  226. package/src/sdkFactory/types.ts +2 -1
  227. package/src/sdkFactory/userConsentProps.ts +42 -0
  228. package/src/storages/KeyBuilder.ts +2 -6
  229. package/src/storages/KeyBuilderCS.ts +13 -1
  230. package/src/storages/inLocalStorage/MySegmentsCacheInLocal.ts +23 -3
  231. package/src/storages/inLocalStorage/index.ts +1 -1
  232. package/src/storages/inMemory/ImpressionsCacheInMemory.ts +22 -1
  233. package/src/storages/inMemory/InMemoryStorage.ts +1 -1
  234. package/src/storages/inMemory/InMemoryStorageCS.ts +1 -1
  235. package/src/storages/inRedis/RedisAdapter.ts +8 -2
  236. package/src/storages/pluggable/index.ts +2 -2
  237. package/src/storages/types.ts +6 -2
  238. package/src/sync/offline/splitsParser/splitsParserFromFile.ts +1 -1
  239. package/src/sync/polling/fetchers/mySegmentsFetcher.ts +2 -1
  240. package/src/sync/polling/fetchers/types.ts +1 -0
  241. package/src/sync/polling/pollingManagerCS.ts +3 -6
  242. package/src/sync/polling/pollingManagerSS.ts +3 -8
  243. package/src/sync/polling/syncTasks/mySegmentsSyncTask.ts +2 -1
  244. package/src/sync/polling/types.ts +0 -12
  245. package/src/sync/polling/updaters/mySegmentsUpdater.ts +2 -1
  246. package/src/sync/streaming/SSEClient/index.ts +2 -1
  247. package/src/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.ts +1 -1
  248. package/src/sync/streaming/pushManager.ts +19 -16
  249. package/src/sync/streaming/types.ts +5 -25
  250. package/src/sync/submitters/eventsSyncTask.ts +19 -6
  251. package/src/sync/submitters/impressionsSyncTask.ts +16 -1
  252. package/src/sync/submitters/submitterManager.ts +4 -8
  253. package/src/sync/syncManagerOnline.ts +20 -24
  254. package/src/sync/types.ts +4 -1
  255. package/src/trackers/eventTracker.ts +11 -3
  256. package/src/trackers/impressionObserver/utils.ts +8 -1
  257. package/src/trackers/impressionsTracker.ts +7 -8
  258. package/src/types.ts +22 -1
  259. package/src/utils/consent.ts +8 -0
  260. package/src/utils/constants/index.ts +5 -0
  261. package/src/utils/inputValidation/attributes.ts +1 -2
  262. package/src/utils/inputValidation/eventProperties.ts +4 -2
  263. package/src/utils/lang/index.ts +15 -18
  264. package/src/utils/lang/maps.ts +15 -1
  265. package/src/utils/settingsValidation/consent.ts +16 -0
  266. package/src/utils/settingsValidation/impressionsMode.ts +8 -8
  267. package/src/utils/settingsValidation/index.ts +29 -10
  268. package/src/utils/settingsValidation/runtime.ts +9 -0
  269. package/src/utils/settingsValidation/types.ts +12 -6
  270. package/types/evaluator/types.d.ts +2 -2
  271. package/types/evaluator/value/index.d.ts +1 -1
  272. package/types/evaluator/value/sanitize.d.ts +1 -1
  273. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +2 -2
  274. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +2 -3
  275. package/types/integrations/types.d.ts +4 -0
  276. package/types/logger/constants.d.ts +6 -2
  277. package/types/logger/types.d.ts +4 -0
  278. package/types/sdkClient/clientAttributesDecoration.d.ts +1 -1
  279. package/types/sdkClient/clientInputValidation.d.ts +2 -3
  280. package/types/sdkFactory/types.d.ts +1 -1
  281. package/types/sdkFactory/userConsentProps.d.ts +6 -0
  282. package/types/storages/KeyBuilderCS.d.ts +2 -0
  283. package/types/storages/inMemory/ImpressionsCacheInMemory.d.ts +9 -0
  284. package/types/storages/inMemory/index.d.ts +10 -0
  285. package/types/storages/inRedis/RedisAdapter.d.ts +1 -1
  286. package/types/storages/parseSegments.d.ts +6 -0
  287. package/types/storages/types.d.ts +3 -1
  288. package/types/sync/polling/fetchers/mySegmentsFetcher.d.ts +1 -1
  289. package/types/sync/polling/fetchers/types.d.ts +1 -1
  290. package/types/sync/polling/pollingManagerCS.d.ts +2 -5
  291. package/types/sync/polling/pollingManagerSS.d.ts +2 -5
  292. package/types/sync/polling/types.d.ts +0 -11
  293. package/types/sync/polling/updaters/mySegmentsUpdater.d.ts +1 -1
  294. package/types/sync/streaming/UpdateWorkers/SegmentsUpdateWorker.d.ts +1 -1
  295. package/types/sync/streaming/pushManager.d.ts +3 -7
  296. package/types/sync/streaming/pushManagerCS.d.ts +1 -12
  297. package/types/sync/streaming/pushManagerSS.d.ts +1 -11
  298. package/types/sync/streaming/types.d.ts +3 -23
  299. package/types/sync/submitters/submitterManager.d.ts +2 -4
  300. package/types/sync/syncManagerOnline.d.ts +3 -3
  301. package/types/sync/types.d.ts +3 -0
  302. package/types/trackers/eventTracker.d.ts +2 -2
  303. package/types/trackers/impressionObserver/utils.d.ts +4 -0
  304. package/types/trackers/impressionsTracker.d.ts +2 -3
  305. package/types/types.d.ts +22 -1
  306. package/types/utils/consent.d.ts +2 -0
  307. package/types/utils/constants/index.d.ts +3 -0
  308. package/types/utils/lang/index.d.ts +6 -5
  309. package/types/utils/lang/maps.d.ts +7 -0
  310. package/types/utils/settingsValidation/consent.d.ts +6 -0
  311. package/types/utils/settingsValidation/impressionsMode.d.ts +1 -1
  312. package/types/utils/settingsValidation/runtime/browser.d.ts +2 -0
  313. package/types/utils/settingsValidation/runtime/node.d.ts +2 -0
  314. package/types/utils/settingsValidation/runtime.d.ts +2 -0
  315. package/types/utils/settingsValidation/types.d.ts +12 -6
  316. package/types/utils/settingsValidation/userConsent.d.ts +5 -0
@@ -5,6 +5,7 @@ var objectAssign_1 = require("../utils/lang/objectAssign");
5
5
  var thenable_1 = require("../utils/promise/thenable");
6
6
  var time_1 = require("../utils/time");
7
7
  var constants_1 = require("../logger/constants");
8
+ var constants_2 = require("../utils/constants");
8
9
  /**
9
10
  * Impressions tracker stores impressions in cache and pass them to the listener and integrations manager if provided.
10
11
  *
@@ -15,16 +16,16 @@ var constants_1 = require("../logger/constants");
15
16
  * @param observer optional impression observer. If provided, previous time (pt property) is included in impression instances
16
17
  * @param countsCache optional cache to save impressions count. If provided, impressions will be deduped (OPTIMIZED mode)
17
18
  */
18
- function impressionsTrackerFactory(log, impressionsCache,
19
- // @TODO consider passing only an optional integrationsManager to handle impressions
20
- _a, impressionListener, integrationsManager,
19
+ function impressionsTrackerFactory(settings, impressionsCache, integrationsManager,
21
20
  // if observer is provided, it implies `shouldAddPreviousTime` flag (i.e., if impressions previous time should be added or not)
22
21
  observer,
23
22
  // if countsCache is provided, it implies `isOptimized` flag (i.e., if impressions should be deduped or not)
24
23
  countsCache) {
25
- var _b = _a.runtime, ip = _b.ip, hostname = _b.hostname, version = _a.version;
24
+ var log = settings.log, impressionListener = settings.impressionListener, _a = settings.runtime, ip = _a.ip, hostname = _a.hostname, version = settings.version;
26
25
  return {
27
26
  track: function (impressions, attributes) {
27
+ if (settings.userConsent === constants_2.CONSENT_DECLINED)
28
+ return;
28
29
  var impressionsCount = impressions.length;
29
30
  var impressionsToStore = []; // Track only the impressions that are going to be stored
30
31
  // Wraps impressions to store and adds previousTime if it corresponds
@@ -39,13 +40,13 @@ countsCache) {
39
40
  countsCache.track(impression.feature, now, 1);
40
41
  }
41
42
  // Checks if the impression should be added in queue to be sent
42
- if (!countsCache || !impression.pt || impression.pt < time_1.truncateTimeFrame(now)) {
43
+ if (!countsCache || !impression.pt || impression.pt < (0, time_1.truncateTimeFrame)(now)) {
43
44
  impressionsToStore.push(impression);
44
45
  }
45
46
  });
46
47
  var res = impressionsCache.track(impressionsToStore);
47
48
  // If we're on an async storage, handle error and log it.
48
- if (thenable_1.thenable(res)) {
49
+ if ((0, thenable_1.thenable)(res)) {
49
50
  res.then(function () {
50
51
  log.info(constants_1.IMPRESSIONS_TRACKER_SUCCESS, [impressionsCount]);
51
52
  }).catch(function (err) {
@@ -57,7 +58,7 @@ countsCache) {
57
58
  var _loop_1 = function (i) {
58
59
  var impressionData = {
59
60
  // copy of impression, to avoid unexpected behaviour if modified by integrations or impressionListener
60
- impression: objectAssign_1.objectAssign({}, impressions[i]),
61
+ impression: (0, objectAssign_1.objectAssign)({}, impressions[i]),
61
62
  attributes: attributes,
62
63
  ip: ip,
63
64
  hostname: hostname,
@@ -68,7 +69,7 @@ countsCache) {
68
69
  // integrationsManager.handleImpression does not throw errors
69
70
  if (integrationsManager)
70
71
  integrationsManager.handleImpression(impressionData);
71
- try { // An exception on the listeners should not break the SDK.
72
+ try { // @ts-ignore. An exception on the listeners should not break the SDK.
72
73
  if (impressionListener)
73
74
  impressionListener.logImpression(impressionData);
74
75
  }
@@ -38,9 +38,10 @@ var ReflectApply = R && typeof R.apply === 'function'
38
38
  : function ReflectApply(target, receiver, args) {
39
39
  return Function.prototype.apply.call(target, receiver, args);
40
40
  };
41
- exports.EventEmitter = function EventEmitter() {
41
+ var EventEmitter = function EventEmitter() {
42
42
  EventEmitter.init.call(this);
43
43
  };
44
+ exports.EventEmitter = EventEmitter;
44
45
  exports.EventEmitter.prototype._events = undefined;
45
46
  exports.EventEmitter.prototype._eventsCount = 0;
46
47
  function checkListener(listener) {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isConsentGranted = void 0;
4
+ var constants_1 = require("./constants");
5
+ function isConsentGranted(settings) {
6
+ var userConsent = settings.userConsent;
7
+ // undefined userConsent is handled as granted (default)
8
+ return !userConsent || userConsent === constants_1.CONSENT_GRANTED;
9
+ }
10
+ exports.isConsentGranted = isConsentGranted;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STORAGE_PLUGGABLE = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
3
+ exports.CONSENT_UNKNOWN = exports.CONSENT_DECLINED = exports.CONSENT_GRANTED = exports.STORAGE_PLUGGABLE = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
4
4
  // Special treatments
5
5
  exports.CONTROL = 'control';
6
6
  exports.CONTROL_WITH_CONFIG = {
@@ -27,3 +27,7 @@ exports.STORAGE_MEMORY = 'MEMORY';
27
27
  exports.STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
28
28
  exports.STORAGE_REDIS = 'REDIS';
29
29
  exports.STORAGE_PLUGGABLE = 'PLUGGABLE';
30
+ // User consent
31
+ exports.CONSENT_GRANTED = 'GRANTED'; // The user has granted consent for tracking events and impressions
32
+ exports.CONSENT_DECLINED = 'DECLINED'; // The user has declined consent for tracking events and impressions
33
+ exports.CONSENT_UNKNOWN = 'UNKNOWN'; // The user has neither granted nor declined consent for tracking events and impressions
@@ -10,7 +10,7 @@ function validateApiKey(log, maybeApiKey) {
10
10
  if (maybeApiKey == undefined) { // eslint-disable-line eqeqeq
11
11
  log.error(constants_1.ERROR_NULL, [constants_1.LOG_PREFIX_INSTANTIATION, item]);
12
12
  }
13
- else if (lang_1.isString(maybeApiKey)) {
13
+ else if ((0, lang_1.isString)(maybeApiKey)) {
14
14
  if (maybeApiKey.length > 0)
15
15
  apiKey = maybeApiKey;
16
16
  else
@@ -3,13 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateAttribute = void 0;
4
4
  var lang_1 = require("../../utils/lang");
5
5
  function validateAttribute(log, attributeKey, attributeValue, method) {
6
- if (!lang_1.isString(attributeKey) || attributeKey.length === 0) {
6
+ if (!(0, lang_1.isString)(attributeKey) || attributeKey.length === 0) {
7
7
  log.warn(method + ": you passed an invalid attribute name, attribute name must be a non-empty string.");
8
8
  return false;
9
9
  }
10
- var isStringVal = lang_1.isString(attributeValue);
11
- var isFiniteVal = lang_1.isFiniteNumber(attributeValue);
12
- var isBoolVal = lang_1.isBoolean(attributeValue);
10
+ var isStringVal = (0, lang_1.isString)(attributeValue);
11
+ var isFiniteVal = (0, lang_1.isFiniteNumber)(attributeValue);
12
+ var isBoolVal = (0, lang_1.isBoolean)(attributeValue);
13
13
  var isArrayVal = Array.isArray(attributeValue);
14
14
  if (!(isStringVal || isFiniteVal || isBoolVal || isArrayVal)) { // If it's not of valid type.
15
15
  log.warn(method + ": you passed an invalid attribute value for " + attributeKey + ". Acceptable types are: string, number, boolean and array of strings.");
@@ -6,7 +6,7 @@ var attribute_1 = require("./attribute");
6
6
  var constants_1 = require("../../logger/constants");
7
7
  function validateAttributes(log, maybeAttrs, method) {
8
8
  // Attributes are optional
9
- if (lang_1.isObject(maybeAttrs) || maybeAttrs == undefined) // eslint-disable-line eqeqeq
9
+ if (maybeAttrs == undefined || (0, lang_1.isObject)(maybeAttrs)) // eslint-disable-line eqeqeq
10
10
  return maybeAttrs;
11
11
  log.error(constants_1.ERROR_NOT_PLAIN_OBJECT, [method, 'attributes']);
12
12
  return false;
@@ -17,7 +17,7 @@ function validateAttributesDeep(log, maybeAttributes, method) {
17
17
  return false;
18
18
  var result = true;
19
19
  Object.keys(maybeAttributes).forEach(function (attributeKey) {
20
- if (!attribute_1.validateAttribute(log, attributeKey, maybeAttributes[attributeKey], method))
20
+ if (!(0, attribute_1.validateAttribute)(log, attributeKey, maybeAttributes[attributeKey], method))
21
21
  result = false;
22
22
  });
23
23
  return result;
@@ -9,7 +9,7 @@ function validateEvent(log, maybeEvent, method) {
9
9
  if (maybeEvent == undefined) { // eslint-disable-line eqeqeq
10
10
  log.error(constants_1.ERROR_NULL, [method, item]);
11
11
  }
12
- else if (!lang_1.isString(maybeEvent)) {
12
+ else if (!(0, lang_1.isString)(maybeEvent)) {
13
13
  log.error(constants_1.ERROR_INVALID, [method, item]);
14
14
  }
15
15
  else { // It is a string.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateEventProperties = void 0;
4
4
  var lang_1 = require("../lang");
5
+ var objectAssign_1 = require("../lang/objectAssign");
5
6
  var constants_1 = require("../../logger/constants");
6
7
  var ECMA_SIZES = {
7
8
  NULL: 0,
@@ -15,12 +16,13 @@ var BASE_EVENT_SIZE = 1024; // We assume 1kb events without properties (avg meas
15
16
  function validateEventProperties(log, maybeProperties, method) {
16
17
  if (maybeProperties == undefined)
17
18
  return { properties: null, size: BASE_EVENT_SIZE }; // eslint-disable-line eqeqeq
18
- if (!lang_1.isObject(maybeProperties)) {
19
+ if (!(0, lang_1.isObject)(maybeProperties)) {
19
20
  log.error(constants_1.ERROR_NOT_PLAIN_OBJECT, [method, 'properties']);
20
21
  return { properties: false, size: BASE_EVENT_SIZE };
21
22
  }
22
23
  var keys = Object.keys(maybeProperties);
23
- var clone = lang_1.shallowClone(maybeProperties);
24
+ // Shallow clone
25
+ var clone = (0, objectAssign_1.objectAssign)({}, maybeProperties);
24
26
  // To avoid calculating the size twice we'll return it from here.
25
27
  var output = {
26
28
  properties: clone,
@@ -32,9 +34,9 @@ function validateEventProperties(log, maybeProperties, method) {
32
34
  for (var i = 0; i < keys.length; i++) {
33
35
  output.size += keys[i].length * ECMA_SIZES.STRING; // Count the size of the key which is always a string.
34
36
  var val = clone[keys[i]];
35
- var isStringVal = lang_1.isString(val);
36
- var isFiniteVal = lang_1.isFiniteNumber(val);
37
- var isBoolVal = lang_1.isBoolean(val);
37
+ var isStringVal = (0, lang_1.isString)(val);
38
+ var isFiniteVal = (0, lang_1.isFiniteNumber)(val);
39
+ var isBoolVal = (0, lang_1.isBoolean)(val);
38
40
  var isNullVal = val === null;
39
41
  if (!(isStringVal || isFiniteVal || isBoolVal || isNullVal)) { // If it's not of valid type.
40
42
  clone[keys[i]] = null;
@@ -4,7 +4,7 @@ exports.validateEventValue = void 0;
4
4
  var constants_1 = require("../../logger/constants");
5
5
  var lang_1 = require("../lang");
6
6
  function validateEventValue(log, maybeValue, method) {
7
- if (lang_1.isFiniteNumber(maybeValue) || maybeValue == undefined) // eslint-disable-line eqeqeq
7
+ if ((0, lang_1.isFiniteNumber)(maybeValue) || maybeValue == undefined) // eslint-disable-line eqeqeq
8
8
  return maybeValue;
9
9
  log.error(constants_1.ERROR_NOT_FINITE, [method]);
10
10
  return false;
@@ -9,11 +9,11 @@ function validateKeyValue(log, maybeKey, method, type) {
9
9
  log.error(constants_1.ERROR_NULL, [method, type]);
10
10
  return false;
11
11
  }
12
- if (lang_1.isFiniteNumber(maybeKey)) {
12
+ if ((0, lang_1.isFiniteNumber)(maybeKey)) {
13
13
  log.warn(constants_1.WARN_CONVERTING, [method, type, maybeKey]);
14
- return lang_1.toString(maybeKey);
14
+ return (0, lang_1.toString)(maybeKey);
15
15
  }
16
- if (lang_1.isString(maybeKey)) {
16
+ if ((0, lang_1.isString)(maybeKey)) {
17
17
  // It's a string, start by trimming the value.
18
18
  maybeKey = maybeKey.trim();
19
19
  // It's aaaaaall good.
@@ -32,13 +32,14 @@ function validateKeyValue(log, maybeKey, method, type) {
32
32
  return false;
33
33
  }
34
34
  function validateKey(log, maybeKey, method) {
35
- if (lang_1.isObject(maybeKey)) {
35
+ if ((0, lang_1.isObject)(maybeKey)) {
36
36
  // Validate key object
37
37
  var matchingKey = validateKeyValue(log, maybeKey.matchingKey, method, 'matchingKey');
38
38
  var bucketingKey = validateKeyValue(log, maybeKey.bucketingKey, method, 'bucketingKey');
39
39
  if (matchingKey && bucketingKey)
40
40
  return {
41
- matchingKey: matchingKey, bucketingKey: bucketingKey
41
+ matchingKey: matchingKey,
42
+ bucketingKey: bucketingKey
42
43
  };
43
44
  log.error(constants_1.ERROR_INVALID_KEY_OBJECT, [method]);
44
45
  return false;
@@ -4,30 +4,30 @@ exports.validatePreloadedData = void 0;
4
4
  var lang_1 = require("../lang");
5
5
  var split_1 = require("./split");
6
6
  function validateTimestampData(log, maybeTimestamp, method, item) {
7
- if (lang_1.isFiniteNumber(maybeTimestamp) && maybeTimestamp > -1)
7
+ if ((0, lang_1.isFiniteNumber)(maybeTimestamp) && maybeTimestamp > -1)
8
8
  return true;
9
9
  log.error(method + ": preloadedData." + item + " must be a positive number.");
10
10
  return false;
11
11
  }
12
12
  function validateSplitsData(log, maybeSplitsData, method) {
13
- if (lang_1.isObject(maybeSplitsData)) {
13
+ if ((0, lang_1.isObject)(maybeSplitsData)) {
14
14
  var splitNames = Object.keys(maybeSplitsData);
15
15
  if (splitNames.length === 0)
16
16
  log.warn(method + ": preloadedData.splitsData doesn't contain split definitions.");
17
17
  // @TODO in the future, consider handling the possibility of having parsed definitions of splits
18
- if (splitNames.every(function (splitName) { return split_1.validateSplit(log, splitName, method) && lang_1.isString(maybeSplitsData[splitName]); }))
18
+ if (splitNames.every(function (splitName) { return (0, split_1.validateSplit)(log, splitName, method) && (0, lang_1.isString)(maybeSplitsData[splitName]); }))
19
19
  return true;
20
20
  }
21
21
  log.error(method + ": preloadedData.splitsData must be a map of split names to their serialized definitions.");
22
22
  return false;
23
23
  }
24
24
  function validateMySegmentsData(log, maybeMySegmentsData, method) {
25
- if (lang_1.isObject(maybeMySegmentsData)) {
25
+ if ((0, lang_1.isObject)(maybeMySegmentsData)) {
26
26
  var userKeys = Object.keys(maybeMySegmentsData);
27
27
  if (userKeys.every(function (userKey) {
28
28
  var segmentNames = maybeMySegmentsData[userKey];
29
29
  // an empty list is valid
30
- return Array.isArray(segmentNames) && segmentNames.every(function (segmentName) { return lang_1.isString(segmentName); });
30
+ return Array.isArray(segmentNames) && segmentNames.every(function (segmentName) { return (0, lang_1.isString)(segmentName); });
31
31
  }))
32
32
  return true;
33
33
  }
@@ -35,16 +35,16 @@ function validateMySegmentsData(log, maybeMySegmentsData, method) {
35
35
  return false;
36
36
  }
37
37
  function validateSegmentsData(log, maybeSegmentsData, method) {
38
- if (lang_1.isObject(maybeSegmentsData)) {
38
+ if ((0, lang_1.isObject)(maybeSegmentsData)) {
39
39
  var segmentNames = Object.keys(maybeSegmentsData);
40
- if (segmentNames.every(function (segmentName) { return lang_1.isString(maybeSegmentsData[segmentName]); }))
40
+ if (segmentNames.every(function (segmentName) { return (0, lang_1.isString)(maybeSegmentsData[segmentName]); }))
41
41
  return true;
42
42
  }
43
43
  log.error(method + ": preloadedData.segmentsData must be a map of segment names to their serialized definitions.");
44
44
  return false;
45
45
  }
46
46
  function validatePreloadedData(log, maybePreloadedData, method) {
47
- if (!lang_1.isObject(maybePreloadedData)) {
47
+ if (!(0, lang_1.isObject)(maybePreloadedData)) {
48
48
  log.error(method + ": preloadedData must be an object.");
49
49
  }
50
50
  else if (validateTimestampData(log, maybePreloadedData.lastUpdated, method, 'lastUpdated') &&
@@ -10,7 +10,7 @@ function validateSplit(log, maybeSplit, method, item) {
10
10
  if (maybeSplit == undefined) { // eslint-disable-line eqeqeq
11
11
  log.error(constants_1.ERROR_NULL, [method, item]);
12
12
  }
13
- else if (!lang_1.isString(maybeSplit)) {
13
+ else if (!(0, lang_1.isString)(maybeSplit)) {
14
14
  log.error(constants_1.ERROR_INVALID, [method, item]);
15
15
  }
16
16
  else {
@@ -11,13 +11,13 @@ function validateSplits(log, maybeSplits, method, listName, item) {
11
11
  var validatedArray_1 = [];
12
12
  // Remove invalid values
13
13
  maybeSplits.forEach(function (maybeSplit) {
14
- var splitName = split_1.validateSplit(log, maybeSplit, method, item);
14
+ var splitName = (0, split_1.validateSplit)(log, maybeSplit, method, item);
15
15
  if (splitName)
16
16
  validatedArray_1.push(splitName);
17
17
  });
18
18
  // Strip off duplicated values if we have valid split names then return
19
19
  if (validatedArray_1.length)
20
- return lang_1.uniq(validatedArray_1);
20
+ return (0, lang_1.uniq)(validatedArray_1);
21
21
  }
22
22
  log.error(constants_1.ERROR_EMPTY_ARRAY, [method, listName]);
23
23
  return false;
@@ -9,7 +9,7 @@ function validateTrafficType(log, maybeTT, method) {
9
9
  if (maybeTT == undefined) { // eslint-disable-line eqeqeq
10
10
  log.error(constants_1.ERROR_NULL, [method, item]);
11
11
  }
12
- else if (!lang_1.isString(maybeTT)) {
12
+ else if (!(0, lang_1.isString)(maybeTT)) {
13
13
  log.error(constants_1.ERROR_INVALID, [method, item]);
14
14
  }
15
15
  else {
@@ -15,7 +15,7 @@ function validateTrafficTypeExistance(log, readinessManager, splitsCache, mode,
15
15
  if (!readinessManager.isReady() || mode === constants_1.LOCALHOST_MODE)
16
16
  return true;
17
17
  var res = splitsCache.trafficTypeExists(maybeTT); // never rejects or throws error
18
- if (thenable_1.thenable(res)) {
18
+ if ((0, thenable_1.thenable)(res)) {
19
19
  return res.then(function (isValid) {
20
20
  if (!isValid)
21
21
  logTTExistanceWarning(log, maybeTT, method);
@@ -9,7 +9,7 @@ function decodeJWTtoken(token) {
9
9
  var base64Url = token.split('.')[1];
10
10
  var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
11
11
  // no need to check availability of `encodeURIComponent`, since it is a function highly supported in browsers, node and other platforms.
12
- var jsonPayload = decodeURIComponent(base64_1.decodeFromBase64(base64).split('').map(function (c) {
12
+ var jsonPayload = decodeURIComponent((0, base64_1.decodeFromBase64)(base64).split('').map(function (c) {
13
13
  return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
14
14
  }).join(''));
15
15
  return JSON.parse(jsonPayload);
@@ -7,12 +7,12 @@ var lang_1 = require("../lang");
7
7
  // }
8
8
  // returns the matchingKey if the Key is defined as an object or the key itself if it is a string
9
9
  function getMatching(key) {
10
- return lang_1.isObject(key) ? key.matchingKey : key;
10
+ return (0, lang_1.isObject)(key) ? key.matchingKey : key;
11
11
  }
12
12
  exports.getMatching = getMatching;
13
13
  // if the key is a string, there's no bucketingKey (undefined)
14
14
  function getBucketing(key) {
15
- return lang_1.isObject(key) ? key.bucketingKey : undefined;
15
+ return (0, lang_1.isObject)(key) ? key.bucketingKey : undefined;
16
16
  }
17
17
  exports.getBucketing = getBucketing;
18
18
  /**
@@ -20,7 +20,7 @@ exports.getBucketing = getBucketing;
20
20
  * specific split.
21
21
  */
22
22
  function keyParser(key) {
23
- if (lang_1.isObject(key)) {
23
+ if ((0, lang_1.isObject)(key)) {
24
24
  return {
25
25
  matchingKey: key.matchingKey,
26
26
  bucketingKey: key.bucketingKey
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniqueId = exports.uniqAsStrings = exports.uniq = exports.toString = exports.toNumber = exports.startsWith = exports.shallowClone = exports.merge = exports.isString = exports.isObject = exports.isNaNNumber = exports.isIntegerNumber = exports.isFiniteNumber = exports.isBoolean = exports.groupBy = exports.get = exports.forOwn = exports.findIndex = exports.find = exports.endsWith = void 0;
3
+ exports.uniqueId = exports.uniqAsStrings = exports.uniq = exports.toString = exports.toNumber = exports.startsWith = exports.merge = exports.stringToUpperCase = exports.isString = exports.isObject = exports.isNaNNumber = exports.isIntegerNumber = exports.isFiniteNumber = exports.isBoolean = exports.groupBy = exports.get = exports.forOwn = exports.findIndex = exports.find = exports.endsWith = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  /**
6
6
  * Checks if the target string ends with the sub string.
@@ -154,10 +154,12 @@ function isNaNNumber(val) {
154
154
  }
155
155
  exports.isNaNNumber = isNaNNumber;
156
156
  /**
157
- * Validates if a value is an object with the Object prototype (map object).
157
+ * Validates if a value is an object created by the Object constructor (plain object).
158
+ * It checks `constructor.name` to avoid false negatives when validating values on a separate VM context, which has its own global built-ins.
158
159
  */
159
160
  function isObject(obj) {
160
- return obj !== null && typeof obj === 'object' && obj.constructor === Object;
161
+ return obj !== null && typeof obj === 'object' && (obj.constructor === Object ||
162
+ (obj.constructor != null && obj.constructor.name === 'Object'));
161
163
  }
162
164
  exports.isObject = isObject;
163
165
  /**
@@ -167,6 +169,13 @@ function isString(val) {
167
169
  return typeof val === 'string' || val instanceof String;
168
170
  }
169
171
  exports.isString = isString;
172
+ /**
173
+ * String sanitizer. Returns the provided value converted to uppercase if it is a string.
174
+ */
175
+ function stringToUpperCase(val) {
176
+ return isString(val) ? val.toUpperCase() : val;
177
+ }
178
+ exports.stringToUpperCase = stringToUpperCase;
170
179
  /**
171
180
  * Deep copy version of Object.assign using recursion.
172
181
  * There are some assumptions here. It's for internal use and we don't need verbose errors
@@ -194,23 +203,11 @@ function merge(target, source) {
194
203
  });
195
204
  if (rest && rest.length) {
196
205
  var nextSource = rest.splice(0, 1)[0];
197
- res = merge.apply(void 0, tslib_1.__spreadArrays([res, nextSource], rest));
206
+ res = merge.apply(void 0, (0, tslib_1.__spreadArray)([res, nextSource], rest, false));
198
207
  }
199
208
  return res;
200
209
  }
201
210
  exports.merge = merge;
202
- /**
203
- * Shallow clone an object
204
- */
205
- function shallowClone(obj) {
206
- var keys = Object.keys(obj);
207
- var output = {};
208
- for (var i = 0; i < keys.length; i++) {
209
- output[keys[i]] = obj[keys[i]];
210
- }
211
- return output;
212
- }
213
- exports.shallowClone = shallowClone;
214
211
  /**
215
212
  * Checks if the target string starts with the sub string.
216
213
  */
@@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
24
  THE SOFTWARE.
25
25
  **/
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports._Map = exports.MapPoly = void 0;
27
+ exports._Map = exports.__getMapConstructor = exports.MapPoly = void 0;
28
28
  var MapPoly = /** @class */ (function () {
29
29
  // unlike ES6 `Map`, it only accepts an array as first argument iterable
30
30
  function MapPoly(entries) {
@@ -71,4 +71,18 @@ var MapPoly = /** @class */ (function () {
71
71
  return MapPoly;
72
72
  }());
73
73
  exports.MapPoly = MapPoly;
74
- exports._Map = typeof Map !== 'undefined' ? Map : MapPoly;
74
+ /**
75
+ * return the Map constructor to use. If native Map is not available or it doesn't support the required features (e.g., IE11),
76
+ * a ponyfill with minimal features is returned instead.
77
+ *
78
+ * Exported for testing purposes only.
79
+ */
80
+ function __getMapConstructor() {
81
+ // eslint-disable-next-line compat/compat
82
+ if (typeof Array.from === 'function' && typeof Map === 'function' && Map.prototype && Map.prototype.values) {
83
+ return Map;
84
+ }
85
+ return MapPoly;
86
+ }
87
+ exports.__getMapConstructor = __getMapConstructor;
88
+ exports._Map = __getMapConstructor();
@@ -4,7 +4,7 @@ exports.x86Fmix = exports.x86Rotl = exports.x86Multiply = exports.UTF16ToUTF8 =
4
4
  var utfx_1 = require("./utfx");
5
5
  function UTF16ToUTF8(key) {
6
6
  var sd;
7
- utfx_1.encodeUTF16toUTF8(utfx_1.stringSource(key), sd = utfx_1.stringDestination());
7
+ (0, utfx_1.encodeUTF16toUTF8)((0, utfx_1.stringSource)(key), sd = (0, utfx_1.stringDestination)());
8
8
  return sd();
9
9
  }
10
10
  exports.UTF16ToUTF8 = UTF16ToUTF8;
@@ -28,12 +28,12 @@ function hash32(key, seed) {
28
28
  var c2 = 0x1b873593;
29
29
  for (var i = 0; i < bytes; i = i + 4) {
30
30
  k1 = ((key.charCodeAt(i) & 0xff)) | ((key.charCodeAt(i + 1) & 0xff) << 8) | ((key.charCodeAt(i + 2) & 0xff) << 16) | ((key.charCodeAt(i + 3) & 0xff) << 24);
31
- k1 = common_1.x86Multiply(k1, c1);
32
- k1 = common_1.x86Rotl(k1, 15);
33
- k1 = common_1.x86Multiply(k1, c2);
31
+ k1 = (0, common_1.x86Multiply)(k1, c1);
32
+ k1 = (0, common_1.x86Rotl)(k1, 15);
33
+ k1 = (0, common_1.x86Multiply)(k1, c2);
34
34
  h1 ^= k1;
35
- h1 = common_1.x86Rotl(h1, 13);
36
- h1 = common_1.x86Multiply(h1, 5) + 0xe6546b64;
35
+ h1 = (0, common_1.x86Rotl)(h1, 13);
36
+ h1 = (0, common_1.x86Multiply)(h1, 5) + 0xe6546b64;
37
37
  }
38
38
  k1 = 0;
39
39
  switch (remainder) {
@@ -43,17 +43,17 @@ function hash32(key, seed) {
43
43
  k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
44
44
  case 1:
45
45
  k1 ^= (key.charCodeAt(i) & 0xff);
46
- k1 = common_1.x86Multiply(k1, c1);
47
- k1 = common_1.x86Rotl(k1, 15);
48
- k1 = common_1.x86Multiply(k1, c2);
46
+ k1 = (0, common_1.x86Multiply)(k1, c1);
47
+ k1 = (0, common_1.x86Rotl)(k1, 15);
48
+ k1 = (0, common_1.x86Multiply)(k1, c2);
49
49
  h1 ^= k1;
50
50
  }
51
51
  h1 ^= key.length;
52
- h1 = common_1.x86Fmix(h1);
52
+ h1 = (0, common_1.x86Fmix)(h1);
53
53
  return h1 >>> 0;
54
54
  }
55
55
  function hash(str, seed) {
56
- return hash32(common_1.UTF16ToUTF8(str), seed >>> 0);
56
+ return hash32((0, common_1.UTF16ToUTF8)(str), seed >>> 0);
57
57
  }
58
58
  exports.hash = hash;
59
59
  function bucket(str, seed) {
@@ -214,6 +214,6 @@ function hash128x64(key, seed) {
214
214
  * @param {string} str
215
215
  */
216
216
  function hash128(str, seed) {
217
- return hash128x64(common_1.UTF16ToUTF8(str), seed >>> 0);
217
+ return hash128x64((0, common_1.UTF16ToUTF8)(str), seed >>> 0);
218
218
  }
219
219
  exports.hash128 = hash128;