@lowentry/utils 1.23.3 → 1.24.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowentry/utils",
3
- "version": "1.23.3",
3
+ "version": "1.24.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/LeUtils.js CHANGED
@@ -158,10 +158,13 @@ export const LeUtils = {
158
158
  return a.toString() === b.toString();
159
159
  }
160
160
 
161
- const proto = Object.getPrototypeOf(a);
162
- if((a.constructor !== Object) && (a.constructor !== Array) && (proto !== Object.prototype) && (typeof a.equals === 'function'))
161
+ if(a.constructor && (a.constructor !== Object) && (a.constructor !== Array) && (Object.getPrototypeOf(a) !== Object.prototype))
163
162
  {
164
- return a.equals(b);
163
+ if(typeof a.equals === 'function')
164
+ {
165
+ return a.equals(b);
166
+ }
167
+ return false;
165
168
  }
166
169
 
167
170
  const keys = Object.keys(a);
@@ -1705,27 +1708,34 @@ export const LeUtils = {
1705
1708
 
1706
1709
  let run = true;
1707
1710
  let requestAnimationFrameId = null;
1708
- let lastTime = globalThis?.performance?.now?.() ?? 0;
1711
+ let lastTimestamp = 0;
1712
+ let totalTime = 0;
1709
1713
  let frames = intervalFrames;
1710
- const tick = () =>
1714
+ const tick = (timestamp) =>
1711
1715
  {
1712
1716
  if(run)
1713
1717
  {
1718
+ if(lastTimestamp === 0)
1719
+ {
1720
+ lastTimestamp = timestamp;
1721
+ }
1722
+ totalTime += (timestamp - lastTimestamp);
1723
+ lastTimestamp = timestamp;
1724
+
1725
+ frames--;
1714
1726
  if(frames <= 0)
1715
1727
  {
1716
- let currentTime = globalThis?.performance?.now?.() ?? 0;
1717
1728
  try
1718
1729
  {
1719
- callback((currentTime - lastTime) / 1000);
1730
+ callback(totalTime / 1000);
1720
1731
  }
1721
1732
  catch(e)
1722
1733
  {
1723
1734
  console.error(e);
1724
1735
  }
1725
- lastTime = currentTime;
1736
+ totalTime = 0;
1726
1737
  frames = intervalFrames;
1727
1738
  }
1728
- frames--;
1729
1739
 
1730
1740
  if(run)
1731
1741
  {