Creates an instance of the given class from the given raw object.
The class of the instance to create
The raw object to use as source
An instance of the given class
import { createInstance } from '@magek/common'import { User } from './entities/user'const rawUser = { id: '123', name: 'John Doe',}const user = createInstance(User, rawUser)console.log(user.id) // Prints '123'console.log(user.name) // Prints 'John Doe' Copy
import { createInstance } from '@magek/common'import { User } from './entities/user'const rawUser = { id: '123', name: 'John Doe',}const user = createInstance(User, rawUser)console.log(user.id) // Prints '123'console.log(user.name) // Prints 'John Doe'
Creates an instance of the given class from the given raw object.