@leafer/data 1.0.0-beta.9 → 1.0.0-rc.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/package.json +6 -3
- package/src/LeafData.ts +8 -10
- package/types/index.d.ts +29 -0
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/data",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.2",
|
|
4
4
|
"description": "@leafer/data",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
|
@@ -19,6 +22,6 @@
|
|
|
19
22
|
"leaferjs"
|
|
20
23
|
],
|
|
21
24
|
"devDependencies": {
|
|
22
|
-
"@leafer/interface": "1.0.0-
|
|
25
|
+
"@leafer/interface": "1.0.0-rc.2"
|
|
23
26
|
}
|
|
24
27
|
}
|
package/src/LeafData.ts
CHANGED
|
@@ -16,13 +16,12 @@ export class LeafData implements ILeafData {
|
|
|
16
16
|
this.__leaf = leaf
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
public __get(name: string):
|
|
19
|
+
public __get(name: string): any {
|
|
20
20
|
if (this.__input) {
|
|
21
21
|
const value = this.__input[name]
|
|
22
|
-
|
|
23
|
-
} else {
|
|
24
|
-
return (this as IObject)[name]
|
|
22
|
+
if (value !== undefined) return value
|
|
25
23
|
}
|
|
24
|
+
return (this as IObject)[name]
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
public __setInput(name: string, value: any): void {
|
|
@@ -30,13 +29,12 @@ export class LeafData implements ILeafData {
|
|
|
30
29
|
this.__input[name] = value
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
public __getInput(name: string):
|
|
32
|
+
public __getInput(name: string): any {
|
|
34
33
|
if (this.__input) {
|
|
35
34
|
const value = this.__input[name]
|
|
36
|
-
|
|
37
|
-
} else {
|
|
38
|
-
return (this as IObject)['_' + name]
|
|
35
|
+
if (value !== undefined) return value
|
|
39
36
|
}
|
|
37
|
+
return (this as IObject)['_' + name]
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
public __removeInput(name: string): void {
|
|
@@ -44,7 +42,7 @@ export class LeafData implements ILeafData {
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
public __getInputData(): IObject {
|
|
47
|
-
const data: IObject = {}, { __input } = this
|
|
45
|
+
const data: IObject = { tag: this.__leaf.tag }, { __input } = this
|
|
48
46
|
let realKey: string, value: __Value
|
|
49
47
|
|
|
50
48
|
for (let key in this) {
|
|
@@ -79,6 +77,6 @@ export class LeafData implements ILeafData {
|
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
public destroy(): void {
|
|
82
|
-
this.
|
|
80
|
+
this.__input = this.__middle = null
|
|
83
81
|
}
|
|
84
82
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IObject, ILeafData, ILeaf } from '@leafer/interface';
|
|
2
|
+
|
|
3
|
+
declare const DataHelper: {
|
|
4
|
+
default<T>(t: T, defaultData: IObject): T;
|
|
5
|
+
assign(t: IObject, merge: IObject): void;
|
|
6
|
+
copyAttrs(t: IObject, from: IObject, include: string[]): IObject;
|
|
7
|
+
clone(data: unknown): IObject;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
declare class LeafData implements ILeafData {
|
|
11
|
+
__leaf: ILeaf;
|
|
12
|
+
__input: IObject;
|
|
13
|
+
__middle: IObject;
|
|
14
|
+
__single: boolean;
|
|
15
|
+
__naturalWidth?: number;
|
|
16
|
+
__naturalHeight?: number;
|
|
17
|
+
constructor(leaf: ILeaf);
|
|
18
|
+
__get(name: string): any;
|
|
19
|
+
__setInput(name: string, value: any): void;
|
|
20
|
+
__getInput(name: string): any;
|
|
21
|
+
__removeInput(name: string): void;
|
|
22
|
+
__getInputData(): IObject;
|
|
23
|
+
__setMiddle(name: string, value: any): void;
|
|
24
|
+
__getMiddle(name: string): any;
|
|
25
|
+
__checkSingle(): void;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { DataHelper, LeafData };
|