hotfix throttle function args
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rrweb",
|
||||
"version": "0.7.20",
|
||||
"version": "0.7.21",
|
||||
"description": "record and replay the web",
|
||||
"scripts": {
|
||||
"test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.test.ts",
|
||||
|
||||
@@ -53,13 +53,14 @@ export function throttle<T>(
|
||||
let timeout: number | null = null;
|
||||
let previous = 0;
|
||||
// tslint:disable-next-line: only-arrow-functions
|
||||
return function(args: T) {
|
||||
return function(arg: T) {
|
||||
let now = Date.now();
|
||||
if (!previous && options.leading === false) {
|
||||
previous = now;
|
||||
}
|
||||
let remaining = wait - (now - previous);
|
||||
let context = this;
|
||||
let args = arguments;
|
||||
if (remaining <= 0 || remaining > wait) {
|
||||
if (timeout) {
|
||||
window.clearTimeout(timeout);
|
||||
|
||||
2
typings/utils.d.ts
vendored
2
typings/utils.d.ts
vendored
@@ -2,7 +2,7 @@ import { Mirror, throttleOptions, listenerHandler, hookResetter, blockClass } fr
|
||||
import { INode } from 'rrweb-snapshot';
|
||||
export declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | Window): listenerHandler;
|
||||
export declare const mirror: Mirror;
|
||||
export declare function throttle<T>(func: (arg: T) => void, wait: number, options?: throttleOptions): (args: T) => void;
|
||||
export declare function throttle<T>(func: (arg: T) => void, wait: number, options?: throttleOptions): () => void;
|
||||
export declare function hookSetter<T>(target: T, key: string | number | symbol, d: PropertyDescriptor, isRevoked?: boolean): hookResetter;
|
||||
export declare function getWindowHeight(): number;
|
||||
export declare function getWindowWidth(): number;
|
||||
|
||||
Reference in New Issue
Block a user