@leafer/data
Advanced tools
+2
-2
| { | ||
| "name": "@leafer/data", | ||
| "version": "1.0.0-rc.6", | ||
| "version": "1.0.0-rc.7", | ||
| "description": "@leafer/data", | ||
@@ -25,4 +25,4 @@ "author": "Chao (Leafer) Wan", | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.0.0-rc.6" | ||
| "@leafer/interface": "1.0.0-rc.7" | ||
| } | ||
| } |
+21
-13
@@ -1,2 +0,2 @@ | ||
| import { ILeafData, ILeafDataOptions, ILeaf, IObject, __Value } from '@leafer/interface' | ||
| import { ILeafData, ILeaf, IObject, IValue } from '@leafer/interface' | ||
@@ -27,2 +27,14 @@ | ||
| public __getData(): IObject { | ||
| const data: IObject = { tag: this.__leaf.tag }, { __input } = this | ||
| let inputValue: IValue | ||
| for (let key in this) { | ||
| if (key[0] !== '_') { | ||
| inputValue = __input ? __input[key] : undefined | ||
| data[key] = (inputValue === undefined) ? this[key] : inputValue | ||
| } | ||
| } | ||
| return data | ||
| } | ||
| public __setInput(name: string, value: any): void { | ||
@@ -45,15 +57,11 @@ this.__input || (this.__input = {}) | ||
| public __getInputData(options?: ILeafDataOptions): IObject { | ||
| public __getInputData(): IObject { | ||
| const data: IObject = { tag: this.__leaf.tag }, { __input } = this | ||
| if (options) { | ||
| for (let key in this) { | ||
| if (key[0] !== '_') data[key] = this[key] | ||
| } | ||
| } else { | ||
| let realKey: string, value: __Value | ||
| for (let key in this) { | ||
| realKey = key.substring(1) | ||
| if ((this as any)[realKey] !== undefined) { | ||
| value = __input ? __input[realKey] : undefined | ||
| data[realKey] = value === undefined ? this[key] : value | ||
| let value: IValue, inputValue: IValue | ||
| for (let key in this) { | ||
| if (key[0] !== '_') { | ||
| value = (this as IObject)['_' + key] | ||
| if (value !== undefined) { | ||
| inputValue = __input ? __input[key] : undefined | ||
| data[key] = (inputValue === undefined) ? value : inputValue | ||
| } | ||
@@ -60,0 +68,0 @@ } |
+3
-2
@@ -1,2 +0,2 @@ | ||
| import { IObject, ILeafData, ILeaf, ILeafDataOptions } from '@leafer/interface'; | ||
| import { IObject, ILeafData, ILeaf } from '@leafer/interface'; | ||
@@ -19,6 +19,7 @@ declare const DataHelper: { | ||
| __get(name: string): any; | ||
| __getData(): IObject; | ||
| __setInput(name: string, value: any): void; | ||
| __getInput(name: string): any; | ||
| __removeInput(name: string): void; | ||
| __getInputData(options?: ILeafDataOptions): IObject; | ||
| __getInputData(): IObject; | ||
| __setMiddle(name: string, value: any): void; | ||
@@ -25,0 +26,0 @@ __getMiddle(name: string): any; |
6336
3.53%135
6.3%