a2bei4-utils 1.0.0

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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +2 -0
  3. package/dist/a2bei4.utils.cjs.js +1112 -0
  4. package/dist/a2bei4.utils.cjs.js.map +1 -0
  5. package/dist/a2bei4.utils.cjs.min.js +2 -0
  6. package/dist/a2bei4.utils.cjs.min.js.map +1 -0
  7. package/dist/a2bei4.utils.esm.js +1070 -0
  8. package/dist/a2bei4.utils.esm.js.map +1 -0
  9. package/dist/a2bei4.utils.esm.min.js +2 -0
  10. package/dist/a2bei4.utils.esm.min.js.map +1 -0
  11. package/dist/a2bei4.utils.umd.js +1118 -0
  12. package/dist/a2bei4.utils.umd.js.map +1 -0
  13. package/dist/a2bei4.utils.umd.min.js +2 -0
  14. package/dist/a2bei4.utils.umd.min.js.map +1 -0
  15. package/dist/arr.cjs +34 -0
  16. package/dist/arr.cjs.map +1 -0
  17. package/dist/arr.js +31 -0
  18. package/dist/arr.js.map +1 -0
  19. package/dist/browser.cjs +60 -0
  20. package/dist/browser.cjs.map +1 -0
  21. package/dist/browser.js +56 -0
  22. package/dist/browser.js.map +1 -0
  23. package/dist/common.cjs +391 -0
  24. package/dist/common.cjs.map +1 -0
  25. package/dist/common.js +373 -0
  26. package/dist/common.js.map +1 -0
  27. package/dist/date.cjs +195 -0
  28. package/dist/date.cjs.map +1 -0
  29. package/dist/date.js +188 -0
  30. package/dist/date.js.map +1 -0
  31. package/dist/download.cjs +70 -0
  32. package/dist/download.cjs.map +1 -0
  33. package/dist/download.js +64 -0
  34. package/dist/download.js.map +1 -0
  35. package/dist/evt.cjs +155 -0
  36. package/dist/evt.cjs.map +1 -0
  37. package/dist/evt.js +152 -0
  38. package/dist/evt.js.map +1 -0
  39. package/dist/id.cjs +75 -0
  40. package/dist/id.cjs.map +1 -0
  41. package/dist/id.js +72 -0
  42. package/dist/id.js.map +1 -0
  43. package/dist/timer.cjs +57 -0
  44. package/dist/timer.cjs.map +1 -0
  45. package/dist/timer.js +55 -0
  46. package/dist/timer.js.map +1 -0
  47. package/dist/tree.cjs +99 -0
  48. package/dist/tree.cjs.map +1 -0
  49. package/dist/tree.js +95 -0
  50. package/dist/tree.js.map +1 -0
  51. package/package.json +146 -0
  52. package/readme.txt +18 -0
  53. package/types/arr.d.ts +18 -0
  54. package/types/browser.d.ts +51 -0
  55. package/types/common.d.ts +170 -0
  56. package/types/date.d.ts +77 -0
  57. package/types/download.d.ts +39 -0
  58. package/types/evt.d.ts +52 -0
  59. package/types/id.d.ts +39 -0
  60. package/types/index.d.ts +499 -0
  61. package/types/timer.d.ts +32 -0
  62. package/types/tree.d.ts +30 -0
