Group and view
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
export interface Modeling {
|
||||
toModel(): Model
|
||||
}
|
||||
export function obj2Model(obj: Model): Model {
|
||||
if (obj instanceof Array) {
|
||||
return obj.map(e => obj2Model(e)) as Model
|
||||
} else if (obj instanceof Object
|
||||
&& Reflect.has(obj, 'toModel')
|
||||
&& Reflect.get(obj, 'toModel') instanceof Function) {
|
||||
obj = Reflect.apply(Reflect.get(obj, 'toModel'), obj, [])
|
||||
return obj
|
||||
} else {
|
||||
return obj
|
||||
}
|
||||
}
|
||||
|
||||
export type Model = string | number | boolean | Modeling | { [index: string]: Model | undefined }
|
||||
type _M = string | number | boolean | Modeling | { [index: string]: Model | undefined }
|
||||
export type Model = _M | Array<_M>
|
Reference in New Issue
Block a user