@thienvu18/designable-shared 2.0.0 → 2.0.2
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/esm/animation.d.ts +8 -2
- package/esm/animation.js +29 -30
- package/esm/array.d.ts +163 -37
- package/esm/array.js +104 -87
- package/esm/clone.d.ts +4 -4
- package/esm/clone.js +79 -86
- package/esm/compose.d.ts +3 -1
- package/esm/compose.js +6 -6
- package/esm/coordinate.d.ts +120 -76
- package/esm/coordinate.js +480 -411
- package/esm/element.d.ts +11 -6
- package/esm/element.js +123 -125
- package/esm/event.d.ts +162 -75
- package/esm/event.js +197 -197
- package/esm/globalThisPolyfill.d.ts +1 -1
- package/esm/globalThisPolyfill.js +14 -17
- package/esm/index.d.ts +17 -17
- package/esm/index.js +17 -17
- package/esm/instanceof.d.ts +1 -1
- package/esm/instanceof.js +9 -10
- package/esm/keycode.d.ts +145 -145
- package/esm/keycode.js +149 -149
- package/esm/lru.d.ts +50 -47
- package/esm/lru.js +236 -245
- package/esm/observer.d.ts +7 -7
- package/esm/observer.js +37 -40
- package/esm/request-idle.d.ts +9 -6
- package/esm/request-idle.js +6 -6
- package/esm/scroller.d.ts +24 -8
- package/esm/scroller.js +78 -75
- package/esm/subscribable.d.ts +10 -10
- package/esm/subscribable.js +39 -40
- package/esm/types.d.ts +13 -13
- package/esm/types.js +19 -20
- package/esm/uid.d.ts +1 -1
- package/esm/uid.js +7 -7
- package/lib/animation.d.ts +8 -2
- package/lib/animation.js +34 -35
- package/lib/array.d.ts +163 -37
- package/lib/array.js +129 -101
- package/lib/clone.d.ts +4 -4
- package/lib/clone.js +84 -91
- package/lib/compose.d.ts +3 -1
- package/lib/compose.js +10 -10
- package/lib/coordinate.d.ts +120 -76
- package/lib/coordinate.js +538 -440
- package/lib/element.d.ts +11 -6
- package/lib/element.js +139 -133
- package/lib/event.d.ts +162 -75
- package/lib/event.js +206 -202
- package/lib/globalThisPolyfill.d.ts +1 -1
- package/lib/globalThisPolyfill.js +17 -20
- package/lib/index.d.ts +17 -17
- package/lib/index.js +49 -33
- package/lib/instanceof.d.ts +1 -1
- package/lib/instanceof.js +13 -14
- package/lib/keycode.d.ts +145 -145
- package/lib/keycode.js +153 -153
- package/lib/lru.d.ts +50 -47
- package/lib/lru.js +240 -249
- package/lib/observer.d.ts +7 -7
- package/lib/observer.js +41 -44
- package/lib/request-idle.d.ts +9 -6
- package/lib/request-idle.js +14 -11
- package/lib/scroller.d.ts +24 -8
- package/lib/scroller.js +89 -81
- package/lib/subscribable.d.ts +10 -10
- package/lib/subscribable.js +43 -44
- package/lib/types.d.ts +13 -13
- package/lib/types.js +40 -28
- package/lib/uid.d.ts +1 -1
- package/lib/uid.js +11 -11
- package/package.json +15 -15
package/lib/array.d.ts
CHANGED
|
@@ -1,37 +1,163 @@
|
|
|
1
|
-
type EachArrayIterator<T> = (currentValue: T, key: number) => void | boolean
|
|
2
|
-
type EachStringIterator = (currentValue: string, key: number) => void | boolean
|
|
3
|
-
type EachObjectIterator<T = any> = (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export declare
|
|
32
|
-
export declare function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export
|
|
1
|
+
type EachArrayIterator<T> = (currentValue: T, key: number) => void | boolean
|
|
2
|
+
type EachStringIterator = (currentValue: string, key: number) => void | boolean
|
|
3
|
+
type EachObjectIterator<T = any> = (
|
|
4
|
+
currentValue: T,
|
|
5
|
+
key: string
|
|
6
|
+
) => void | boolean
|
|
7
|
+
type MapArrayIterator<TItem, TResult> = (
|
|
8
|
+
currentValue: TItem,
|
|
9
|
+
key: number
|
|
10
|
+
) => TResult
|
|
11
|
+
type MapStringIterator<TResult> = (currentValue: string, key: number) => TResult
|
|
12
|
+
type MapObjectIterator<TItem, TResult> = (
|
|
13
|
+
currentValue: TItem,
|
|
14
|
+
key: string
|
|
15
|
+
) => TResult
|
|
16
|
+
type MemoArrayIterator<T, U> = (
|
|
17
|
+
previousValue: U,
|
|
18
|
+
currentValue: T,
|
|
19
|
+
key: number
|
|
20
|
+
) => U
|
|
21
|
+
type MemoStringIterator<T> = (
|
|
22
|
+
previousValue: T,
|
|
23
|
+
currentValue: string,
|
|
24
|
+
key: number
|
|
25
|
+
) => T
|
|
26
|
+
type MemoObjectIterator<TValue, TResult> = (
|
|
27
|
+
previousValue: TResult,
|
|
28
|
+
currentValue: TValue,
|
|
29
|
+
key: string
|
|
30
|
+
) => TResult
|
|
31
|
+
export declare const toArr: (val: any) => any[]
|
|
32
|
+
export declare function each(
|
|
33
|
+
val: string,
|
|
34
|
+
iterator: EachStringIterator,
|
|
35
|
+
revert?: boolean
|
|
36
|
+
): void
|
|
37
|
+
export declare function each<T>(
|
|
38
|
+
val: T[],
|
|
39
|
+
iterator: EachArrayIterator<T>,
|
|
40
|
+
revert?: boolean
|
|
41
|
+
): void
|
|
42
|
+
export declare function each<T extends {}, TValue = T[keyof T]>(
|
|
43
|
+
val: T,
|
|
44
|
+
iterator: EachObjectIterator<TValue>,
|
|
45
|
+
revert?: boolean
|
|
46
|
+
): void
|
|
47
|
+
export declare function map<T>(
|
|
48
|
+
val: string,
|
|
49
|
+
iterator: MapStringIterator<T>,
|
|
50
|
+
revert?: boolean
|
|
51
|
+
): any
|
|
52
|
+
export declare function map<TItem, TResult>(
|
|
53
|
+
val: TItem[],
|
|
54
|
+
iterator: MapArrayIterator<TItem, TResult>,
|
|
55
|
+
revert?: boolean
|
|
56
|
+
): any
|
|
57
|
+
export declare function map<T extends {}, TResult>(
|
|
58
|
+
val: T,
|
|
59
|
+
iterator: MapObjectIterator<T[keyof T], TResult>,
|
|
60
|
+
revert?: boolean
|
|
61
|
+
): any
|
|
62
|
+
export declare function reduce<T, U>(
|
|
63
|
+
val: T[],
|
|
64
|
+
iterator: MemoArrayIterator<T, U>,
|
|
65
|
+
accumulator?: U,
|
|
66
|
+
revert?: boolean
|
|
67
|
+
): U
|
|
68
|
+
export declare function reduce<T>(
|
|
69
|
+
val: string,
|
|
70
|
+
iterator: MemoStringIterator<T>,
|
|
71
|
+
accumulator?: T,
|
|
72
|
+
revert?: boolean
|
|
73
|
+
): T
|
|
74
|
+
export declare function reduce<
|
|
75
|
+
T extends {},
|
|
76
|
+
TValue = T[keyof T],
|
|
77
|
+
TResult = any
|
|
78
|
+
>(
|
|
79
|
+
val: T,
|
|
80
|
+
iterator: MemoObjectIterator<TValue, TResult>,
|
|
81
|
+
accumulator?: TResult,
|
|
82
|
+
revert?: boolean
|
|
83
|
+
): TResult
|
|
84
|
+
export declare function every<T extends string>(
|
|
85
|
+
val: T,
|
|
86
|
+
iterator: EachStringIterator,
|
|
87
|
+
revert?: boolean
|
|
88
|
+
): boolean
|
|
89
|
+
export declare function every<T>(
|
|
90
|
+
val: T[],
|
|
91
|
+
iterator: EachArrayIterator<T>,
|
|
92
|
+
revert?: boolean
|
|
93
|
+
): boolean
|
|
94
|
+
export declare function every<T extends {}>(
|
|
95
|
+
val: T,
|
|
96
|
+
iterator: EachObjectIterator,
|
|
97
|
+
revert?: boolean
|
|
98
|
+
): boolean
|
|
99
|
+
export declare function some<T extends string>(
|
|
100
|
+
val: T,
|
|
101
|
+
iterator: EachStringIterator,
|
|
102
|
+
revert?: boolean
|
|
103
|
+
): boolean
|
|
104
|
+
export declare function some<T>(
|
|
105
|
+
val: T[],
|
|
106
|
+
iterator: EachArrayIterator<T>,
|
|
107
|
+
revert?: boolean
|
|
108
|
+
): boolean
|
|
109
|
+
export declare function some<T extends {}>(
|
|
110
|
+
val: T,
|
|
111
|
+
iterator: EachObjectIterator,
|
|
112
|
+
revert?: boolean
|
|
113
|
+
): boolean
|
|
114
|
+
export declare function findIndex<T extends string>(
|
|
115
|
+
val: T,
|
|
116
|
+
iterator: EachStringIterator,
|
|
117
|
+
revert?: boolean
|
|
118
|
+
): number
|
|
119
|
+
export declare function findIndex<T>(
|
|
120
|
+
val: T[],
|
|
121
|
+
iterator: EachArrayIterator<T>,
|
|
122
|
+
revert?: boolean
|
|
123
|
+
): number
|
|
124
|
+
export declare function findIndex<T extends {}>(
|
|
125
|
+
val: T,
|
|
126
|
+
iterator: EachObjectIterator,
|
|
127
|
+
revert?: boolean
|
|
128
|
+
): keyof T
|
|
129
|
+
export declare function find<T extends string>(
|
|
130
|
+
val: T,
|
|
131
|
+
iterator: EachStringIterator,
|
|
132
|
+
revert?: boolean
|
|
133
|
+
): any
|
|
134
|
+
export declare function find<T>(
|
|
135
|
+
val: T[],
|
|
136
|
+
iterator: EachArrayIterator<T>,
|
|
137
|
+
revert?: boolean
|
|
138
|
+
): T
|
|
139
|
+
export declare function find<T extends {}>(
|
|
140
|
+
val: T,
|
|
141
|
+
iterator: EachObjectIterator,
|
|
142
|
+
revert?: boolean
|
|
143
|
+
): T[keyof T]
|
|
144
|
+
export declare function includes<T extends string>(
|
|
145
|
+
val: T,
|
|
146
|
+
searchElement: string,
|
|
147
|
+
revert?: boolean
|
|
148
|
+
): boolean
|
|
149
|
+
export declare function includes<T>(
|
|
150
|
+
val: T[],
|
|
151
|
+
searchElement: T,
|
|
152
|
+
revert?: boolean
|
|
153
|
+
): boolean
|
|
154
|
+
export declare function includesWith<T extends string>(
|
|
155
|
+
val: T,
|
|
156
|
+
search: (item: string) => boolean
|
|
157
|
+
): boolean
|
|
158
|
+
export declare function includesWith<T>(
|
|
159
|
+
val: T[],
|
|
160
|
+
search: (item: T) => boolean
|
|
161
|
+
): boolean
|
|
162
|
+
export declare const flat: <T>(array: (T | T[])[]) => T[]
|
|
163
|
+
export {}
|
package/lib/array.js
CHANGED
|
@@ -1,125 +1,153 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.flat =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.flat =
|
|
4
|
+
exports.includesWith =
|
|
5
|
+
exports.includes =
|
|
6
|
+
exports.find =
|
|
7
|
+
exports.findIndex =
|
|
8
|
+
exports.some =
|
|
9
|
+
exports.every =
|
|
10
|
+
exports.reduce =
|
|
11
|
+
exports.map =
|
|
12
|
+
exports.each =
|
|
13
|
+
exports.toArr =
|
|
14
|
+
void 0
|
|
15
|
+
const types_1 = require('./types')
|
|
16
|
+
const toArr = (val) => ((0, types_1.isArr)(val) ? val : val ? [val] : [])
|
|
17
|
+
exports.toArr = toArr
|
|
7
18
|
function each(val, iterator, revert) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
}
|
|
19
|
+
if ((0, types_1.isArr)(val) || (0, types_1.isStr)(val)) {
|
|
20
|
+
if (revert) {
|
|
21
|
+
for (let i = val.length - 1; i >= 0; i--) {
|
|
22
|
+
if (iterator(val[i], i) === false) {
|
|
23
|
+
return
|
|
15
24
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
for (let i = 0; i < val.length; i++) {
|
|
28
|
+
if (iterator(val[i], i) === false) {
|
|
29
|
+
return
|
|
22
30
|
}
|
|
31
|
+
}
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
33
|
+
} else if ((0, types_1.isObj)(val)) {
|
|
34
|
+
let key
|
|
35
|
+
for (key in val) {
|
|
36
|
+
if (Object.hasOwnProperty.call(val, key)) {
|
|
37
|
+
if (iterator(val[key], key) === false) {
|
|
38
|
+
return
|
|
32
39
|
}
|
|
40
|
+
}
|
|
33
41
|
}
|
|
42
|
+
}
|
|
34
43
|
}
|
|
35
|
-
exports.each = each
|
|
44
|
+
exports.each = each
|
|
36
45
|
function map(val, iterator, revert) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
46
|
+
const res = (0, types_1.isArr)(val) || (0, types_1.isStr)(val) ? [] : {}
|
|
47
|
+
each(
|
|
48
|
+
val,
|
|
49
|
+
(item, key) => {
|
|
50
|
+
const value = iterator(item, key)
|
|
51
|
+
if ((0, types_1.isArr)(res)) {
|
|
52
|
+
res.push(value)
|
|
53
|
+
} else {
|
|
54
|
+
res[key] = value
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
revert
|
|
58
|
+
)
|
|
59
|
+
return res
|
|
49
60
|
}
|
|
50
|
-
exports.map = map
|
|
61
|
+
exports.map = map
|
|
51
62
|
function reduce(val, iterator, accumulator, revert) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
let result = accumulator
|
|
64
|
+
each(
|
|
65
|
+
val,
|
|
66
|
+
(item, key) => {
|
|
67
|
+
result = iterator(result, item, key)
|
|
68
|
+
},
|
|
69
|
+
revert
|
|
70
|
+
)
|
|
71
|
+
return result
|
|
57
72
|
}
|
|
58
|
-
exports.reduce = reduce
|
|
73
|
+
exports.reduce = reduce
|
|
59
74
|
function every(val, iterator, revert) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
let res = true
|
|
76
|
+
each(
|
|
77
|
+
val,
|
|
78
|
+
(item, key) => {
|
|
79
|
+
if (!iterator(item, key)) {
|
|
80
|
+
res = false
|
|
81
|
+
return false
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
revert
|
|
85
|
+
)
|
|
86
|
+
return res
|
|
68
87
|
}
|
|
69
|
-
exports.every = every
|
|
88
|
+
exports.every = every
|
|
70
89
|
function some(val, iterator, revert) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
let res = false
|
|
91
|
+
each(
|
|
92
|
+
val,
|
|
93
|
+
(item, key) => {
|
|
94
|
+
if (iterator(item, key)) {
|
|
95
|
+
res = true
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
revert
|
|
100
|
+
)
|
|
101
|
+
return res
|
|
79
102
|
}
|
|
80
|
-
exports.some = some
|
|
103
|
+
exports.some = some
|
|
81
104
|
function findIndex(val, iterator, revert) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
105
|
+
let res = -1
|
|
106
|
+
each(
|
|
107
|
+
val,
|
|
108
|
+
(item, key) => {
|
|
109
|
+
if (iterator(item, key)) {
|
|
110
|
+
res = key
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
revert
|
|
115
|
+
)
|
|
116
|
+
return res
|
|
90
117
|
}
|
|
91
|
-
exports.findIndex = findIndex
|
|
118
|
+
exports.findIndex = findIndex
|
|
92
119
|
function find(val, iterator, revert) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
120
|
+
let res
|
|
121
|
+
each(
|
|
122
|
+
val,
|
|
123
|
+
(item, key) => {
|
|
124
|
+
if (iterator(item, key)) {
|
|
125
|
+
res = item
|
|
126
|
+
return false
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
revert
|
|
130
|
+
)
|
|
131
|
+
return res
|
|
101
132
|
}
|
|
102
|
-
exports.find = find
|
|
133
|
+
exports.find = find
|
|
103
134
|
function includes(val, searchElement, revert) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return some(val, (item) => item === searchElement, revert);
|
|
135
|
+
if ((0, types_1.isStr)(val)) return val.includes(searchElement)
|
|
136
|
+
return some(val, (item) => item === searchElement, revert)
|
|
107
137
|
}
|
|
108
|
-
exports.includes = includes
|
|
138
|
+
exports.includes = includes
|
|
109
139
|
function includesWith(val, search) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
140
|
+
if ((0, types_1.isArr)(val)) {
|
|
141
|
+
return val.some((item) => search(item))
|
|
142
|
+
} else {
|
|
143
|
+
return false
|
|
144
|
+
}
|
|
116
145
|
}
|
|
117
|
-
exports.includesWith = includesWith
|
|
146
|
+
exports.includesWith = includesWith
|
|
118
147
|
const flat = (array) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
exports.flat = flat;
|
|
148
|
+
return (0, exports.toArr)(array).reduce((buf, item) => {
|
|
149
|
+
if ((0, types_1.isArr)(item)) return buf.concat((0, exports.flat)(item))
|
|
150
|
+
return buf.concat(item)
|
|
151
|
+
}, [])
|
|
152
|
+
}
|
|
153
|
+
exports.flat = flat
|
package/lib/clone.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Filter = (value: any, key: string) => boolean
|
|
2
|
-
export declare const shallowClone: (values: any) => any
|
|
3
|
-
export declare const clone: (values: any, filter?: Filter) => any
|
|
4
|
-
export {}
|
|
1
|
+
type Filter = (value: any, key: string) => boolean
|
|
2
|
+
export declare const shallowClone: (values: any) => any
|
|
3
|
+
export declare const clone: (values: any, filter?: Filter) => any
|
|
4
|
+
export {}
|
package/lib/clone.js
CHANGED
|
@@ -1,102 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.clone = exports.shallowClone = void 0
|
|
4
|
-
const types_1 = require(
|
|
5
|
-
const instanceof_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
|
+
exports.clone = exports.shallowClone = void 0
|
|
4
|
+
const types_1 = require('./types')
|
|
5
|
+
const instanceof_1 = require('./instanceof')
|
|
6
6
|
const NATIVE_KEYS = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
]
|
|
7
|
+
['Map', (map) => new Map(map)],
|
|
8
|
+
['WeakMap', (map) => new WeakMap(map)],
|
|
9
|
+
['WeakSet', (set) => new WeakSet(set)],
|
|
10
|
+
['Set', (set) => new Set(set)],
|
|
11
|
+
['Date', (date) => new Date(date)],
|
|
12
|
+
'FileList',
|
|
13
|
+
'File',
|
|
14
|
+
'URL',
|
|
15
|
+
'RegExp',
|
|
16
|
+
[
|
|
17
|
+
'Promise',
|
|
18
|
+
(promise) =>
|
|
19
|
+
new Promise((resolve, reject) => promise.then(resolve, reject)),
|
|
20
|
+
],
|
|
21
|
+
]
|
|
21
22
|
const isNativeObject = (values) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
}
|
|
23
|
+
for (let i = 0; i < NATIVE_KEYS.length; i++) {
|
|
24
|
+
const item = NATIVE_KEYS[i]
|
|
25
|
+
if (Array.isArray(item) && item[0]) {
|
|
26
|
+
if ((0, instanceof_1.instOf)(values, item[0])) {
|
|
27
|
+
return item[1] ? item[1] : item[0]
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
if ((0, instanceof_1.instOf)(values, item)) {
|
|
31
|
+
return item
|
|
32
|
+
}
|
|
34
33
|
}
|
|
35
|
-
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
36
|
const shallowClone = (values) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
let nativeClone
|
|
38
|
+
if (Array.isArray(values)) {
|
|
39
|
+
return values.slice(0)
|
|
40
|
+
} else if (isNativeObject(values)) {
|
|
41
|
+
nativeClone = isNativeObject(values)
|
|
42
|
+
return (0, types_1.isFn)(nativeClone) ? nativeClone(values) : values
|
|
43
|
+
} else if (typeof values === 'object' && !!values) {
|
|
44
|
+
return {
|
|
45
|
+
...values,
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.shallowClone = shallowClone
|
|
50
|
+
const clone = (values, filter) => {
|
|
51
|
+
let nativeClone
|
|
52
|
+
if (Array.isArray(values)) {
|
|
53
|
+
return values.map((item) => (0, exports.clone)(item, filter))
|
|
54
|
+
} else if (isNativeObject(values)) {
|
|
55
|
+
nativeClone = isNativeObject(values)
|
|
56
|
+
return (0, types_1.isFn)(nativeClone) ? nativeClone(values) : values
|
|
57
|
+
} else if (typeof values === 'object' && !!values) {
|
|
58
|
+
if ('$$typeof' in values && '_owner' in values) {
|
|
59
|
+
return values
|
|
44
60
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
...values,
|
|
48
|
-
};
|
|
61
|
+
if (values._isAMomentObject) {
|
|
62
|
+
return values
|
|
49
63
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const clone = (values, filter) => {
|
|
53
|
-
let nativeClone;
|
|
54
|
-
if (Array.isArray(values)) {
|
|
55
|
-
return values.map((item) => (0, exports.clone)(item, filter));
|
|
64
|
+
if (values._isJSONSchemaObject) {
|
|
65
|
+
return values
|
|
56
66
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (0, types_1.isFn)(nativeClone) ? nativeClone(values) : values;
|
|
67
|
+
if ((0, types_1.isFn)(values.toJS)) {
|
|
68
|
+
return values
|
|
60
69
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return values;
|
|
67
|
-
}
|
|
68
|
-
if (values._isJSONSchemaObject) {
|
|
69
|
-
return values;
|
|
70
|
-
}
|
|
71
|
-
if ((0, types_1.isFn)(values.toJS)) {
|
|
72
|
-
return values;
|
|
73
|
-
}
|
|
74
|
-
if ((0, types_1.isFn)(values.toJSON)) {
|
|
75
|
-
return values;
|
|
76
|
-
}
|
|
77
|
-
if (Object.getOwnPropertySymbols(values || {}).length) {
|
|
78
|
-
return values;
|
|
79
|
-
}
|
|
80
|
-
const res = {};
|
|
81
|
-
for (const key in values) {
|
|
82
|
-
if (Object.hasOwnProperty.call(values, key)) {
|
|
83
|
-
if ((0, types_1.isFn)(filter)) {
|
|
84
|
-
if (filter(values[key], key)) {
|
|
85
|
-
res[key] = (0, exports.clone)(values[key], filter);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
res[key] = values[key];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
res[key] = (0, exports.clone)(values[key], filter);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return res;
|
|
70
|
+
if ((0, types_1.isFn)(values.toJSON)) {
|
|
71
|
+
return values
|
|
72
|
+
}
|
|
73
|
+
if (Object.getOwnPropertySymbols(values || {}).length) {
|
|
74
|
+
return values
|
|
97
75
|
}
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
const res = {}
|
|
77
|
+
for (const key in values) {
|
|
78
|
+
if (Object.hasOwnProperty.call(values, key)) {
|
|
79
|
+
if ((0, types_1.isFn)(filter)) {
|
|
80
|
+
if (filter(values[key], key)) {
|
|
81
|
+
res[key] = (0, exports.clone)(values[key], filter)
|
|
82
|
+
} else {
|
|
83
|
+
res[key] = values[key]
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
res[key] = (0, exports.clone)(values[key], filter)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
100
89
|
}
|
|
101
|
-
|
|
102
|
-
|
|
90
|
+
return res
|
|
91
|
+
} else {
|
|
92
|
+
return values
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.clone = clone
|
package/lib/compose.d.ts
CHANGED