@cripty2001/utils 0.0.134 → 0.0.135

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.
@@ -166,7 +166,8 @@ function useAsync(f, data, debouce = 200) {
166
166
  function useRelTime(refresh = 1000) {
167
167
  const currTs = useCurrentTimestamp(refresh);
168
168
  const rtf = (0, react_1.useRef)(new Intl.RelativeTimeFormat(navigator.language, { numeric: "auto" })).current;
169
- const getFormat = (diff) => {
169
+ const getFormat = (_diff) => {
170
+ const diff = Math.abs(_diff);
170
171
  const breakpoints = [
171
172
  { limit: 60, unit: "second" },
172
173
  { limit: 3600, unit: "minute" },
@@ -191,8 +192,10 @@ function useRelTime(refresh = 1000) {
191
192
  const delta = then - now;
192
193
  const seconds = Math.round(delta / 1000);
193
194
  const { limit, unit } = getFormat(seconds);
194
- console.log("format", Math.floor(seconds / limit), unit);
195
- return rtf.format(Math.floor(seconds / limit), unit);
195
+ const rounded = seconds > 0 ?
196
+ Math.floor(seconds / limit) :
197
+ Math.ceil(seconds / limit);
198
+ return rtf.format(rounded, unit);
196
199
  }, [currTs, rtf]);
197
200
  return cb;
198
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.134",
3
+ "version": "0.0.135",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {