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

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.4",
3
+ "version": "1.0.0-rc.6",
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.4"
25
+ "@leafer/interface": "1.0.0-rc.6"
26
26
  }
27
27
  }
package/src/LeafData.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeafData, ILeaf, IObject, __Value } from '@leafer/interface'
1
+ import { ILeafData, ILeafDataOptions, ILeaf, IObject, __Value } from '@leafer/interface'
2
2
 
3
3
 
4
4
  export class LeafData implements ILeafData {
@@ -41,15 +41,20 @@ export class LeafData implements ILeafData {
41
41
  if (this.__input && this.__input[name] !== undefined) this.__input[name] = undefined
42
42
  }
43
43
 
44
- public __getInputData(): IObject {
44
+ public __getInputData(options?: ILeafDataOptions): IObject {
45
45
  const data: IObject = { tag: this.__leaf.tag }, { __input } = this
46
- let realKey: string, value: __Value
47
-
48
- for (let key in this) {
49
- realKey = key.substring(1)
50
- if ((this as any)[realKey] !== undefined) {
51
- value = __input ? __input[realKey] : undefined
52
- data[realKey] = value === undefined ? this[key] : value
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
57
+ }
53
58
  }
54
59
  }
55
60
  return data
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IObject, ILeafData, ILeaf } from '@leafer/interface';
1
+ import { IObject, ILeafData, ILeaf, ILeafDataOptions } from '@leafer/interface';
2
2
 
3
3
  declare const DataHelper: {
4
4
  default<T>(t: T, defaultData: IObject): T;
@@ -19,7 +19,7 @@ declare class LeafData implements ILeafData {
19
19
  __setInput(name: string, value: any): void;
20
20
  __getInput(name: string): any;
21
21
  __removeInput(name: string): void;
22
- __getInputData(): IObject;
22
+ __getInputData(options?: ILeafDataOptions): IObject;
23
23
  __setMiddle(name: string, value: any): void;
24
24
  __getMiddle(name: string): any;
25
25
  __checkSingle(): void;