@leafer/data 1.0.0-alpha.23 → 1.0.0-alpha.30
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/package.json +2 -2
- package/src/DataHelper.ts +14 -7
- package/src/LeafData.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/data",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
4
4
|
"description": "@leafer/data",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
"leaferjs"
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@leafer/interface": "1.0.0-alpha.
|
|
22
|
+
"@leafer/interface": "1.0.0-alpha.30"
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/DataHelper.ts
CHANGED
|
@@ -3,24 +3,31 @@ import { IObject } from '@leafer/interface'
|
|
|
3
3
|
|
|
4
4
|
export const DataHelper = {
|
|
5
5
|
|
|
6
|
-
default<T>(
|
|
7
|
-
assign(defaultData,
|
|
8
|
-
assign(
|
|
9
|
-
return
|
|
6
|
+
default<T>(t: T, defaultData: IObject): T {
|
|
7
|
+
assign(defaultData, t)
|
|
8
|
+
assign(t, defaultData)
|
|
9
|
+
return t
|
|
10
10
|
},
|
|
11
11
|
|
|
12
|
-
assign(
|
|
12
|
+
assign(t: IObject, merge: IObject): void {
|
|
13
13
|
let value: unknown
|
|
14
14
|
Object.keys(merge).forEach(key => {
|
|
15
15
|
value = merge[key]
|
|
16
16
|
if (value?.constructor === Object) {
|
|
17
|
-
(
|
|
17
|
+
(t[key]?.constructor === Object) ? assign(t[key], merge[key]) : t[key] = merge[key]
|
|
18
18
|
} else {
|
|
19
|
-
|
|
19
|
+
t[key] = merge[key]
|
|
20
20
|
}
|
|
21
21
|
})
|
|
22
22
|
},
|
|
23
23
|
|
|
24
|
+
copyAttrs(t: IObject, from: IObject, include: string[]): IObject {
|
|
25
|
+
include.forEach(key => {
|
|
26
|
+
if (from[key] !== undefined) t[key] = from[key]
|
|
27
|
+
})
|
|
28
|
+
return t
|
|
29
|
+
},
|
|
30
|
+
|
|
24
31
|
clone(data: unknown): IObject {
|
|
25
32
|
return JSON.parse(JSON.stringify(data))
|
|
26
33
|
}
|
package/src/LeafData.ts
CHANGED
|
@@ -34,6 +34,10 @@ export class LeafData implements ILeafData {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
public __removeInput(name: string): void {
|
|
38
|
+
if (this.__input && this.__input[name] !== undefined) this.__input[name] = undefined
|
|
39
|
+
}
|
|
40
|
+
|
|
37
41
|
public __getInputData(): IObject {
|
|
38
42
|
const data: IObject = {}, { __input } = this
|
|
39
43
|
let realKey: string, value: __Value
|