mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Use Date.now.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import isObject from './isObject.js';
|
import isObject from './isObject.js';
|
||||||
import now from './now.js';
|
|
||||||
import toNumber from './toNumber.js';
|
import toNumber from './toNumber.js';
|
||||||
|
|
||||||
/** Error message constants. */
|
/** Error message constants. */
|
||||||
@@ -125,7 +124,7 @@ function debounce(func, wait, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function timerExpired() {
|
function timerExpired() {
|
||||||
const time = now();
|
const time = Date.now();
|
||||||
if (shouldInvoke(time)) {
|
if (shouldInvoke(time)) {
|
||||||
return trailingEdge(time);
|
return trailingEdge(time);
|
||||||
}
|
}
|
||||||
@@ -154,11 +153,11 @@ function debounce(func, wait, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function flush() {
|
function flush() {
|
||||||
return timerId === undefined ? result : trailingEdge(now());
|
return timerId === undefined ? result : trailingEdge(Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
function debounced(...args) {
|
function debounced(...args) {
|
||||||
const time = now();
|
const time = Date.now();
|
||||||
const isInvoking = shouldInvoke(time);
|
const isInvoking = shouldInvoke(time);
|
||||||
|
|
||||||
lastArgs = args;
|
lastArgs = args;
|
||||||
|
|||||||
20
now.js
20
now.js
@@ -1,20 +0,0 @@
|
|||||||
import root from './_root.js';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
||||||
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @since 2.4.0
|
|
||||||
* @category Date
|
|
||||||
* @returns {number} Returns the timestamp.
|
|
||||||
* @example
|
|
||||||
*
|
|
||||||
* defer(function(stamp) {
|
|
||||||
* console.log(now() - stamp);
|
|
||||||
* }, now());
|
|
||||||
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
||||||
*/
|
|
||||||
const now = () => root.Date.now();
|
|
||||||
|
|
||||||
export default now;
|
|
||||||
Reference in New Issue
Block a user