@@ -0,0 +1,499 @@
1
+ /**
2
+ * 基于 `setTimeout` 的“间隔循环”定时器。
3
+ * 每次任务执行完成后才计算下一次间隔,避免任务堆积。
4
+ */
5
+ declare class IntervalTimer {
6
+ /**
7
+ * 创建定时器实例。
8
+ * @param {() => void} fn - 每次间隔要执行的业务函数
9
+ * @param {number} [ms=1000] - 间隔时间(毫秒)
10
+ * @throws {TypeError} 当 `fn` 不是函数时抛出
11
+ */
12
+ constructor(fn: () => void, ms?: number);
13
+ _fn: () => void;
14
+ _ms: number;
15
+ _timerId: number | null;
16
+ /**
17
+ * 启动定时器;若已启动则先停止再重新启动。
18
+ * 首次执行会立即触发。
19
+ */
20
+ start(): void;
21
+ /**
22
+ * 停止定时器。
23
+ */
24
+ stop(): void;
25
+ /**
26
+ * 查询定时器是否正在运行。
27
+ * @returns {boolean}
28
+ */
29
+ isRunning(): boolean;
30
+ }
31
+
32
+ /**
33
+ * 使用 Fisher-Yates 算法对数组 **原地** 随机乱序。
34
+ * @template T
35
+ * @param {T[]} arr - 要乱序的数组
36
+ * @returns {T[]} 返回传入的同一数组实例(已乱序)
37
+ */
38
+ declare function shuffle<T>(arr: T[]): T[];
39
+ /**
40
+ * 将数组中的元素从 `fromIndex` 移动到 `toIndex`,**原地** 修改并返回该数组。
41
+ * @template T
42
+ * @param {T[]} arr - 要操作的数组
43
+ * @param {number} fromIndex - 原始下标
44
+ * @param {number} toIndex - 目标下标
45
+ * @returns {T[]} 返回传入的同一数组实例
46
+ */
47
+ declare function moveItem<T>(arr: T[], fromIndex: number, toIndex: number): T[];
48
+
49
+ /**
50
+ * 视口尺寸对象。
51
+ * @typedef {Object} ViewportDimensions
52
+ * @property {number} w 视口宽度,单位像素。
53
+ * @property {number} h 视口高度,单位像素。
54
+ */
55
+ /**
56
+ * 获取当前视口(viewport)的宽高。
57
+ *
58
+ * 兼容策略:
59
+ * 1. 优先使用 `window.innerWidth/innerHeight`(现代浏览器)。
60
+ * 2. 降级到 `document.documentElement.clientWidth/clientHeight`(IE9+ 及怪异模式)。
61
+ * 3. 最后降级到 `document.body.clientWidth/clientHeight`(IE6-8 怪异模式)。
62
+ *
63
+ * @returns {ViewportDimensions} 包含 `w`(宽度)和 `h`(高度)的对象,单位为像素。
64
+ *
65
+ * @example
66
+ * const { w, h } = getViewportSize();
67
+ * console.log(`视口尺寸:${w} × ${h}`);
68
+ */
69
+ declare function getViewportSize(): ViewportDimensions;
70
+ /**
71
+ * 将当前页面 URL 的 query 部分解析成键值对对象。
72
+ *
73
+ * @returns {Record<string, string>} 所有查询参数组成的平凡对象
74
+ * (同名 key 仅保留最后一项)
75
+ */
76
+ declare function getAllSearchParams(): Record<string, string>;
77
+ /**
78
+ * 根据 key 获取当前页面 URL 中的单个查询参数。
79
+ *
80
+ * @param {string} key - 要提取的参数名
81
+ * @returns {string | undefined} 对应参数值;不存在时返回 `undefined`
82
+ */
83
+ declare function getSearchParam(key: string): string | undefined;
84
+ /**
85
+ * 视口尺寸对象。
86
+ */
87
+ type ViewportDimensions = {
88
+ /**
89
+ * 视口宽度,单位像素。
90
+ */
91
+ w: number;
92
+ /**
93
+ * 视口高度,单位像素。
94
+ */
95
+ h: number;
96
+ };
97
+
98
+ /**
99
+ * 返回任意值的运行时类型字符串(小写形式)。
100
+ *
101
+ * @param {*} obj 待检测的值
102
+ * @returns {keyof globalThis|"blob"|"file"|"formdata"|string} 小写类型名
103
+ */
104
+ declare function getDataType(obj: any): ("undefined" | "globalThis" | "eval" | "parseInt" | "parseFloat" | "isNaN" | "isFinite" | "decodeURI" | "decodeURIComponent" | "encodeURI" | "encodeURIComponent" | "escape" | "unescape" | "NaN" | "Infinity" | "Symbol" | "Object" | "Function" | "String" | "Boolean" | "Number" | "Math" | "Date" | "RegExp" | "Error" | "EvalError" | "RangeError" | "ReferenceError" | "SyntaxError" | "TypeError" | "URIError" | "JSON" | "Array" | "Promise" | "ArrayBuffer" | "DataView" | "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "Intl" | "alert" | "blur" | "cancelIdleCallback" | "captureEvents" | "close" | "confirm" | "focus" | "getComputedStyle" | "getSelection" | "matchMedia" | "moveBy" | "moveTo" | "open" | "postMessage" | "print" | "prompt" | "releaseEvents" | "requestIdleCallback" | "resizeBy" | "resizeTo" | "scroll" | "scrollBy" | "scrollTo" | "stop" | "toString" | "dispatchEvent" | "cancelAnimationFrame" | "requestAnimationFrame" | "atob" | "btoa" | "clearInterval" | "clearTimeout" | "createImageBitmap" | "fetch" | "queueMicrotask" | "reportError" | "setInterval" | "setTimeout" | "structuredClone" | "addEventListener" | "removeEventListener" | "NodeFilter" | "AbortController" | "AbortSignal" | "AbstractRange" | "AnalyserNode" | "Animation" | "AnimationEffect" | "AnimationEvent" | "AnimationPlaybackEvent" | "AnimationTimeline" | "Attr" | "AudioBuffer" | "AudioBufferSourceNode" | "AudioContext" | "AudioData" | "AudioDecoder" | "AudioDestinationNode" | "AudioEncoder" | "AudioListener" | "AudioNode" | "AudioParam" | "AudioParamMap" | "AudioProcessingEvent" | "AudioScheduledSourceNode" | "AudioWorklet" | "AudioWorkletNode" | "AuthenticatorAssertionResponse" | "AuthenticatorAttestationResponse" | "AuthenticatorResponse" | "BarProp" | "BaseAudioContext" | "BeforeUnloadEvent" | "BiquadFilterNode" | "Blob" | "BlobEvent" | "BroadcastChannel" | "ByteLengthQueuingStrategy" | "CDATASection" | "CSPViolationReportBody" | "CSSAnimation" | "CSSConditionRule" | "CSSContainerRule" | "CSSCounterStyleRule" | "CSSFontFaceRule" | "CSSFontFeatureValuesRule" | "CSSFontPaletteValuesRule" | "CSSGroupingRule" | "CSSImageValue" | "CSSImportRule" | "CSSKeyframeRule" | "CSSKeyframesRule" | "CSSKeywordValue" | "CSSLayerBlockRule" | "CSSLayerStatementRule" | "CSSMathClamp" | "CSSMathInvert" | "CSSMathMax" | "CSSMathMin" | "CSSMathNegate" | "CSSMathProduct" | "CSSMathSum" | "CSSMathValue" | "CSSMatrixComponent" | "CSSMediaRule" | "CSSNamespaceRule" | "CSSNestedDeclarations" | "CSSNumericArray" | "CSSNumericValue" | "CSSPageRule" | "CSSPerspective" | "CSSPropertyRule" | "CSSRotate" | "CSSRule" | "CSSRuleList" | "CSSScale" | "CSSScopeRule" | "CSSSkew" | "CSSSkewX" | "CSSSkewY" | "CSSStartingStyleRule" | "CSSStyleDeclaration" | "CSSStyleRule" | "CSSStyleSheet" | "CSSStyleValue" | "CSSSupportsRule" | "CSSTransformComponent" | "CSSTransformValue" | "CSSTransition" | "CSSTranslate" | "CSSUnitValue" | "CSSUnparsedValue" | "CSSVariableReferenceValue" | "CSSViewTransitionRule" | "Cache" | "CacheStorage" | "CanvasCaptureMediaStreamTrack" | "CanvasGradient" | "CanvasPattern" | "CanvasRenderingContext2D" | "CaretPosition" | "ChannelMergerNode" | "ChannelSplitterNode" | "CharacterData" | "Clipboard" | "ClipboardEvent" | "ClipboardItem" | "CloseEvent" | "Comment" | "CompositionEvent" | "CompressionStream" | "ConstantSourceNode" | "ContentVisibilityAutoStateChangeEvent" | "ConvolverNode" | "CookieChangeEvent" | "CookieStore" | "CookieStoreManager" | "CountQueuingStrategy" | "Credential" | "CredentialsContainer" | "Crypto" | "CryptoKey" | "CustomElementRegistry" | "CustomEvent" | "CustomStateSet" | "DOMException" | "DOMImplementation" | "DOMMatrix" | "SVGMatrix" | "WebKitCSSMatrix" | "DOMMatrixReadOnly" | "DOMParser" | "DOMPoint" | "SVGPoint" | "DOMPointReadOnly" | "DOMQuad" | "DOMRect" | "SVGRect" | "DOMRectList" | "DOMRectReadOnly" | "DOMStringList" | "DOMStringMap" | "DOMTokenList" | "DataTransfer" | "DataTransferItem" | "DataTransferItemList" | "DecompressionStream" | "DelayNode" | "DeviceMotionEvent" | "DeviceOrientationEvent" | "Document" | "DocumentFragment" | "DocumentTimeline" | "DocumentType" | "DragEvent" | "DynamicsCompressorNode" | "Element" | "ElementInternals" | "EncodedAudioChunk" | "EncodedVideoChunk" | "ErrorEvent" | "Event" | "EventCounts" | "EventSource" | "EventTarget" | "External" | "File" | "FileList" | "FileReader" | "FileSystem" | "FileSystemDirectoryEntry" | "FileSystemDirectoryHandle" | "FileSystemDirectoryReader" | "FileSystemEntry" | "FileSystemFileEntry" | "FileSystemFileHandle" | "FileSystemHandle" | "FileSystemWritableFileStream" | "FocusEvent" | "FontFace" | "FontFaceSet" | "FontFaceSetLoadEvent" | "FormData" | "FormDataEvent" | "FragmentDirective" | "GainNode" | "Gamepad" | "GamepadButton" | "GamepadEvent" | "GamepadHapticActuator" | "Geolocation" | "GeolocationCoordinates" | "GeolocationPosition" | "GeolocationPositionError" | "HTMLAllCollection" | "HTMLAnchorElement" | "HTMLAreaElement" | "HTMLAudioElement" | "HTMLBRElement" | "HTMLBaseElement" | "HTMLBodyElement" | "HTMLButtonElement" | "HTMLCanvasElement" | "HTMLCollection" | "HTMLDListElement" | "HTMLDataElement" | "HTMLDataListElement" | "HTMLDetailsElement" | "HTMLDialogElement" | "HTMLDirectoryElement" | "HTMLDivElement" | "HTMLDocument" | "HTMLElement" | "HTMLEmbedElement" | "HTMLFieldSetElement" | "HTMLFontElement" | "HTMLFormControlsCollection" | "HTMLFormElement" | "HTMLFrameElement" | "HTMLFrameSetElement" | "HTMLHRElement" | "HTMLHeadElement" | "HTMLHeadingElement" | "HTMLHtmlElement" | "HTMLIFrameElement" | "HTMLImageElement" | "HTMLInputElement" | "HTMLLIElement" | "HTMLLabelElement" | "HTMLLegendElement" | "HTMLLinkElement" | "HTMLMapElement" | "HTMLMarqueeElement" | "HTMLMediaElement" | "HTMLMenuElement" | "HTMLMetaElement" | "HTMLMeterElement" | "HTMLModElement" | "HTMLOListElement" | "HTMLObjectElement" | "HTMLOptGroupElement" | "HTMLOptionElement" | "HTMLOptionsCollection" | "HTMLOutputElement" | "HTMLParagraphElement" | "HTMLParamElement" | "HTMLPictureElement" | "HTMLPreElement" | "HTMLProgressElement" | "HTMLQuoteElement" | "HTMLScriptElement" | "HTMLSelectElement" | "HTMLSlotElement" | "HTMLSourceElement" | "HTMLSpanElement" | "HTMLStyleElement" | "HTMLTableCaptionElement" | "HTMLTableCellElement" | "HTMLTableColElement" | "HTMLTableElement" | "HTMLTableRowElement" | "HTMLTableSectionElement" | "HTMLTemplateElement" | "HTMLTextAreaElement" | "HTMLTimeElement" | "HTMLTitleElement" | "HTMLTrackElement" | "HTMLUListElement" | "HTMLUnknownElement" | "HTMLVideoElement" | "HashChangeEvent" | "Headers" | "Highlight" | "HighlightRegistry" | "History" | "IDBCursor" | "IDBCursorWithValue" | "IDBDatabase" | "IDBFactory" | "IDBIndex" | "IDBKeyRange" | "IDBObjectStore" | "IDBOpenDBRequest" | "IDBRequest" | "IDBTransaction" | "IDBVersionChangeEvent" | "IIRFilterNode" | "IdleDeadline" | "ImageBitmap" | "ImageBitmapRenderingContext" | "ImageCapture" | "ImageData" | "ImageDecoder" | "ImageTrack" | "ImageTrackList" | "InputDeviceInfo" | "InputEvent" | "IntersectionObserver" | "IntersectionObserverEntry" | "KeyboardEvent" | "KeyframeEffect" | "LargestContentfulPaint" | "Location" | "Lock" | "LockManager" | "MIDIAccess" | "MIDIConnectionEvent" | "MIDIInput" | "MIDIInputMap" | "MIDIMessageEvent" | "MIDIOutput" | "MIDIOutputMap" | "MIDIPort" | "MathMLElement" | "MediaCapabilities" | "MediaDeviceInfo" | "MediaDevices" | "MediaElementAudioSourceNode" | "MediaEncryptedEvent" | "MediaError" | "MediaKeyMessageEvent" | "MediaKeySession" | "MediaKeyStatusMap" | "MediaKeySystemAccess" | "MediaKeys" | "MediaList" | "MediaMetadata" | "MediaQueryList" | "MediaQueryListEvent" | "MediaRecorder" | "MediaSession" | "MediaSource" | "MediaSourceHandle" | "MediaStream" | "MediaStreamAudioDestinationNode" | "MediaStreamAudioSourceNode" | "MediaStreamTrack" | "MediaStreamTrackEvent" | "MessageChannel" | "MessageEvent" | "MessagePort" | "MimeType" | "MimeTypeArray" | "MouseEvent" | "MutationObserver" | "MutationRecord" | "NamedNodeMap" | "NavigationActivation" | "NavigationHistoryEntry" | "NavigationPreloadManager" | "Navigator" | "NavigatorLogin" | "Node" | "NodeIterator" | "NodeList" | "Notification" | "OfflineAudioCompletionEvent" | "OfflineAudioContext" | "OffscreenCanvas" | "OffscreenCanvasRenderingContext2D" | "OscillatorNode" | "OverconstrainedError" | "PageRevealEvent" | "PageSwapEvent" | "PageTransitionEvent" | "PannerNode" | "Path2D" | "PaymentAddress" | "PaymentMethodChangeEvent" | "PaymentRequest" | "PaymentRequestUpdateEvent" | "PaymentResponse" | "Performance" | "PerformanceEntry" | "PerformanceEventTiming" | "PerformanceMark" | "PerformanceMeasure" | "PerformanceNavigation" | "PerformanceNavigationTiming" | "PerformanceObserver" | "PerformanceObserverEntryList" | "PerformancePaintTiming" | "PerformanceResourceTiming" | "PerformanceServerTiming" | "PerformanceTiming" | "PeriodicWave" | "PermissionStatus" | "Permissions" | "PictureInPictureEvent" | "PictureInPictureWindow" | "Plugin" | "PluginArray" | "PointerEvent" | "PopStateEvent" | "ProcessingInstruction" | "ProgressEvent" | "PromiseRejectionEvent" | "PublicKeyCredential" | "PushManager" | "PushSubscription" | "PushSubscriptionOptions" | "RTCCertificate" | "RTCDTMFSender" | "RTCDTMFToneChangeEvent" | "RTCDataChannel" | "RTCDataChannelEvent" | "RTCDtlsTransport" | "RTCEncodedAudioFrame" | "RTCEncodedVideoFrame" | "RTCError" | "RTCErrorEvent" | "RTCIceCandidate" | "RTCIceTransport" | "RTCPeerConnection" | "RTCPeerConnectionIceErrorEvent" | "RTCPeerConnectionIceEvent" | "RTCRtpReceiver" | "RTCRtpScriptTransform" | "RTCRtpSender" | "RTCRtpTransceiver" | "RTCSctpTransport" | "RTCSessionDescription" | "RTCStatsReport" | "RTCTrackEvent" | "RadioNodeList" | "Range" | "ReadableByteStreamController" | "ReadableStream" | "ReadableStreamBYOBReader" | "ReadableStreamBYOBRequest" | "ReadableStreamDefaultController" | "ReadableStreamDefaultReader" | "RemotePlayback" | "Report" | "ReportBody" | "ReportingObserver" | "Request" | "ResizeObserver" | "ResizeObserverEntry" | "ResizeObserverSize" | "Response" | "SVGAElement" | "SVGAngle" | "SVGAnimateElement" | "SVGAnimateMotionElement" | "SVGAnimateTransformElement" | "SVGAnimatedAngle" | "SVGAnimatedBoolean" | "SVGAnimatedEnumeration" | "SVGAnimatedInteger" | "SVGAnimatedLength" | "SVGAnimatedLengthList" | "SVGAnimatedNumber" | "SVGAnimatedNumberList" | "SVGAnimatedPreserveAspectRatio" | "SVGAnimatedRect" | "SVGAnimatedString" | "SVGAnimatedTransformList" | "SVGAnimationElement" | "SVGCircleElement" | "SVGClipPathElement" | "SVGComponentTransferFunctionElement" | "SVGDefsElement" | "SVGDescElement" | "SVGElement" | "SVGEllipseElement" | "SVGFEBlendElement" | "SVGFEColorMatrixElement" | "SVGFEComponentTransferElement" | "SVGFECompositeElement" | "SVGFEConvolveMatrixElement" | "SVGFEDiffuseLightingElement" | "SVGFEDisplacementMapElement" | "SVGFEDistantLightElement" | "SVGFEDropShadowElement" | "SVGFEFloodElement" | "SVGFEFuncAElement" | "SVGFEFuncBElement" | "SVGFEFuncGElement" | "SVGFEFuncRElement" | "SVGFEGaussianBlurElement" | "SVGFEImageElement" | "SVGFEMergeElement" | "SVGFEMergeNodeElement" | "SVGFEMorphologyElement" | "SVGFEOffsetElement" | "SVGFEPointLightElement" | "SVGFESpecularLightingElement" | "SVGFESpotLightElement" | "SVGFETileElement" | "SVGFETurbulenceElement" | "SVGFilterElement" | "SVGForeignObjectElement" | "SVGGElement" | "SVGGeometryElement" | "SVGGradientElement" | "SVGGraphicsElement" | "SVGImageElement" | "SVGLength" | "SVGLengthList" | "SVGLineElement" | "SVGLinearGradientElement" | "SVGMPathElement" | "SVGMarkerElement" | "SVGMaskElement" | "SVGMetadataElement" | "SVGNumber" | "SVGNumberList" | "SVGPathElement" | "SVGPatternElement" | "SVGPointList" | "SVGPolygonElement" | "SVGPolylineElement" | "SVGPreserveAspectRatio" | "SVGRadialGradientElement" | "SVGRectElement" | "SVGSVGElement" | "SVGScriptElement" | "SVGSetElement" | "SVGStopElement" | "SVGStringList" | "SVGStyleElement" | "SVGSwitchElement" | "SVGSymbolElement" | "SVGTSpanElement" | "SVGTextContentElement" | "SVGTextElement" | "SVGTextPathElement" | "SVGTextPositioningElement" | "SVGTitleElement" | "SVGTransform" | "SVGTransformList" | "SVGUnitTypes" | "SVGUseElement" | "SVGViewElement" | "Screen" | "ScreenOrientation" | "ScriptProcessorNode" | "SecurityPolicyViolationEvent" | "Selection" | "ServiceWorker" | "ServiceWorkerContainer" | "ServiceWorkerRegistration" | "ShadowRoot" | "SharedWorker" | "SourceBuffer" | "SourceBufferList" | "SpeechRecognitionAlternative" | "SpeechRecognitionResult" | "SpeechRecognitionResultList" | "SpeechSynthesis" | "SpeechSynthesisErrorEvent" | "SpeechSynthesisEvent" | "SpeechSynthesisUtterance" | "SpeechSynthesisVoice" | "StaticRange" | "StereoPannerNode" | "Storage" | "StorageEvent" | "StorageManager" | "StylePropertyMap" | "StylePropertyMapReadOnly" | "StyleSheet" | "StyleSheetList" | "SubmitEvent" | "SubtleCrypto" | "Text" | "TextDecoder" | "TextDecoderStream" | "TextEncoder" | "TextEncoderStream" | "TextEvent" | "TextMetrics" | "TextTrack" | "TextTrackCue" | "TextTrackCueList" | "TextTrackList" | "TimeRanges" | "ToggleEvent" | "Touch" | "TouchEvent" | "TouchList" | "TrackEvent" | "TransformStream" | "TransformStreamDefaultController" | "TransitionEvent" | "TreeWalker" | "UIEvent" | "URL" | "webkitURL" | "URLSearchParams" | "UserActivation" | "VTTCue" | "VTTRegion" | "ValidityState" | "VideoColorSpace" | "VideoDecoder" | "VideoEncoder" | "VideoFrame" | "VideoPlaybackQuality" | "ViewTransition" | "ViewTransitionTypeSet" | "VisualViewport" | "WakeLock" | "WakeLockSentinel" | "WaveShaperNode" | "WebGL2RenderingContext" | "WebGLActiveInfo" | "WebGLBuffer" | "WebGLContextEvent" | "WebGLFramebuffer" | "WebGLProgram" | "WebGLQuery" | "WebGLRenderbuffer" | "WebGLRenderingContext" | "WebGLSampler" | "WebGLShader" | "WebGLShaderPrecisionFormat" | "WebGLSync" | "WebGLTexture" | "WebGLTransformFeedback" | "WebGLUniformLocation" | "WebGLVertexArrayObject" | "WebSocket" | "WebTransport" | "WebTransportBidirectionalStream" | "WebTransportDatagramDuplexStream" | "WebTransportError" | "WheelEvent" | "Window" | "Worker" | "Worklet" | "WritableStream" | "WritableStreamDefaultController" | "WritableStreamDefaultWriter" | "XMLDocument" | "XMLHttpRequest" | "XMLHttpRequestEventTarget" | "XMLHttpRequestUpload" | "XMLSerializer" | "XPathEvaluator" | "XPathExpression" | "XPathResult" | "XSLTProcessor" | "CSS" | "WebAssembly" | "console" | "Audio" | "Image" | "Option" | "clientInformation" | "closed" | "cookieStore" | "customElements" | "devicePixelRatio" | "document" | "event" | "external" | "frameElement" | "frames" | "history" | "innerHeight" | "innerWidth" | "length" | "location" | "locationbar" | "menubar" | "navigator" | "ondevicemotion" | "ondeviceorientation" | "ondeviceorientationabsolute" | "onorientationchange" | "opener" | "orientation" | "originAgentCluster" | "outerHeight" | "outerWidth" | "pageXOffset" | "pageYOffset" | "parent" | "personalbar" | "screen" | "screenLeft" | "screenTop" | "screenX" | "screenY" | "scrollX" | "scrollY" | "scrollbars" | "self" | "speechSynthesis" | "status" | "statusbar" | "toolbar" | "top" | "visualViewport" | "window" | "onabort" | "onanimationcancel" | "onanimationend" | "onanimationiteration" | "onanimationstart" | "onauxclick" | "onbeforeinput" | "onbeforematch" | "onbeforetoggle" | "onblur" | "oncancel" | "oncanplay" | "oncanplaythrough" | "onchange" | "onclick" | "onclose" | "oncontextlost" | "oncontextmenu" | "oncontextrestored" | "oncopy" | "oncuechange" | "oncut" | "ondblclick" | "ondrag" | "ondragend" | "ondragenter" | "ondragleave" | "ondragover" | "ondragstart" | "ondrop" | "ondurationchange" | "onemptied" | "onended" | "onerror" | "onfocus" | "onformdata" | "ongotpointercapture" | "oninput" | "oninvalid" | "onkeydown" | "onkeypress" | "onkeyup" | "onload" | "onloadeddata" | "onloadedmetadata" | "onloadstart" | "onlostpointercapture" | "onmousedown" | "onmouseenter" | "onmouseleave" | "onmousemove" | "onmouseout" | "onmouseover" | "onmouseup" | "onpaste" | "onpause" | "onplay" | "onplaying" | "onpointercancel" | "onpointerdown" | "onpointerenter" | "onpointerleave" | "onpointermove" | "onpointerout" | "onpointerover" | "onpointerrawupdate" | "onpointerup" | "onprogress" | "onratechange" | "onreset" | "onresize" | "onscroll" | "onscrollend" | "onsecuritypolicyviolation" | "onseeked" | "onseeking" | "onselect" | "onselectionchange" | "onselectstart" | "onslotchange" | "onstalled" | "onsubmit" | "onsuspend" | "ontimeupdate" | "ontoggle" | "ontouchcancel" | "ontouchend" | "ontouchmove" | "ontouchstart" | "ontransitioncancel" | "ontransitionend" | "ontransitionrun" | "ontransitionstart" | "onvolumechange" | "onwaiting" | "onwebkitanimationend" | "onwebkitanimationiteration" | "onwebkitanimationstart" | "onwebkittransitionend" | "onwheel" | "onafterprint" | "onbeforeprint" | "onbeforeunload" | "ongamepadconnected" | "ongamepaddisconnected" | "onhashchange" | "onlanguagechange" | "onmessage" | "onmessageerror" | "onoffline" | "ononline" | "onpagehide" | "onpagereveal" | "onpageshow" | "onpageswap" | "onpopstate" | "onrejectionhandled" | "onstorage" | "onunhandledrejection" | "onunload" | "localStorage" | "caches" | "crossOriginIsolated" | "crypto" | "indexedDB" | "isSecureContext" | "origin" | "performance" | "sessionStorage" | "importScripts" | "ActiveXObject" | "WScript" | "WSH" | "Enumerator" | "VBArray" | "Map" | "WeakMap" | "Set" | "WeakSet" | "Iterator" | "Proxy" | "Reflect" | "SharedArrayBuffer" | "Atomics" | "BigInt" | "BigInt64Array" | "BigUint64Array" | "AggregateError" | "WeakRef" | "FinalizationRegistry" | "SuppressedError" | "DisposableStack" | "AsyncDisposableStack" | "Float16Array") | "blob" | "file" | "formdata" | string;
105
+ /**
106
+ * 判断值是否为原生 Blob(含 File)。
107
+ *
108
+ * @param {*} obj - 待检测的值
109
+ * @returns {obj is Blob}
110
+ */
111
+ declare function isBlob(obj: any): obj is Blob;
112
+ /**
113
+ * 判断值是否为**纯粹**的 Object(即 `{}` 或 `new Object()`,不含数组、null、自定义类等)。
114
+ *
115
+ * @param {*} obj - 待检测的值
116
+ * @returns {obj is Record<PropertyKey, any>}
117
+ */
118
+ declare function isPlainObject(obj: any): obj is Record<PropertyKey, any>;
119
+ /**
120
+ * 判断值是否为 Promise(含 Promise 子类)。
121
+ *
122
+ * @param {*} obj - 待检测的值
123
+ * @returns {obj is Promise<any>}
124
+ */
125
+ declare function isPromise(obj: any): obj is Promise<any>;
126
+ /**
127
+ * 判断值是否为合法 Date 对象(含 Invalid Date 返回 false)。
128
+ *
129
+ * @param {*} t - 待检测值
130
+ * @returns {t is Date}
131
+ */
132
+ declare function isDate(t: any): t is Date;
133
+ /**
134
+ * 判断值是否为函数(含异步函数、生成器函数、类)。
135
+ *
136
+ * @param {*} obj - 待检测的值
137
+ * @returns {obj is Function}
138
+ */
139
+ declare function isFunction(obj: any): obj is Function;
140
+ /**
141
+ * 判断值是否为**非空**字符串。
142
+ *
143
+ * @param {*} obj - 待检测的值
144
+ * @returns {obj is string}
145
+ */
146
+ declare function isNonEmptyString(obj: any): obj is string;
147
+ /**
148
+ * 在闭区间 [min, max] 内生成一个均匀分布的随机整数。
149
+ * 若 min > max 则自动交换。
150
+ *
151
+ * @param {number} min - 整数下界(包含)
152
+ * @param {number} max - 整数上界(包含)
153
+ * @returns {number}
154
+ * @throws {TypeError} 当 min 或 max 不是整数时抛出
155
+ */
156
+ declare function randomIntInRange(min: number, max: number): number;
157
+ /**
158
+ * 随机生成一个汉字(可控制范围)。
159
+ *
160
+ * @param {boolean} [base=true] - 是否启用基本区(0x4E00-0x9FA5)
161
+ * @param {boolean} [extA=false] - 是否启用扩展 A 区(0x3400-0x4DBF)
162
+ * @param {boolean} [extBH=false] - 是否启用扩展 B~H 区(0x20000-0x2EBEF,代理对)
163
+ * @returns {string} 单个汉字字符
164
+ * @throws {RangeError} 未启用任何区段时抛出
165
+ */
166
+ declare function randomHan(base?: boolean, extA?: boolean, extBH?: boolean): string;
167
+ /**
168
+ * 随机生成一个英文字母。
169
+ *
170
+ * @param {'lower'|'upper'} [type] - 指定大小写;留空则随机
171
+ * @returns {string} 单个字母
172
+ */
173
+ declare function randomEnLetter(type?: "lower" | "upper"): string;
174
+ /**
175
+ * 生成指定长度的随机“中英混合”字符串。
176
+ *
177
+ * @param {number} [len=1] - 目标长度(≥1,自动取整)
178
+ * @param {number} [zhProb=0.5] - 每个位置选择汉字的概率,默认 0.5
179
+ * @returns {string}
180
+ */
181
+ declare function randomHanOrEn(len?: number, zhProb?: number): string;
182
+ /**
183
+ * 创建 debounced(防抖)函数。
184
+ * - 默认 trailing 触发;当 `leading=true` 时,首次调用或超过等待间隔会立即执行。
185
+ * - 支持手动取消。
186
+ *
187
+ * @template {(...args: any[]) => any} T
188
+ * @param {T} fn - 要防抖的原始函数
189
+ * @param {number} wait - 防抖等待时间(毫秒)
190
+ * @param {boolean} [leading=false] - 是否启用立即执行(leading edge)
191
+ * @returns {T & { cancel(): void }} 返回经过防抖包装的函数,并附带 `cancel` 方法
192
+ * @throws {TypeError} 当 `fn` 不是函数时抛出
193
+ */
194
+ declare function debounce<T extends (...args: any[]) => any>(fn: T, wait: number, leading?: boolean): T & {
195
+ cancel(): void;
196
+ };
197
+ /**
198
+ * 创建 throttled(节流)函数。
199
+ * 支持 leading/trailing 边缘触发,可手动取消。
200
+ *
201
+ * @template {(...args: any[]) => any} T
202
+ * @param {T} fn - 要节流的原始函数
203
+ * @param {number} wait - 节流间隔(毫秒)
204
+ * @param {object} [options] - 配置项
205
+ * @param {boolean} [options.leading=true] - 是否在 leading 边缘执行
206
+ * @param {boolean} [options.trailing=true] - 是否在 trailing 边缘执行
207
+ * @returns {T & { cancel(): void }} 返回经过节流包装的函数,并附带 `cancel` 方法
208
+ * @throws {TypeError} 当 `fn` 不是函数时抛出
209
+ */
210
+ declare function throttle<T extends (...args: any[]) => any>(fn: T, wait: number, { leading, trailing }?: {
211
+ leading?: boolean | undefined;
212
+ trailing?: boolean | undefined;
213
+ }): T & {
214
+ cancel(): void;
215
+ };
216
+ /**
217
+ * 利用 JSON 序列化/反序列化实现**深拷贝**。
218
+ * 注意:会丢失 `undefined`、函数、循环引用、特殊包装对象等。
219
+ *
220
+ * @template T
221
+ * @param {T} obj - 待拷贝的 JSON 兼容值
222
+ * @returns {T} 深拷贝后的值
223
+ */
224
+ declare function deepCloneByJSON<T>(obj: T): T;
225
+ /**
226
+ * **安全**地将源对象中**已存在**的属性赋值到目标对象。
227
+ * 不会新增键,也不会复制原型链上的属性。
228
+ *
229
+ * @template {Record<PropertyKey, any>} T
230
+ * @param {T} target - 目标对象(将被就地修改)
231
+ * @param {...Partial<T>} sources - 一个或多个源对象
232
+ * @returns {T} 修改后的目标对象(即第一个参数本身)
233
+ *
234
+ * @example
235
+ * const defaults = { a: 1, b: 2 };
236
+ * assignExisting(defaults, { a: 9, c: 99 }); // defaults 变为 { a: 9, b: 2 }
237
+ */
238
+ declare function assignExisting<T extends Record<PropertyKey, any>>(target: T, ...sources: Partial<T>[]): T;
239
+ /**
240
+ * 提取任意函数(含箭头函数、普通函数、async、class 构造器)的形参名称列表。
241
+ * 通过源码正则解析,不支持解构参数、默认参数、剩余参数等复杂语法;
242
+ * 若出现上述场景将返回空数组或部分名称。
243
+ *
244
+ * @param {Function} fn - 目标函数
245
+ * @returns {string[]} 按声明顺序排列的参数名数组;解析失败时返回空数组
246
+ *
247
+ * @example
248
+ * getFunctionArgNames(function (a, b) {}) // ["a", "b"]
249
+ * getFunctionArgNames((foo, bar) => {}) // ["foo", "bar"]
250
+ * getFunctionArgNames(async function x({a} = {}) {}) // [] (解构无法识别)
251
+ */
252
+ declare function getFunctionArgNames(fn: Function): string[];
253
+ /**
254
+ * 将 Blob(或 File)读取为文本,并可选择自动执行 `JSON.parse`。
255
+ * 当 `isParse=true` 且内容非法 JSON 时,会回退为返回原始文本。
256
+ *
257
+ * @param {Blob} blob - 待读取的 Blob/File 对象
258
+ * @param {boolean} [isParse=true] - 是否尝试将结果按 JSON 解析
259
+ * @returns {Promise<string | any>} 解析后的 JSON 对象或原始文本
260
+ *
261
+ * @example
262
+ * const json = await readBlobAsText(blob); // 自动 JSON.parse
263
+ * const text = await readBlobAsText(blob, false); // 仅返回文本
264
+ */
265
+ declare function readBlobAsText(blob: Blob, isParse?: boolean): Promise<string | any>;
266
+
267
+ /**
268
+ * 将任意值安全转换为 Date 对象。
269
+ * - 数字/数字字符串:视为时间戳
270
+ * - 字符串:尝试按 ISO/RFC 格式解析
271
+ * - 对象:优先 valueOf(),再 toString()
272
+ * - null / undefined / 无效值:返回 null
273
+ *
274
+ * @param {*} val - 待转换值
275
+ * @returns {Date | null} 有效 Date 或 null
276
+ */
277
+ declare function toDate(val: any): Date | null;
278
+ /**
279
+ * 在闭区间 [date1, date2] 内随机生成一个日期(含首尾)。
280
+ * 若顺序相反则自动交换。
281
+ *
282
+ * @param {Date} date1 - 起始日期
283
+ * @param {Date} date2 - 结束日期
284
+ * @returns {Date} 随机日期
285
+ */
286
+ declare function randomDateInRange(date1: Date, date2: Date): Date;
287
+ /**
288
+ * 计算两个时间之间的剩余/已过时长(天-时-分-秒),返回带补零的展示对象。
289
+ *
290
+ * @param {string|number|Date} originalTime - 原始时间(可转 Date 的任意值)
291
+ * @param {Date} [currentTime=new Date()] - 基准时间,默认当前
292
+ * @returns {{days:number,hours:string,minutes:string,seconds:string}}
293
+ */
294
+ declare function calcTimeDifference(originalTime: string | number | Date, currentTime?: Date): {
295
+ days: number;
296
+ hours: string;
297
+ minutes: string;
298
+ seconds: string;
299
+ };
300
+ /**
301
+ * 将总秒数格式化成人类可读的时间段文本。
302
+ * 固定进制:1 年=365 天,1 月=30 天。
303
+ *
304
+ * @param {number} totalSeconds - 非负总秒数
305
+ * @param {object} [options] - 格式化选项
306
+ * @param {Partial<{year:string,month:string,day:string,hour:string,minute:string,second:string}>} [options.labels] - 各单位的自定义文本
307
+ * @param {('year'|'month'|'day'|'hour'|'minute'|'second')} [options.maxUnit] - 最大输出单位
308
+ * @param {('year'|'month'|'day'|'hour'|'minute'|'second')} [options.minUnit] - 最小输出单位
309
+ * @param {boolean} [options.showZero] - 是否强制显示 0 秒
310
+ * @returns {string} 拼接后的时长文本,如“1天 02小时 30分钟”
311
+ * @throws {TypeError} 当 totalSeconds 为非数字或负数时抛出
312
+ */
313
+ declare function formatDuration(totalSeconds: number, options?: {
314
+ labels?: Partial<{
315
+ year: string;
316
+ month: string;
317
+ day: string;
318
+ hour: string;
319
+ minute: string;
320
+ second: string;
321
+ }> | undefined;
322
+ maxUnit?: "year" | "month" | "day" | "hour" | "minute" | "second" | undefined;
323
+ minUnit?: "year" | "month" | "day" | "hour" | "minute" | "second" | undefined;
324
+ showZero?: boolean | undefined;
325
+ }): string;
326
+ /**
327
+ * 快捷调用 {@link formatDuration},最大单位到“天”。
328
+ *
329
+ * @param {number} totalSeconds
330
+ * @param {Omit<Parameters<typeof formatDuration>[1],'maxUnit'>} [options]
331
+ * @returns {string}
332
+ */
333
+ declare function formatDurationMaxDay(totalSeconds: number, options?: Omit<Parameters<typeof formatDuration>[1], "maxUnit">): string;
334
+ /**
335
+ * 快捷调用 {@link formatDuration},最大单位到“小时”。
336
+ *
337
+ * @param {number} totalSeconds
338
+ * @param {Omit<Parameters<typeof formatDuration>[1],'maxUnit'>} [options]
339
+ * @returns {string}
340
+ */
341
+ declare function formatDurationMaxHour(totalSeconds: number, options?: Omit<Parameters<typeof formatDuration>[1], "maxUnit">): string;
342
+
343
+ /**
344
+ * 通过动态创建 `<a>` 标签触发浏览器下载。
345
+ *
346
+ * @param {string} url - 任意可下载地址(同源或允许跨域)
347
+ * @param {string} [fileName] - 保存到本地的文件名;不传时使用时间戳
348
+ */
349
+ declare function downloadByUrl(url: string, fileName?: string): void;
350
+ /**
351
+ * 把 Blob 转成临时 URL 并触发下载,下载完成后立即释放内存。
352
+ *
353
+ * @param {Blob} blob - 待下载的 Blob(含 File)
354
+ * @param {string} [fileName] - 保存到本地的文件名
355
+ */
356
+ declare function downloadByBlob(blob: Blob, fileName?: string): void;
357
+ /**
358
+ * 将任意数据包装成 Blob 并下载。
359
+ *
360
+ * @param {string | ArrayBufferView | ArrayBuffer | Blob} data - 要写入文件的数据
361
+ * @param {string} [fileName] - 保存到本地的文件名
362
+ * @param {string} [mimeType] - MIME 类型;默认 `application/octet-stream`
363
+ */
364
+ declare function downloadByData(data: string | ArrayBufferView | ArrayBuffer | Blob, fileName?: string, mimeType?: string): void;
365
+ /**
366
+ * 快捷下载 Excel 文件(MIME 已固定)。
367
+ *
368
+ * @param {string | ArrayBufferView | ArrayBuffer | Blob} data - Excel 二进制或字符串内容
369
+ * @param {string} [fileName] - 保存到本地的文件名
370
+ */
371
+ declare function downloadExcel(data: string | ArrayBufferView | ArrayBuffer | Blob, fileName?: string): void;
372
+ /**
373
+ * 快捷下载 JSON 文件(MIME 已固定)。
374
+ * 若传入非字符串数据,会自行 `JSON.stringify`。
375
+ *
376
+ * @param {any} data - 要序列化的 JSON 数据
377
+ * @param {string} [fileName] - 保存到本地的文件名
378
+ */
379
+ declare function downloadJSON(data: any, fileName?: string): void;
380
+
381
+ /**
382
+ * 简单、高性能的通用事件总线。
383
+ * - 支持命名空间事件
384
+ * - 支持一次性监听器
385
+ * - 返回唯一 flag,用于精确卸载
386
+ * - emit 时可选自定义 this 指向
387
+ */
388
+ declare class MyEvent {
389
+ evtPool: Map<any, any>;
390
+ /**
391
+ * 注册事件监听器。
392
+ * @param {string} name - 事件名
393
+ * @param {Function} fn - 回调函数
394
+ * @returns {string} flag - 唯一标识,用于 off
395
+ */
396
+ on(name: string, fn: Function): string;
397
+ /**
398
+ * 注册一次性监听器,触发后自动移除。
399
+ * @param {string} name - 事件名
400
+ * @param {Function} fn - 回调函数
401
+ * @returns {string} flag - 唯一标识
402
+ */
403
+ once(name: string, fn: Function): string;
404
+ /**
405
+ * 移除指定事件监听器。
406
+ * @param {string} name - 事件名
407
+ * @param {Function|string} fnOrFlag - 回调函数或 flag
408
+ */
409
+ off(name: string, fnOrFlag: Function | string): void;
410
+ /**
411
+ * 触发事件(同步执行)。
412
+ * @param {string} name - 事件名
413
+ * @param {*} [data] - 任意载荷
414
+ * @param {*} [fnThis] - 回调内部 this 指向,默认 undefined
415
+ */
416
+ emit(name: string, data?: any, fnThis?: any): void;
417
+ }
418
+ declare namespace MyEvent_CrossPagePlugin {
419
+ /**
420
+ * 为指定 MyEvent 实例安装跨页插件。
421
+ * @param {MyEvent} bus - 事件总线实例
422
+ * @param {Options} [opts] - 配置项
423
+ */
424
+ function install(bus: MyEvent, opts?: Options): void;
425
+ /**
426
+ * 卸载插件,恢复原始 emit 并停止监听。
427
+ * @param {MyEvent} bus - 事件总线实例
428
+ */
429
+ function uninstall(bus: MyEvent): void;
430
+ }
431
+
432
+ /**
433
+ * 生成 RFC4122 版本 4 的 GUID/UUID。
434
+ * 收集来源:《基于mvc的javascript web富应用开发》 书中介绍是Robert Kieffer写的,还留了网址 http://goo.gl/0b0hu ,但实际访问不了。
435
+ * 格式:`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`
436
+ *
437
+ * @returns {string} 36 位大写 GUID
438
+ *
439
+ * @example
440
+ * // A2E0F340-6C3B-4D7F-B8C1-1E4F6A8B9C0D
441
+ * console.log(getGUID())
442
+ */
443
+ declare function getGUID(): string;
444
+ /**
445
+ * 分布式短 ID 生成器。
446
+ * 格式:`${timestamp}${flag}${serial}`,其中:
447
+ * - timestamp:毫秒级时间戳
448
+ * - flag:客户端标识串(自定义)
449
+ * - serial:同一毫秒内的序号,左补零到固定长度
450
+ */
451
+ declare class MyId {
452
+ /**
453
+ * @param {object} [option]
454
+ * @param {string} [option.flag] - 客户端标识,默认空串
455
+ * @param {number} [option.len=5] - 序号位长度(位数),安全范围 ≥0
456
+ */
457
+ constructor(option?: {
458
+ flag?: string | undefined;
459
+ len?: number | undefined;
460
+ });
461
+ /**
462
+ * 生成下一个全局唯一字符串 ID。
463
+ * 同一毫秒序号自动递增;序号溢出时会在控制台警告。
464
+ * @returns {string}
465
+ */
466
+ nextId(): string;
467
+ #private;
468
+ }
469
+
470
+ /**
471
+ * 把嵌套树拍平成 `{ [id]: node }` 映射,同时把原 `children` 置为 `null`。
472
+ *
473
+ * @template T extends Record<PropertyKey, any>
474
+ * @param {T[]} data - 嵌套树森林
475
+ * @param {string} [idKey='id'] - 主键字段
476
+ * @param {string} [childrenKey='children'] - 子节点字段
477
+ * @returns {Record<string, T & { [k in typeof childrenKey]: null }>} id→节点的映射表
478
+ */
479
+ declare function nestedTree2IdMap<T>(data: T[], idKey?: string, childrenKey?: string): Record<string, T & { [k in typeof childrenKey]: null; }>;
480
+ /**
481
+ * 把**已包含完整父子关系**的扁平节点列表还原成嵌套树(森林)。
482
+ *
483
+ * @template T extends Record<PropertyKey, any>
484
+ * @param {T[]} nodes - 扁平节点列表(必须包含 id / parentId)
485
+ * @param {number | string} [parentId=0] - 根节点标识值
486
+ * @param {Object} [opts] - 字段映射配置
487
+ * @param {string} [opts.idKey='id'] - 节点主键
488
+ * @param {string} [opts.parentKey='parentId'] - 父节点外键
489
+ * @param {string} [opts.childrenKey='children'] - 存放子节点的字段
490
+ * @returns {(T & { [k in typeof childrenKey]: T[] })[]} 嵌套树森林
491
+ */
492
+ declare function flatCompleteTree2NestedTree<T>(nodes: T[], parentId?: number | string, { idKey, parentKey, childrenKey }?: {
493
+ idKey?: string | undefined;
494
+ parentKey?: string | undefined;
495
+ childrenKey?: string | undefined;
496
+ }): (T & { [k in typeof childrenKey]: T[]; })[];
497
+ declare function findObjAttrValueById<T>(id: string | number, arr: T[], resultKey?: string, idKey?: string, childrenKey?: string): any;
498
+
499
+ export { IntervalTimer, MyEvent, MyEvent_CrossPagePlugin, MyId, assignExisting, calcTimeDifference, debounce, deepCloneByJSON, downloadByBlob, downloadByData, downloadByUrl, downloadExcel, downloadJSON, findObjAttrValueById, flatCompleteTree2NestedTree, formatDuration, formatDurationMaxDay, formatDurationMaxHour, getAllSearchParams, getDataType, getFunctionArgNames, getGUID, getSearchParam, getViewportSize, isBlob, isDate, isFunction, isNonEmptyString, isPlainObject, isPromise, moveItem, nestedTree2IdMap, randomDateInRange, randomEnLetter, randomHan, randomHanOrEn, randomIntInRange, readBlobAsText, shuffle, throttle, toDate };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 基于 `setTimeout` 的“间隔循环”定时器。
3
+ * 每次任务执行完成后才计算下一次间隔,避免任务堆积。
4
+ */
5
+ declare class IntervalTimer {
6
+ /**
7
+ * 创建定时器实例。
8
+ * @param {() => void} fn - 每次间隔要执行的业务函数
9
+ * @param {number} [ms=1000] - 间隔时间(毫秒)
10
+ * @throws {TypeError} 当 `fn` 不是函数时抛出
11
+ */
12
+ constructor(fn: () => void, ms?: number);
13
+ _fn: () => void;
14
+ _ms: number;
15
+ _timerId: number | null;
16
+ /**
17
+ * 启动定时器;若已启动则先停止再重新启动。
18
+ * 首次执行会立即触发。
19
+ */
20
+ start(): void;
21
+ /**
22
+ * 停止定时器。
23
+ */
24
+ stop(): void;
25
+ /**
26
+ * 查询定时器是否正在运行。
27
+ * @returns {boolean}
28
+ */
29
+ isRunning(): boolean;
30
+ }
31
+
32
+ export { IntervalTimer };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * 把嵌套树拍平成 `{ [id]: node }` 映射,同时把原 `children` 置为 `null`。
3
+ *
4
+ * @template T extends Record<PropertyKey, any>
5
+ * @param {T[]} data - 嵌套树森林
6
+ * @param {string} [idKey='id'] - 主键字段
7
+ * @param {string} [childrenKey='children'] - 子节点字段
8
+ * @returns {Record<string, T & { [k in typeof childrenKey]: null }>} id→节点的映射表
9
+ */
10
+ declare function nestedTree2IdMap<T>(data: T[], idKey?: string, childrenKey?: string): Record<string, T & { [k in typeof childrenKey]: null; }>;
11
+ /**
12
+ * 把**已包含完整父子关系**的扁平节点列表还原成嵌套树(森林)。
13
+ *
14
+ * @template T extends Record<PropertyKey, any>
15
+ * @param {T[]} nodes - 扁平节点列表(必须包含 id / parentId)
16
+ * @param {number | string} [parentId=0] - 根节点标识值
17
+ * @param {Object} [opts] - 字段映射配置
18
+ * @param {string} [opts.idKey='id'] - 节点主键
19
+ * @param {string} [opts.parentKey='parentId'] - 父节点外键
20
+ * @param {string} [opts.childrenKey='children'] - 存放子节点的字段
21
+ * @returns {(T & { [k in typeof childrenKey]: T[] })[]} 嵌套树森林
22
+ */
23
+ declare function flatCompleteTree2NestedTree<T>(nodes: T[], parentId?: number | string, { idKey, parentKey, childrenKey }?: {
24
+ idKey?: string | undefined;
25
+ parentKey?: string | undefined;
26
+ childrenKey?: string | undefined;
27
+ }): (T & { [k in typeof childrenKey]: T[]; })[];
28
+ declare function findObjAttrValueById<T>(id: string | number, arr: T[], resultKey?: string, idKey?: string, childrenKey?: string): any;
29
+
30
+ export { findObjAttrValueById, flatCompleteTree2NestedTree, nestedTree2IdMap };