object-mapping
v1.3.0
Published
A decorator-based object-to-object mapper for TypeScript and ES2016/ES7
Downloads
13
Maintainers
Readme
object-mapping utility library by Brainbean Apps
A decorator-based object-to-object mapper for TypeScript and ES2016/ES7.
Getting Started
Installation
npm install --save object-mapping
or
yarn add object-mapping
Usage
import 'reflect-metadata'
import { map, mapping } from 'object-mapping'
export interface Dto {
demo_value = ''
}
export class Model {
@mapping('Dto').rename('demo_value')
demoValue = ''
public static fromDto (dto: Dto): Model {
return map<Dto, Model>('Dto', Model, dto)
}
public static toDto (object: Model): Dto {
return map<Model, Dto>(Model, 'Dto', object)
}
public toDto (): Dto {
return Model.toDto(this)
}
}