@cripty2001/utils 0.0.150 → 0.0.152
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.js +2 -2
- package/dist/react-whispr.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -204,10 +204,10 @@ function getEnv(key, defaultValue) {
|
|
|
204
204
|
return value;
|
|
205
205
|
}
|
|
206
206
|
const [currentTsMs, setCurrentTsMs] = whispr_1.Whispr.create(Date.now());
|
|
207
|
-
|
|
207
|
+
let currentTsMsInterval = null;
|
|
208
208
|
const CURRENT_TS_MS = () => {
|
|
209
209
|
if (currentTsMsInterval === null) {
|
|
210
|
-
setInterval(() => {
|
|
210
|
+
currentTsMsInterval = setInterval(() => {
|
|
211
211
|
setCurrentTsMs(Date.now());
|
|
212
212
|
}, 200);
|
|
213
213
|
}
|
package/dist/react-whispr.js
CHANGED
|
@@ -224,7 +224,7 @@ function useRelTime(_data) {
|
|
|
224
224
|
const toReturn = useSafeRef(() => whispr_1.Whispr.from({ data, curr: (0, _1.CURRENT_TS_MS)() }, ({ data, curr }) => {
|
|
225
225
|
const then = data instanceof Date ? data.getTime() : data;
|
|
226
226
|
const seconds = Math.round(then - curr) / 1000;
|
|
227
|
-
const { base, unit } =
|
|
227
|
+
const { base, unit } = getRelTimeFormat(seconds);
|
|
228
228
|
const rounded = seconds > 0 ?
|
|
229
229
|
Math.floor(seconds / base) :
|
|
230
230
|
Math.ceil(seconds / base);
|
|
@@ -232,7 +232,7 @@ function useRelTime(_data) {
|
|
|
232
232
|
}));
|
|
233
233
|
return useWhisprValue(toReturn);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function getRelTimeFormat(_diff) {
|
|
236
236
|
const diff = Math.abs(_diff);
|
|
237
237
|
const breakpoints = [
|
|
238
238
|
{
|
package/package.json
CHANGED