@lowentry/utils 1.4.1 → 1.5.1
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/LeUtils.js +18 -11
- package/package.json +1 -1
package/LeUtils.js
CHANGED
|
@@ -1593,6 +1593,7 @@ export const LeUtils = {
|
|
|
1593
1593
|
/**
|
|
1594
1594
|
* Generates a base64 string (with +/ replaced by -_) of the current time (in milliseconds since 1970).
|
|
1595
1595
|
*
|
|
1596
|
+
* @param {number} [now] Optional time to use instead of the current time. If not set, the current time will be used.
|
|
1596
1597
|
* @returns {string}
|
|
1597
1598
|
*/
|
|
1598
1599
|
timestamp:
|
|
@@ -1612,21 +1613,27 @@ export const LeUtils = {
|
|
|
1612
1613
|
return bytes;
|
|
1613
1614
|
};
|
|
1614
1615
|
|
|
1615
|
-
return () =>
|
|
1616
|
+
return (now = null) =>
|
|
1616
1617
|
{
|
|
1617
|
-
|
|
1618
|
-
try
|
|
1618
|
+
if(ISSET(now))
|
|
1619
1619
|
{
|
|
1620
|
-
|
|
1621
|
-
now = (performance.timeOrigin || performance.timing.navigationStart) + performance.now();
|
|
1622
|
-
if(typeof now !== 'number')
|
|
1623
|
-
{
|
|
1624
|
-
throw new Error();
|
|
1625
|
-
}
|
|
1620
|
+
now = FLOAT_LAX(now);
|
|
1626
1621
|
}
|
|
1627
|
-
|
|
1622
|
+
else
|
|
1628
1623
|
{
|
|
1629
|
-
|
|
1624
|
+
try
|
|
1625
|
+
{
|
|
1626
|
+
// noinspection JSDeprecatedSymbols
|
|
1627
|
+
now = (performance.timeOrigin || performance.timing.navigationStart) + performance.now();
|
|
1628
|
+
if(typeof now !== 'number')
|
|
1629
|
+
{
|
|
1630
|
+
throw new Error();
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
catch(e)
|
|
1634
|
+
{
|
|
1635
|
+
now = (Date.now ? Date.now() : (new Date()).getTime());
|
|
1636
|
+
}
|
|
1630
1637
|
}
|
|
1631
1638
|
now = Math.round(now);
|
|
1632
1639
|
const nowBytes = numberToBytes(now);
|