( entity: T & Dictionary, preferHelper = false, )
| 15 | * use `preferHelper = true` to have access to the internal `__` properties like `__meta` or `__em` |
| 16 | */ |
| 17 | export function wrap<T extends object>( |
| 18 | entity: T & Dictionary, |
| 19 | preferHelper = false, |
| 20 | ): IWrappedEntity<T> | IWrappedEntityInternal<T> { |
| 21 | if (!entity) { |
| 22 | return entity; |
| 23 | } |
| 24 | |
| 25 | if (entity.__baseEntity && !preferHelper) { |
| 26 | return entity as unknown as IWrappedEntity<T>; |
| 27 | } |
| 28 | |
| 29 | return entity.__helper ?? entity; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * wraps entity type with WrappedEntity internal properties and helpers like init/isInitialized/populated/toJSON |
no outgoing calls