UNPKG

1.75 kBTypeScriptView Raw
1interface Obj extends Object {
2 [key: string]: any
3
4 [key: number]: any
5}
6
7declare type UnexpectType =
8 | undefined
9 | null
10 | string
11 | number
12 | boolean
13 | Date
14 | Error
15 | RegExp
16 | FileList
17 | File
18 | Element
19 | Window
20 | Document
21declare type ReferencedPath = string
22declare type QuotePath = string
23declare type CircularStructurePaths = [ReferencedPath, QuotePath]
24
25interface CopyDomOptions {
26 /**
27 * Should clear selection after copy
28 *
29 * Default to false
30 * */
31 clearSelect?: boolean
32 /**
33 * Should cut the dom(like <input>) value after copy
34 *
35 * Default to false
36 * */
37 cut?: boolean
38}
39
40/**
41 * @param {Element} dom
42 * @param {Object} options - Optional
43 * @returns {Boolean}
44 * */
45declare function copyDom(dom: Element, options?: CopyDomOptions): boolean
46
47/**
48 * @param {String} text
49 * @return {Promise<boolean>}
50 * */
51declare function copyText(text: string): Promise<true>
52
53/**
54 * @description Deep copy, has the ability to deal nested loop
55 * */
56declare function objectDeepCopy<T extends Obj = Obj>(obj: T): T
57
58/**
59 * @description Deep copy, cannot deal nested loop
60 * */
61declare function objectSimpleCopy(obj: Obj): any
62
63/**
64 * @description Deep merge, cannot deal nested loop
65 * @return The first parameter object which has been merged
66 * */
67declare function objectDeepMerge<T extends Obj = Obj>(
68 target: T,
69 ...rest: T[]
70): any
71
72/**
73 * @description Returns the start dimension of the nested loop
74 * */
75declare function isCircularStructure(obj: Obj): CircularStructurePaths | null
76
77export {
78 CircularStructurePaths,
79 CopyDomOptions,
80 Obj,
81 QuotePath,
82 ReferencedPath,
83 UnexpectType,
84 copyDom,
85 copyText,
86 isCircularStructure,
87 objectDeepCopy,
88 objectDeepMerge,
89 objectSimpleCopy,
90}
91
\No newline at end of file