Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Automapper in Typescript?

Are there any packages available for mapping two object in typescript I.E Automapper? I found a couple of packages but they don't have enough document for implementation.

like image 516
Bhautik Dalicha Avatar asked May 14 '18 06:05

Bhautik Dalicha


People also ask

What is AutoMapper TypeScript?

​ AutoMapper (TypeScript) is an object-object mapper by convention. When two objects' models are conventionally matching, AutoMapper can map the two objects with almost zero mapping configuration.

When should I use AutoMapper?

AutoMapper is used whenever there are many data properties for objects, and we need to map them between the object of source class to the object of destination class, Along with the knowledge of data structure and algorithms, a developer is required to have excellent development skills as well.

What can I use instead of AutoMapper?

AutoMapper is one of the popular object-object mapping libraries with over 296 million NuGet package downloads. It was first published in 2011 and its usage is growing ever since. Mapster is an emerging alternative to AutoMapper which was first published in 2015 and has over 7.4 million NuGet package downloads.

Is AutoMapper fast?

Automapper is slower when mapping a single object and collections but there is one exception. Automapper is considerably faster when mapping a List<T> of objects on . NET Core (It's still slower on full .


2 Answers

Here are a couple I am aware of:

  • https://github.com/loedeman/AutoMapper (https://www.npmjs.com/package/automapper-ts)
  • https://github.com/typestack/class-transformer

There is also a good discussion about this at https://www.reddit.com/r/javascript/comments/4tg69t/question_typescript_auto_mapping/ that might be of interest.

like image 154
Matthew Heironimus Avatar answered Sep 18 '22 11:09

Matthew Heironimus


have you looked at

  • mpr the object mapper - for Typescript and JavaScript
  • Docs are here

Disclaimer I'm the author, I wrote it as I wanted some more of the advanced options (note it flexible with how classes are detailed and mapped)

like image 44
dbones Avatar answered Sep 18 '22 11:09

dbones