@posthog/core 1.0.0 → 1.0.1
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/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -17
- package/dist/index.mjs +16 -17
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +21 -2
- package/dist/types.mjs +17 -1
- package/dist/utils/bucketed-rate-limiter.d.ts +21 -0
- package/dist/utils/bucketed-rate-limiter.d.ts.map +1 -0
- package/dist/utils/bucketed-rate-limiter.js +73 -0
- package/dist/utils/bucketed-rate-limiter.mjs +39 -0
- package/dist/{utils.d.ts → utils/index.d.ts} +6 -2
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +225 -0
- package/dist/{utils.mjs → utils/index.mjs} +4 -0
- package/dist/utils/number-utils.d.ts +11 -0
- package/dist/utils/number-utils.d.ts.map +1 -0
- package/dist/utils/number-utils.js +52 -0
- package/dist/utils/number-utils.mjs +18 -0
- package/dist/utils/string-utils.d.ts +6 -0
- package/dist/utils/string-utils.d.ts.map +1 -0
- package/dist/utils/string-utils.js +59 -0
- package/dist/utils/string-utils.mjs +16 -0
- package/dist/utils/type-utils.d.ts +19 -0
- package/dist/utils/type-utils.d.ts.map +1 -0
- package/dist/utils/type-utils.js +113 -0
- package/dist/utils/type-utils.mjs +31 -0
- package/package.json +4 -4
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -115
package/dist/utils.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: definition[key]
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
})();
|
|
11
|
-
(()=>{
|
|
12
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
-
})();
|
|
14
|
-
(()=>{
|
|
15
|
-
__webpack_require__.r = (exports1)=>{
|
|
16
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
-
value: 'Module'
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
-
value: true
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
})();
|
|
24
|
-
var __webpack_exports__ = {};
|
|
25
|
-
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
STRING_FORMAT: ()=>STRING_FORMAT,
|
|
28
|
-
allSettled: ()=>allSettled,
|
|
29
|
-
assert: ()=>assert,
|
|
30
|
-
currentISOTime: ()=>currentISOTime,
|
|
31
|
-
currentTimestamp: ()=>currentTimestamp,
|
|
32
|
-
getFetch: ()=>getFetch,
|
|
33
|
-
isError: ()=>isError,
|
|
34
|
-
isPromise: ()=>isPromise,
|
|
35
|
-
removeTrailingSlash: ()=>removeTrailingSlash,
|
|
36
|
-
retriable: ()=>retriable,
|
|
37
|
-
safeSetTimeout: ()=>safeSetTimeout
|
|
38
|
-
});
|
|
39
|
-
const STRING_FORMAT = 'utf8';
|
|
40
|
-
function assert(truthyValue, message) {
|
|
41
|
-
if (!truthyValue || 'string' != typeof truthyValue || isEmpty(truthyValue)) throw new Error(message);
|
|
42
|
-
}
|
|
43
|
-
function isEmpty(truthyValue) {
|
|
44
|
-
if (0 === truthyValue.trim().length) return true;
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
function removeTrailingSlash(url) {
|
|
48
|
-
return null == url ? void 0 : url.replace(/\/+$/, '');
|
|
49
|
-
}
|
|
50
|
-
async function retriable(fn, props) {
|
|
51
|
-
let lastError = null;
|
|
52
|
-
for(let i = 0; i < props.retryCount + 1; i++){
|
|
53
|
-
if (i > 0) await new Promise((r)=>setTimeout(r, props.retryDelay));
|
|
54
|
-
try {
|
|
55
|
-
const res = await fn();
|
|
56
|
-
return res;
|
|
57
|
-
} catch (e) {
|
|
58
|
-
lastError = e;
|
|
59
|
-
if (!props.retryCheck(e)) throw e;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
throw lastError;
|
|
63
|
-
}
|
|
64
|
-
function currentTimestamp() {
|
|
65
|
-
return new Date().getTime();
|
|
66
|
-
}
|
|
67
|
-
function currentISOTime() {
|
|
68
|
-
return new Date().toISOString();
|
|
69
|
-
}
|
|
70
|
-
function safeSetTimeout(fn, timeout) {
|
|
71
|
-
const t = setTimeout(fn, timeout);
|
|
72
|
-
(null == t ? void 0 : t.unref) && (null == t || t.unref());
|
|
73
|
-
return t;
|
|
74
|
-
}
|
|
75
|
-
const isPromise = (obj)=>obj && 'function' == typeof obj.then;
|
|
76
|
-
const isError = (x)=>x instanceof Error;
|
|
77
|
-
function getFetch() {
|
|
78
|
-
return 'undefined' != typeof fetch ? fetch : void 0 !== globalThis.fetch ? globalThis.fetch : void 0;
|
|
79
|
-
}
|
|
80
|
-
function allSettled(promises) {
|
|
81
|
-
return Promise.all(promises.map((p)=>(null != p ? p : Promise.resolve()).then((value)=>({
|
|
82
|
-
status: 'fulfilled',
|
|
83
|
-
value
|
|
84
|
-
}), (reason)=>({
|
|
85
|
-
status: 'rejected',
|
|
86
|
-
reason
|
|
87
|
-
}))));
|
|
88
|
-
}
|
|
89
|
-
exports.STRING_FORMAT = __webpack_exports__.STRING_FORMAT;
|
|
90
|
-
exports.allSettled = __webpack_exports__.allSettled;
|
|
91
|
-
exports.assert = __webpack_exports__.assert;
|
|
92
|
-
exports.currentISOTime = __webpack_exports__.currentISOTime;
|
|
93
|
-
exports.currentTimestamp = __webpack_exports__.currentTimestamp;
|
|
94
|
-
exports.getFetch = __webpack_exports__.getFetch;
|
|
95
|
-
exports.isError = __webpack_exports__.isError;
|
|
96
|
-
exports.isPromise = __webpack_exports__.isPromise;
|
|
97
|
-
exports.removeTrailingSlash = __webpack_exports__.removeTrailingSlash;
|
|
98
|
-
exports.retriable = __webpack_exports__.retriable;
|
|
99
|
-
exports.safeSetTimeout = __webpack_exports__.safeSetTimeout;
|
|
100
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
101
|
-
"STRING_FORMAT",
|
|
102
|
-
"allSettled",
|
|
103
|
-
"assert",
|
|
104
|
-
"currentISOTime",
|
|
105
|
-
"currentTimestamp",
|
|
106
|
-
"getFetch",
|
|
107
|
-
"isError",
|
|
108
|
-
"isPromise",
|
|
109
|
-
"removeTrailingSlash",
|
|
110
|
-
"retriable",
|
|
111
|
-
"safeSetTimeout"
|
|
112
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
113
|
-
Object.defineProperty(exports, '__esModule', {
|
|
114
|
-
value: true
|
|
115
|
-
});
|