MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / throttle

Function throttle

entrypoints/utils/common.ts:5–15  ·  view source on GitHub ↗
(fn: (...args: any[]) => void, interval: number)

Source from the content-addressed store, hash-verified

3
4// 防抖限流函数,可传递参数
5export function throttle(fn: (...args: any[]) => void, interval: number) {
6 let last = 0; // 维护上次执行的时间
7 return function (this: any, ...args: any[]) {
8 const now = Date.now();
9 // 只有当前时间与上次执行时间差大于等于间隔时才执行
10 if (now - last >= interval) {
11 last = now;
12 fn.apply(this, args); // 使用 apply 来传递参数数组
13 }
14 };
15}
16
17// 输出标准的语言类型,franc 只返回最可信的结果,francAll 返回所有结果并包含确信度
18export function detectlang(origin: string): string {

Callers 2

tip.tsFile · 0.90
trans.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected