@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/index.js CHANGED
@@ -361,9 +361,11 @@ var LeUtils = {
361
361
  if (a.toString !== Object.prototype.toString) {
362
362
  return a.toString() === b.toString();
363
363
  }
364
- var proto = Object.getPrototypeOf(a);
365
- if (a.constructor !== Object && a.constructor !== Array && proto !== Object.prototype && typeof a.equals === 'function') {
366
- return a.equals(b);
364
+ if (a.constructor && a.constructor !== Object && a.constructor !== Array && Object.getPrototypeOf(a) !== Object.prototype) {
365
+ if (typeof a.equals === 'function') {
366
+ return a.equals(b);
367
+ }
368
+ return false;
367
369
  }
368
370
  var keys = Object.keys(a);
369
371
  var length = keys.length;
@@ -1865,7 +1867,6 @@ var LeUtils = {
1865
1867
  * @returns {{remove:Function}}
1866
1868
  */
1867
1869
  setAnimationFrameInterval: function setAnimationFrameInterval(callback) {
1868
- var _globalThis$performan17, _globalThis$performan18, _globalThis$performan19;
1869
1870
  var intervalFrames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1870
1871
  var fireImmediately = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1871
1872
  intervalFrames = INT_LAX_ANY(intervalFrames, 1);
@@ -1884,22 +1885,26 @@ var LeUtils = {
1884
1885
  }
1885
1886
  var run = true;
1886
1887
  var requestAnimationFrameId = null;
1887
- var lastTime = (_globalThis$performan17 = globalThis === null || globalThis === void 0 || (_globalThis$performan18 = globalThis.performance) === null || _globalThis$performan18 === void 0 || (_globalThis$performan19 = _globalThis$performan18.now) === null || _globalThis$performan19 === void 0 ? void 0 : _globalThis$performan19.call(_globalThis$performan18)) !== null && _globalThis$performan17 !== void 0 ? _globalThis$performan17 : 0;
1888
+ var lastTimestamp = 0;
1889
+ var totalTime = 0;
1888
1890
  var frames = intervalFrames;
1889
- var _tick2 = function tick() {
1891
+ var _tick2 = function tick(timestamp) {
1890
1892
  if (run) {
1893
+ if (lastTimestamp === 0) {
1894
+ lastTimestamp = timestamp;
1895
+ }
1896
+ totalTime += timestamp - lastTimestamp;
1897
+ lastTimestamp = timestamp;
1898
+ frames--;
1891
1899
  if (frames <= 0) {
1892
- var _globalThis$performan20, _globalThis$performan21, _globalThis$performan22;
1893
- var currentTime = (_globalThis$performan20 = globalThis === null || globalThis === void 0 || (_globalThis$performan21 = globalThis.performance) === null || _globalThis$performan21 === void 0 || (_globalThis$performan22 = _globalThis$performan21.now) === null || _globalThis$performan22 === void 0 ? void 0 : _globalThis$performan22.call(_globalThis$performan21)) !== null && _globalThis$performan20 !== void 0 ? _globalThis$performan20 : 0;
1894
1900
  try {
1895
- callback((currentTime - lastTime) / 1000);
1901
+ callback(totalTime / 1000);
1896
1902
  } catch (e) {
1897
1903
  console.error(e);
1898
1904
  }
1899
- lastTime = currentTime;
1905
+ totalTime = 0;
1900
1906
  frames = intervalFrames;
1901
1907
  }
1902
- frames--;
1903
1908
  if (run) {
1904
1909
  requestAnimationFrameId = globalThis.requestAnimationFrame(_tick2);
1905
1910
  }
@@ -2476,9 +2481,9 @@ var LeUtils = {
2476
2481
  var generateUniqueId = function generateUniqueId() {
2477
2482
  var now;
2478
2483
  try {
2479
- var _globalThis$performan23, _globalThis$performan24, _globalThis$performan25, _globalThis$performan26, _globalThis$performan27;
2484
+ var _globalThis$performan17, _globalThis$performan18, _globalThis$performan19, _globalThis$performan20, _globalThis$performan21;
2480
2485
  // noinspection JSDeprecatedSymbols
2481
- now = ((globalThis === null || globalThis === void 0 || (_globalThis$performan23 = globalThis.performance) === null || _globalThis$performan23 === void 0 ? void 0 : _globalThis$performan23.timeOrigin) || (globalThis === null || globalThis === void 0 || (_globalThis$performan24 = globalThis.performance) === null || _globalThis$performan24 === void 0 || (_globalThis$performan24 = _globalThis$performan24.timing) === null || _globalThis$performan24 === void 0 ? void 0 : _globalThis$performan24.navigationStart) || 0) + ((_globalThis$performan25 = globalThis === null || globalThis === void 0 || (_globalThis$performan26 = globalThis.performance) === null || _globalThis$performan26 === void 0 || (_globalThis$performan27 = _globalThis$performan26.now) === null || _globalThis$performan27 === void 0 ? void 0 : _globalThis$performan27.call(_globalThis$performan26)) !== null && _globalThis$performan25 !== void 0 ? _globalThis$performan25 : 0);
2486
+ now = ((globalThis === null || globalThis === void 0 || (_globalThis$performan17 = globalThis.performance) === null || _globalThis$performan17 === void 0 ? void 0 : _globalThis$performan17.timeOrigin) || (globalThis === null || globalThis === void 0 || (_globalThis$performan18 = globalThis.performance) === null || _globalThis$performan18 === void 0 || (_globalThis$performan18 = _globalThis$performan18.timing) === null || _globalThis$performan18 === void 0 ? void 0 : _globalThis$performan18.navigationStart) || 0) + ((_globalThis$performan19 = globalThis === null || globalThis === void 0 || (_globalThis$performan20 = globalThis.performance) === null || _globalThis$performan20 === void 0 || (_globalThis$performan21 = _globalThis$performan20.now) === null || _globalThis$performan21 === void 0 ? void 0 : _globalThis$performan21.call(_globalThis$performan20)) !== null && _globalThis$performan19 !== void 0 ? _globalThis$performan19 : 0);
2482
2487
  } catch (e) {}
2483
2488
  now = now || (Date.now ? Date.now() : new Date().getTime());
2484
2489
  now = Math.round(now);