@lowentry/utils 1.13.3 → 1.13.5

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
@@ -1198,15 +1198,7 @@ var LeUtils = {
1198
1198
  * @param {number} ms
1199
1199
  * @returns {{remove:Function}}
1200
1200
  */
1201
- setTimeout: function (_setTimeout) {
1202
- function setTimeout(_x9, _x10) {
1203
- return _setTimeout.apply(this, arguments);
1204
- }
1205
- setTimeout.toString = function () {
1206
- return _setTimeout.toString();
1207
- };
1208
- return setTimeout;
1209
- }(function (callback, ms) {
1201
+ setTimeout: function setTimeout(callback, ms) {
1210
1202
  if (typeof window === 'undefined') {
1211
1203
  return {
1212
1204
  remove: function remove() {}
@@ -1214,7 +1206,7 @@ var LeUtils = {
1214
1206
  }
1215
1207
  ms = FLOAT_LAX(ms);
1216
1208
  var lastTime = performance.now();
1217
- var handler = setTimeout(function () {
1209
+ var handler = window.setTimeout(function () {
1218
1210
  var currentTime = performance.now();
1219
1211
  try {
1220
1212
  callback((currentTime - lastTime) / 1000);
@@ -1226,12 +1218,12 @@ var LeUtils = {
1226
1218
  return {
1227
1219
  remove: function remove() {
1228
1220
  if (handler !== null) {
1229
- clearTimeout(handler);
1221
+ window.clearTimeout(handler);
1230
1222
  handler = null;
1231
1223
  }
1232
1224
  }
1233
1225
  };
1234
- }),
1226
+ },
1235
1227
  /**
1236
1228
  * @callback LeUtils~__setIntervalCallback
1237
1229
  * @param {number} deltaTime
@@ -1246,15 +1238,7 @@ var LeUtils = {
1246
1238
  * @param {boolean} [fireImmediately]
1247
1239
  * @returns {{remove:Function}}
1248
1240
  */
1249
- setInterval: function (_setInterval) {
1250
- function setInterval(_x11) {
1251
- return _setInterval.apply(this, arguments);
1252
- }
1253
- setInterval.toString = function () {
1254
- return _setInterval.toString();
1255
- };
1256
- return setInterval;
1257
- }(function (callback) {
1241
+ setInterval: function setInterval(callback) {
1258
1242
  var intervalMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
1259
1243
  var fireImmediately = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1260
1244
  intervalMs = FLOAT_LAX_ANY(intervalMs, 1000);
@@ -1271,7 +1255,7 @@ var LeUtils = {
1271
1255
  };
1272
1256
  }
1273
1257
  var lastTime = performance.now();
1274
- var handler = setInterval(function () {
1258
+ var handler = window.setInterval(function () {
1275
1259
  var currentTime = performance.now();
1276
1260
  try {
1277
1261
  callback((currentTime - lastTime) / 1000);
@@ -1283,12 +1267,12 @@ var LeUtils = {
1283
1267
  return {
1284
1268
  remove: function remove() {
1285
1269
  if (handler !== null) {
1286
- clearInterval(handler);
1270
+ window.clearInterval(handler);
1287
1271
  handler = null;
1288
1272
  }
1289
1273
  }
1290
1274
  };
1291
- }),
1275
+ },
1292
1276
  /**
1293
1277
  * @callback LeUtils~__setAnimationFrameTimeoutCallback
1294
1278
  * @param {number} deltaTime
@@ -1328,7 +1312,7 @@ var LeUtils = {
1328
1312
  return;
1329
1313
  }
1330
1314
  frames--;
1331
- requestAnimationFrameId = typeof window === 'undefined' ? setTimeout(_tick, 1000 / 60) : requestAnimationFrame(_tick);
1315
+ requestAnimationFrameId = window.requestAnimationFrame(_tick);
1332
1316
  }
1333
1317
  };
1334
1318
  _tick();
@@ -1336,7 +1320,7 @@ var LeUtils = {
1336
1320
  remove: function remove() {
1337
1321
  run = false;
1338
1322
  if (requestAnimationFrameId !== null) {
1339
- typeof window === 'undefined' ? clearTimeout(requestAnimationFrameId) : cancelAnimationFrame(requestAnimationFrameId);
1323
+ window.cancelAnimationFrame(requestAnimationFrameId);
1340
1324
  requestAnimationFrameId = null;
1341
1325
  }
1342
1326
  }
@@ -1390,16 +1374,16 @@ var LeUtils = {
1390
1374
  }
1391
1375
  frames--;
1392
1376
  if (run) {
1393
- requestAnimationFrameId = typeof window === 'undefined' ? setTimeout(_tick2, 1000 / 60) : requestAnimationFrame(_tick2);
1377
+ requestAnimationFrameId = window.requestAnimationFrame(_tick2);
1394
1378
  }
1395
1379
  }
1396
1380
  };
1397
- typeof window === 'undefined' ? setTimeout(_tick2, 1000 / 60) : requestAnimationFrame(_tick2);
1381
+ window.requestAnimationFrame(_tick2);
1398
1382
  return {
1399
1383
  remove: function remove() {
1400
1384
  run = false;
1401
1385
  if (requestAnimationFrameId !== null) {
1402
- typeof window === 'undefined' ? clearTimeout(requestAnimationFrameId) : cancelAnimationFrame(requestAnimationFrameId);
1386
+ window.cancelAnimationFrame(requestAnimationFrameId);
1403
1387
  requestAnimationFrameId = null;
1404
1388
  }
1405
1389
  }
@@ -1415,11 +1399,11 @@ var LeUtils = {
1415
1399
  ms = FLOAT_LAX(ms);
1416
1400
  if (ms <= 0) {
1417
1401
  return new Promise(function (resolve) {
1418
- return resolve();
1402
+ return resolve(undefined);
1419
1403
  });
1420
1404
  }
1421
1405
  return new Promise(function (resolve) {
1422
- return setTimeout(resolve, ms);
1406
+ return LeUtils.setTimeout(resolve, ms);
1423
1407
  });
1424
1408
  },
1425
1409
  /**
@@ -1432,7 +1416,7 @@ var LeUtils = {
1432
1416
  frames = INT_LAX(frames);
1433
1417
  if (frames <= 0) {
1434
1418
  return new Promise(function (resolve) {
1435
- return resolve();
1419
+ return resolve(undefined);
1436
1420
  });
1437
1421
  }
1438
1422
  return new Promise(function (resolve) {
@@ -1447,7 +1431,7 @@ var LeUtils = {
1447
1431
  * @returns {{then:Function, catch:Function, finally:Function, remove:Function, isRemoved:Function}}
1448
1432
  */
1449
1433
  fetch: function (_fetch) {
1450
- function fetch(_x12, _x13) {
1434
+ function fetch(_x9, _x10) {
1451
1435
  return _fetch.apply(this, arguments);
1452
1436
  }
1453
1437
  fetch.toString = function () {
@@ -2331,7 +2315,7 @@ var LeUtils = {
2331
2315
  * @returns {string}
2332
2316
  */
2333
2317
  btoa: function (_btoa) {
2334
- function btoa(_x14) {
2318
+ function btoa(_x11) {
2335
2319
  return _btoa.apply(this, arguments);
2336
2320
  }
2337
2321
  btoa.toString = function () {
@@ -2351,7 +2335,7 @@ var LeUtils = {
2351
2335
  * @returns {string}
2352
2336
  */
2353
2337
  atob: function (_atob) {
2354
- function atob(_x15) {
2338
+ function atob(_x12) {
2355
2339
  return _atob.apply(this, arguments);
2356
2340
  }
2357
2341
  atob.toString = function () {