@deot/helper-utils 1.0.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/README.md +33 -0
- package/dist/index.cjs.js +368 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.es.js +344 -0
- package/dist/index.iife.js +373 -0
- package/dist/index.umd.js +374 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @deot/helper-utils
|
|
2
|
+
|
|
3
|
+
### `Utils`
|
|
4
|
+
```js
|
|
5
|
+
import * as Utils from '@deot/helper-utils';
|
|
6
|
+
|
|
7
|
+
// or
|
|
8
|
+
import { Utils } from '@deot/helper';
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
| 方法 | 说明 |
|
|
13
|
+
| ------------------------------------------------------------------ | ----------------- |
|
|
14
|
+
| [asterisk][./src/asterisk.ts] | 文字加`*` |
|
|
15
|
+
| [autoCatch][./src/auto-catch.ts] | 捕获异常 |
|
|
16
|
+
| [canvasToImage][./src/canvas-to-image.ts] | 转图片信息 |
|
|
17
|
+
| [cloneDeepEasier][./src/clone-deep-easier.ts] | 深拷贝 |
|
|
18
|
+
| [compressImage][./src/compress-image.ts] | 压缩图片 |
|
|
19
|
+
| [dataURLToFile][./src/dataURL-to-file.ts] | base64转文件 |
|
|
20
|
+
| [debounce][./src/debounce.ts] | 防抖 |
|
|
21
|
+
| [def][./src/def.ts] | 定义 |
|
|
22
|
+
| [flattenDecodeURIComponent][./src/flatten-decode-uri-component.ts] | 深度解码 |
|
|
23
|
+
| [flattenJSONParse][./src/flatten-json-parse.ts] | 深度反序列化 |
|
|
24
|
+
| [getPropByPath][./src/get-prop-by-path.ts] | 根据路径找值 |
|
|
25
|
+
| [getUid][./src/get-uid.ts] | 生成唯一id |
|
|
26
|
+
| [hasOwn][./src/has-own.ts] | 是否在原型上 |
|
|
27
|
+
| [isObj][./src/is-obj.ts] | 是否对象 |
|
|
28
|
+
| [numberToUnit][./src/number-to-unit.ts] | 大数据转成中文单位 |
|
|
29
|
+
| [preZero][./src/pre-zero.ts] | 加零 |
|
|
30
|
+
| [raf][./src/raf.ts] | raf |
|
|
31
|
+
| [random][./src/random.ts] | `range` 和 `probs` |
|
|
32
|
+
| [sleep][./src/sleep.ts] | 等待 |
|
|
33
|
+
| [throttle][./src/throttle.ts] | 节流 |
|
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const asterisk = (value, from, length) => {
|
|
6
|
+
from = from || 3;
|
|
7
|
+
length = length || 4;
|
|
8
|
+
let repeat = length;
|
|
9
|
+
let content = value.substring(0, from);
|
|
10
|
+
while (repeat) {
|
|
11
|
+
content += "*";
|
|
12
|
+
repeat--;
|
|
13
|
+
}
|
|
14
|
+
content += value.substring(from + length);
|
|
15
|
+
return content;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const autoCatch = async (impl, options = {}) => {
|
|
19
|
+
const { onError = console.error } = options;
|
|
20
|
+
let target = impl;
|
|
21
|
+
typeof target === "function" && (target = target());
|
|
22
|
+
try {
|
|
23
|
+
const e = await target;
|
|
24
|
+
return e;
|
|
25
|
+
} catch (e) {
|
|
26
|
+
onError(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const getMime = (filename) => {
|
|
31
|
+
let ext;
|
|
32
|
+
if (typeof filename === "string" && filename.includes(".")) {
|
|
33
|
+
ext = filename.split(".").pop();
|
|
34
|
+
}
|
|
35
|
+
return ext ? `image/${ext}` : "image/jpeg";
|
|
36
|
+
};
|
|
37
|
+
const dataURLToFile = (dataURL, filename, filetype) => {
|
|
38
|
+
const hasPrefix = /data:[^;]+;[^,]+,/g.test(dataURL);
|
|
39
|
+
if (!hasPrefix) {
|
|
40
|
+
dataURL = `data:${filetype || getMime(filename)};base64,${dataURL}`;
|
|
41
|
+
}
|
|
42
|
+
let [suffix, dataURL$] = dataURL.split(",");
|
|
43
|
+
let mime = suffix.match(/:(.*?);/)?.[1];
|
|
44
|
+
let bstr = window.atob(dataURL$);
|
|
45
|
+
let n = bstr.length;
|
|
46
|
+
let u8arr = new Uint8Array(n);
|
|
47
|
+
while (n--) {
|
|
48
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
49
|
+
}
|
|
50
|
+
return new File([u8arr], filename || "__filename", { type: mime });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const canvasToImage = (canvas, filename) => {
|
|
54
|
+
const dataURL = canvas.toDataURL("image/png");
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
let result = {
|
|
57
|
+
dataURL
|
|
58
|
+
};
|
|
59
|
+
if (typeof filename === "string") {
|
|
60
|
+
result.file = dataURLToFile(dataURL, filename);
|
|
61
|
+
}
|
|
62
|
+
resolve(result);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const cloneDeepEasier = (source) => JSON.parse(JSON.stringify(source));
|
|
67
|
+
|
|
68
|
+
const compressImage = (file, options) => {
|
|
69
|
+
const { width, height, filetype = "image/jpeg", encoderOptions } = options || {};
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
const el = new Image();
|
|
72
|
+
const reader = new FileReader();
|
|
73
|
+
reader.readAsDataURL(file);
|
|
74
|
+
reader.onload = (e) => {
|
|
75
|
+
el.src = e.target.result;
|
|
76
|
+
};
|
|
77
|
+
const canvas = document.createElement("canvas");
|
|
78
|
+
const context = canvas.getContext("2d");
|
|
79
|
+
el.onload = () => {
|
|
80
|
+
const originWidth = el.width;
|
|
81
|
+
const originHeight = el.height;
|
|
82
|
+
const maxWidth = width || originWidth;
|
|
83
|
+
const maxHeight = height || originHeight;
|
|
84
|
+
let targetWidth = originWidth;
|
|
85
|
+
let targetHeight = originHeight;
|
|
86
|
+
if (originWidth > maxWidth || originHeight > maxHeight) {
|
|
87
|
+
if (originWidth / originHeight > maxWidth / maxHeight) {
|
|
88
|
+
targetWidth = maxWidth;
|
|
89
|
+
targetHeight = Math.round(maxWidth * (originHeight / originWidth));
|
|
90
|
+
} else {
|
|
91
|
+
targetHeight = maxHeight;
|
|
92
|
+
targetWidth = Math.round(maxHeight * (originWidth / originHeight));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
canvas.width = targetWidth;
|
|
96
|
+
canvas.height = targetHeight;
|
|
97
|
+
context.clearRect(0, 0, targetWidth, targetHeight);
|
|
98
|
+
context.drawImage(el, 0, 0, targetWidth, targetHeight);
|
|
99
|
+
const dataURL = canvas.toDataURL(filetype, encoderOptions);
|
|
100
|
+
const compressFile = dataURLToFile(dataURL, file.name);
|
|
101
|
+
resolve({
|
|
102
|
+
dataURL,
|
|
103
|
+
file: compressFile
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
el.onerror = (e) => {
|
|
107
|
+
reject(e);
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const debounce = (original, wait, options) => {
|
|
113
|
+
const { leading, trailing = true, throttle } = options || {};
|
|
114
|
+
let timer;
|
|
115
|
+
let invoke;
|
|
116
|
+
let cancel = () => {
|
|
117
|
+
timer && clearTimeout(timer);
|
|
118
|
+
timer = null;
|
|
119
|
+
};
|
|
120
|
+
let start = () => {
|
|
121
|
+
timer = setTimeout(() => {
|
|
122
|
+
timer = null;
|
|
123
|
+
trailing && invoke && invoke();
|
|
124
|
+
}, wait);
|
|
125
|
+
};
|
|
126
|
+
const fn = function(...args) {
|
|
127
|
+
invoke = () => {
|
|
128
|
+
original.apply(this, args);
|
|
129
|
+
invoke = null;
|
|
130
|
+
};
|
|
131
|
+
if (!wait && throttle)
|
|
132
|
+
return invoke();
|
|
133
|
+
if (!timer) {
|
|
134
|
+
leading && invoke();
|
|
135
|
+
start();
|
|
136
|
+
} else if (!throttle) {
|
|
137
|
+
cancel();
|
|
138
|
+
start();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
fn.cancel = () => {
|
|
142
|
+
cancel();
|
|
143
|
+
invoke = null;
|
|
144
|
+
};
|
|
145
|
+
fn.flush = () => {
|
|
146
|
+
cancel();
|
|
147
|
+
trailing && invoke && invoke();
|
|
148
|
+
};
|
|
149
|
+
return fn;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const def = (target, key, value, options) => {
|
|
153
|
+
Object.defineProperty(target, key, {
|
|
154
|
+
value,
|
|
155
|
+
enumerable: false,
|
|
156
|
+
writable: true,
|
|
157
|
+
configurable: true,
|
|
158
|
+
...options
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const getPropByPath = (target, path) => {
|
|
163
|
+
let o = target;
|
|
164
|
+
path = path.replace(/\[(\w+)\]/g, ".$1");
|
|
165
|
+
path = path.replace(/^\./, "");
|
|
166
|
+
let keyArr = path.split(".");
|
|
167
|
+
let i = 0;
|
|
168
|
+
for (let len = keyArr.length; i < len - 1; ++i) {
|
|
169
|
+
let key = keyArr[i];
|
|
170
|
+
try {
|
|
171
|
+
if (key in o) {
|
|
172
|
+
o = o[key];
|
|
173
|
+
} else {
|
|
174
|
+
throw new Error();
|
|
175
|
+
}
|
|
176
|
+
} catch {
|
|
177
|
+
throw new Error("无效路径!");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
o,
|
|
182
|
+
k: keyArr[i],
|
|
183
|
+
v: o[keyArr[i]]
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
const timestamp = +/* @__PURE__ */ new Date();
|
|
188
|
+
let index = 0;
|
|
189
|
+
const getUid = (prefix) => {
|
|
190
|
+
return `${prefix ? `${prefix}-` : ""}${timestamp}-${++index}`;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const hasOwn = (target, key) => Object.prototype.hasOwnProperty.call(target, key);
|
|
194
|
+
|
|
195
|
+
const isObj = (target) => typeof target === "object";
|
|
196
|
+
|
|
197
|
+
const getDigit = (integer) => {
|
|
198
|
+
let digit = -1;
|
|
199
|
+
while (integer >= 1) {
|
|
200
|
+
digit++;
|
|
201
|
+
integer /= 10;
|
|
202
|
+
}
|
|
203
|
+
return digit;
|
|
204
|
+
};
|
|
205
|
+
const addWan = (integer, num, mutiple, decimalDigit) => {
|
|
206
|
+
let digit = getDigit(integer);
|
|
207
|
+
if (digit > 3) {
|
|
208
|
+
let remainder = digit % 8;
|
|
209
|
+
if (remainder >= 5) {
|
|
210
|
+
remainder = 4;
|
|
211
|
+
}
|
|
212
|
+
return Math.round(num / Math.pow(10, remainder + mutiple - decimalDigit)) / Math.pow(10, decimalDigit) + "万";
|
|
213
|
+
} else {
|
|
214
|
+
return Math.round(num / Math.pow(10, mutiple - decimalDigit)) / Math.pow(10, decimalDigit) + "";
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const numberToUnit = (number, decimalDigit) => {
|
|
218
|
+
if (number > Number.MAX_SAFE_INTEGER) {
|
|
219
|
+
number = Number.MAX_SAFE_INTEGER;
|
|
220
|
+
}
|
|
221
|
+
decimalDigit = decimalDigit == null ? 2 : decimalDigit;
|
|
222
|
+
let integer = Math.floor(number);
|
|
223
|
+
let digit = getDigit(integer);
|
|
224
|
+
let unit = [];
|
|
225
|
+
if (digit > 3) {
|
|
226
|
+
let multiple = Math.floor(digit / 8);
|
|
227
|
+
if (multiple >= 1) {
|
|
228
|
+
let tmp = Math.round(integer / Math.pow(10, 8 * multiple));
|
|
229
|
+
unit.push(addWan(tmp, number, 8 * multiple, decimalDigit));
|
|
230
|
+
for (let i = 0; i < multiple; i++) {
|
|
231
|
+
unit.push("亿");
|
|
232
|
+
}
|
|
233
|
+
return unit.join("");
|
|
234
|
+
} else {
|
|
235
|
+
return addWan(integer, number, 0, decimalDigit);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
return number;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const preZero = (num) => {
|
|
243
|
+
if (num < 10 && num > 0) {
|
|
244
|
+
return "0" + num;
|
|
245
|
+
} else if (num <= 0) {
|
|
246
|
+
return "00";
|
|
247
|
+
}
|
|
248
|
+
return "" + num;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const raf = typeof window !== "undefined" && window.requestAnimationFrame || ((fn) => setTimeout(fn, 16));
|
|
252
|
+
|
|
253
|
+
const range = (min, max) => {
|
|
254
|
+
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
255
|
+
};
|
|
256
|
+
const probs = (weights) => {
|
|
257
|
+
let sum = weights.reduce((pre, cur) => pre + (!cur || cur <= 0 ? 0 : cur), 0);
|
|
258
|
+
if (!sum) {
|
|
259
|
+
throw new Error("不可能得到索引值");
|
|
260
|
+
}
|
|
261
|
+
let probs$ = weights.map((i) => i / sum);
|
|
262
|
+
let index = 0;
|
|
263
|
+
let r = Math.random();
|
|
264
|
+
while (r > 0) {
|
|
265
|
+
r -= probs$[index];
|
|
266
|
+
index++;
|
|
267
|
+
}
|
|
268
|
+
index--;
|
|
269
|
+
return index;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const sleep = (wait, immediate) => {
|
|
273
|
+
let duration;
|
|
274
|
+
if (typeof wait === "object") {
|
|
275
|
+
duration = range(wait.min, wait.max);
|
|
276
|
+
} else {
|
|
277
|
+
duration = wait || 0;
|
|
278
|
+
}
|
|
279
|
+
return new Promise((r) => {
|
|
280
|
+
let timer = setTimeout(r, duration);
|
|
281
|
+
immediate && immediate(timer, duration, r);
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const throttle = (original, wait, options) => {
|
|
286
|
+
const { leading = true, trailing = true } = options || {};
|
|
287
|
+
return debounce(
|
|
288
|
+
original,
|
|
289
|
+
wait,
|
|
290
|
+
{
|
|
291
|
+
leading,
|
|
292
|
+
trailing,
|
|
293
|
+
throttle: true
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const flattenDecodeURIComponent = (value) => {
|
|
299
|
+
let need = true;
|
|
300
|
+
let safeCount = 1;
|
|
301
|
+
let parseValue = value;
|
|
302
|
+
while (need) {
|
|
303
|
+
if (safeCount > 1e3) {
|
|
304
|
+
throw new Error(value);
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
let next = decodeURIComponent(parseValue);
|
|
308
|
+
if (parseValue === next) {
|
|
309
|
+
need = false;
|
|
310
|
+
}
|
|
311
|
+
parseValue = next;
|
|
312
|
+
} catch {
|
|
313
|
+
need = false;
|
|
314
|
+
}
|
|
315
|
+
safeCount++;
|
|
316
|
+
}
|
|
317
|
+
return parseValue;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const flattenJSONParse = (value) => {
|
|
321
|
+
if (value === null)
|
|
322
|
+
return null;
|
|
323
|
+
let regex = /^\d+$/;
|
|
324
|
+
if (regex.test(value) && value.length >= 16 && +value > Number.MAX_SAFE_INTEGER) {
|
|
325
|
+
return value;
|
|
326
|
+
}
|
|
327
|
+
let need = true;
|
|
328
|
+
let safeCount = 1;
|
|
329
|
+
let parseValue = value;
|
|
330
|
+
while (need) {
|
|
331
|
+
if (safeCount > 10) {
|
|
332
|
+
throw new Error(value);
|
|
333
|
+
}
|
|
334
|
+
try {
|
|
335
|
+
let next = JSON.parse(parseValue);
|
|
336
|
+
if (parseValue === next) {
|
|
337
|
+
need = false;
|
|
338
|
+
}
|
|
339
|
+
parseValue = next;
|
|
340
|
+
} catch {
|
|
341
|
+
need = false;
|
|
342
|
+
}
|
|
343
|
+
safeCount++;
|
|
344
|
+
}
|
|
345
|
+
return parseValue;
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
exports.asterisk = asterisk;
|
|
349
|
+
exports.autoCatch = autoCatch;
|
|
350
|
+
exports.canvasToImage = canvasToImage;
|
|
351
|
+
exports.cloneDeepEasier = cloneDeepEasier;
|
|
352
|
+
exports.compressImage = compressImage;
|
|
353
|
+
exports.dataURLToFile = dataURLToFile;
|
|
354
|
+
exports.debounce = debounce;
|
|
355
|
+
exports.def = def;
|
|
356
|
+
exports.flattenDecodeURIComponent = flattenDecodeURIComponent;
|
|
357
|
+
exports.flattenJSONParse = flattenJSONParse;
|
|
358
|
+
exports.getPropByPath = getPropByPath;
|
|
359
|
+
exports.getUid = getUid;
|
|
360
|
+
exports.hasOwn = hasOwn;
|
|
361
|
+
exports.isObj = isObj;
|
|
362
|
+
exports.numberToUnit = numberToUnit;
|
|
363
|
+
exports.preZero = preZero;
|
|
364
|
+
exports.probs = probs;
|
|
365
|
+
exports.raf = raf;
|
|
366
|
+
exports.range = range;
|
|
367
|
+
exports.sleep = sleep;
|
|
368
|
+
exports.throttle = throttle;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
export declare const asterisk: (value: string, from?: number, length?: number) => string;
|
|
4
|
+
|
|
5
|
+
export declare const autoCatch: (impl: any, options?: Record<string, any>) => Promise<any>;
|
|
6
|
+
|
|
7
|
+
export declare const canvasToImage: (canvas: HTMLCanvasElement, filename?: string) => Promise<Result>;
|
|
8
|
+
|
|
9
|
+
export declare const cloneDeepEasier: (source: object) => any;
|
|
10
|
+
|
|
11
|
+
export declare const compressImage: (file: File, options?: CompressOptions) => Promise<{
|
|
12
|
+
dataURL: string;
|
|
13
|
+
file: File;
|
|
14
|
+
}>;
|
|
15
|
+
|
|
16
|
+
export declare interface CompressOptions {
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
filetype?: string;
|
|
20
|
+
encoderOptions?: any;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare const dataURLToFile: (dataURL: string, filename?: string, filetype?: string) => File;
|
|
24
|
+
|
|
25
|
+
export declare const debounce: (original: Function, wait?: number, options?: Options) => {
|
|
26
|
+
(this: any, ...args: any[]): any;
|
|
27
|
+
cancel(): void;
|
|
28
|
+
flush(): void;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export declare const def: (target: object, key: PropertyKey, value?: any, options?: PropertyDescriptor) => void;
|
|
32
|
+
|
|
33
|
+
export declare const flattenDecodeURIComponent: (value: string) => string;
|
|
34
|
+
|
|
35
|
+
export declare const flattenJSONParse: (value: string | null) => any;
|
|
36
|
+
|
|
37
|
+
export declare const getPropByPath: (target: object, path: string) => ObjectKeyValue;
|
|
38
|
+
|
|
39
|
+
export declare const getUid: (prefix?: string) => string;
|
|
40
|
+
|
|
41
|
+
export declare const hasOwn: (target: object, key: PropertyKey) => boolean;
|
|
42
|
+
|
|
43
|
+
export declare const isObj: (target?: any) => boolean;
|
|
44
|
+
|
|
45
|
+
export declare const numberToUnit: (number: number, decimalDigit?: number) => string | number;
|
|
46
|
+
|
|
47
|
+
declare interface ObjectKeyValue {
|
|
48
|
+
o: object;
|
|
49
|
+
k: PropertyKey;
|
|
50
|
+
v: any;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare interface Options {
|
|
54
|
+
leading?: boolean;
|
|
55
|
+
trailing?: boolean;
|
|
56
|
+
throttle?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
declare interface Options_2 {
|
|
60
|
+
leading?: boolean;
|
|
61
|
+
trailing?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export declare const preZero: (num: number) => string;
|
|
65
|
+
|
|
66
|
+
export declare const probs: (weights: number[]) => number;
|
|
67
|
+
|
|
68
|
+
export declare type Raf = (callback: FrameRequestCallback) => number;
|
|
69
|
+
|
|
70
|
+
export declare const raf: Raf;
|
|
71
|
+
|
|
72
|
+
export declare const range: (min: number, max: number) => number;
|
|
73
|
+
|
|
74
|
+
declare interface Result {
|
|
75
|
+
dataURL: string;
|
|
76
|
+
file?: File;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export declare const sleep: (wait?: number | {
|
|
80
|
+
min: number;
|
|
81
|
+
max: number;
|
|
82
|
+
}, immediate?: ((timer: ReturnType<typeof global.setTimeout>, duration: number, done: Function) => any) | undefined) => Promise<unknown>;
|
|
83
|
+
|
|
84
|
+
export declare const throttle: (original: Function, wait?: number, options?: Options_2) => {
|
|
85
|
+
(this: any, ...args: any[]): any;
|
|
86
|
+
cancel(): void;
|
|
87
|
+
flush(): void;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export { }
|