@leafer/data 1.0.0-rc.6 → 1.0.0-rc.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/data",
3
- "version": "1.0.0-rc.6",
3
+ "version": "1.0.0-rc.8",
4
4
  "description": "@leafer/data",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,6 +22,6 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "devDependencies": {
25
- "@leafer/interface": "1.0.0-rc.6"
25
+ "@leafer/interface": "1.0.0-rc.8"
26
26
  }
27
27
  }
package/src/LeafData.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeafData, ILeafDataOptions, ILeaf, IObject, __Value } from '@leafer/interface'
1
+ import { ILeafData, ILeaf, IObject, IValue } from '@leafer/interface'
2
2
 
3
3
 
4
4
  export class LeafData implements ILeafData {
@@ -24,6 +24,18 @@ export class LeafData implements ILeafData {
24
24
  return (this as IObject)[name]
25
25
  }
26
26
 
27
+ public __getData(): IObject {
28
+ const data: IObject = { tag: this.__leaf.tag }, { __input } = this
29
+ let inputValue: IValue
30
+ for (let key in this) {
31
+ if (key[0] !== '_') {
32
+ inputValue = __input ? __input[key] : undefined
33
+ data[key] = (inputValue === undefined) ? this[key] : inputValue
34
+ }
35
+ }
36
+ return data
37
+ }
38
+
27
39
  public __setInput(name: string, value: any): void {
28
40
  this.__input || (this.__input = {})
29
41
  this.__input[name] = value
@@ -41,19 +53,15 @@ export class LeafData implements ILeafData {
41
53
  if (this.__input && this.__input[name] !== undefined) this.__input[name] = undefined
42
54
  }
43
55
 
44
- public __getInputData(options?: ILeafDataOptions): IObject {
56
+ public __getInputData(): IObject {
45
57
  const data: IObject = { tag: this.__leaf.tag }, { __input } = this
46
- if (options) {
47
- for (let key in this) {
48
- if (key[0] !== '_') data[key] = this[key]
49
- }
50
- } else {
51
- let realKey: string, value: __Value
52
- for (let key in this) {
53
- realKey = key.substring(1)
54
- if ((this as any)[realKey] !== undefined) {
55
- value = __input ? __input[realKey] : undefined
56
- data[realKey] = value === undefined ? this[key] : value
58
+ let value: IValue, inputValue: IValue
59
+ for (let key in this) {
60
+ if (key[0] !== '_') {
61
+ value = (this as IObject)['_' + key]
62
+ if (value !== undefined) {
63
+ inputValue = __input ? __input[key] : undefined
64
+ data[key] = (inputValue === undefined) ? value : inputValue
57
65
  }
58
66
  }
59
67
  }
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IObject, ILeafData, ILeaf, ILeafDataOptions } from '@leafer/interface';
1
+ import { IObject, ILeafData, ILeaf } from '@leafer/interface';
2
2
 
3
3
  declare const DataHelper: {
4
4
  default<T>(t: T, defaultData: IObject): T;
@@ -16,10 +16,11 @@ declare class LeafData implements ILeafData {
16
16
  __naturalHeight?: number;
17
17
  constructor(leaf: ILeaf);
18
18
  __get(name: string): any;
19
+ __getData(): IObject;
19
20
  __setInput(name: string, value: any): void;
20
21
  __getInput(name: string): any;
21
22
  __removeInput(name: string): void;
22
- __getInputData(options?: ILeafDataOptions): IObject;
23
+ __getInputData(): IObject;
23
24
  __setMiddle(name: string, value: any): void;
24
25
  __getMiddle(name: string): any;
25
26
  __checkSingle(): void;