mapper

๐Ÿ”ฅ An Object-Object AutoMapper for TypeScript ๐Ÿ”ฅ

MIT License

Downloads
732.2K
Stars
952
Committers
19

Bot releases are hidden (Show)

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

Transformer Plugin for @automapper/classes

A before transformer plugin that runs before the compilation step in order to keep track of the classes' metadata a different way. Read more about it on documentations

Treat anything as primitives

One of the requests I've got is to map any object as-is instead of going through the usual mapping pipeline. Internally, @automapper/core looks at source value and will determine to proceed with Mapping Nested Object if it encounters an object type. Previously, there's no way to customize this behavior from the auto-configured standpoint (you can still customize this with a forMember). v3.x will allow to use null for metadata that will affect the auto-configured process during initialization.

  • For classes
class Foo {
   @AutoMap(() => null)
   arbitraryObject: Record<string, unknown>;
}
  • For pojos
interface Foo {
   arbitraryObject: Record<string, unknown>;
}

createMetadataMap<Foo>("Foo", {
   arbitraryObject: null
})

Breaking Changes

Date properties on initialization

Previously, a Date property will be instantiated with a new Date instance when the source value is undefined. This has been changed to instantiate a Date property with undefined when source value is undefined instead. If your code and tests depend on the old behavior, please adjust accordingly

null in createMetadataMap

As mentioned above, null now means something else when used with createMetadataMap. Previously, null is to skip a property when we use the extend syntax of createMetadataMap. Now, to skip a property, use false value instead.

// previously
createMetadataMap("AnotherFoo", "Foo", {
   bar: null // AnotherFoo has everything Foo has but it does not have "bar", so we skip it
})

// now
createMetadataMap("AnotherFoo", "Foo", {
   bar: false
})
mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago

mapper -

Published by nartc over 3 years ago