@suprsend/web-sdk 1.1.0 → 1.2.0
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.
- package/dist/cdn_bundle.js +1 -1
- package/dist/cjs_bundle.js +1 -1
- package/package.json +3 -2
- package/src/config.js +3 -2
- package/src/encryption.js +12 -5
- package/src/index.d.ts +113 -0
- package/src/index.js +10 -2
- package/src/preferences.js +474 -0
- package/src/user.js +3 -1
- package/src/utils.js +30 -0
package/src/utils.js
CHANGED
|
@@ -257,6 +257,35 @@ const is_empty = (value) => {
|
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
259
|
|
|
260
|
+
function debounce(func, timeOut) {
|
|
261
|
+
let timer;
|
|
262
|
+
|
|
263
|
+
return (...args) => {
|
|
264
|
+
if (timer) clearTimeout(timer);
|
|
265
|
+
timer = setTimeout(() => {
|
|
266
|
+
func.apply(this, args);
|
|
267
|
+
}, timeOut);
|
|
268
|
+
return timer;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// https://gist.github.com/nzvtrk/1a444cdf6a86a5a6e6d6a34f0db19065
|
|
273
|
+
function debounce_by_type(func, wait, options) {
|
|
274
|
+
const memory = {};
|
|
275
|
+
|
|
276
|
+
return (...args) => {
|
|
277
|
+
const [searchType] = args;
|
|
278
|
+
const payload = args.slice(1);
|
|
279
|
+
|
|
280
|
+
if (typeof memory[searchType] === "function") {
|
|
281
|
+
return memory[searchType](...payload);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
memory[searchType] = debounce(func, wait, { ...options, leading: true });
|
|
285
|
+
return memory[searchType](...payload);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
260
289
|
export default {
|
|
261
290
|
uuid,
|
|
262
291
|
epoch_milliseconds,
|
|
@@ -281,4 +310,5 @@ export default {
|
|
|
281
310
|
bulk_call_api,
|
|
282
311
|
is_internal_event,
|
|
283
312
|
api,
|
|
313
|
+
debounce_by_type,
|
|
284
314
|
};
|