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