( superProps?: P, props?: P, properties?: any )
| 4 | |
| 5 | // 方便取值的时候能够把上层的取到,但是获取的时候不会全部把所有的数据获取到。 |
| 6 | export function createObject<P extends {[propName: string]: any} | null>( |
| 7 | superProps?: P, |
| 8 | props?: P, |
| 9 | properties?: any |
| 10 | ): object { |
| 11 | if (superProps && Object.isFrozen(superProps)) { |
| 12 | superProps = cloneObject(superProps); |
| 13 | } |
| 14 | |
| 15 | const obj = superProps |
| 16 | ? Object.create(superProps, { |
| 17 | ...properties, |
| 18 | __super: { |
| 19 | value: superProps, |
| 20 | writable: false, |
| 21 | enumerable: false |
| 22 | } |
| 23 | }) |
| 24 | : Object.create(Object.prototype, properties); |
| 25 | |
| 26 | props && |
| 27 | isObject(props) && |
| 28 | Object.keys(props).forEach(key => (obj[key] = props[key])); |
| 29 | |
| 30 | return obj; |
| 31 | } |
| 32 | |
| 33 | export function extractObjectChain(value: any) { |
| 34 | const result: Array<object> = value ? [value] : []; |
no test coverage detected