npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nartc/automapper

v7.0.4

Published

An object-to-object mapper by convention for TypeScript.

Downloads

5,240

Readme

AutoMapper

An object-to-object mapper by convention for TypeScript.

Travis (.com) npm bundle size (scoped) npm npm (scoped) NPM Coveralls github Snyk Vulnerabilities for GitHub Repo

Migrations to v6

  • initialize() has been deprecated in v6. Please use createMap(), addProfile(), and/or withGlobalSettings() directly
  • Mapping operations have been rewritten as individual functions to support tree-shaking, please migrate your mapping configurations to use those
// before
Mapper.createMap(Source, Destination)
    .forMember(d => d.destMember, opts => opts.mapFrom(s => s.sourceMember);

// after
Mapper.createMap(Source, Destination)
    .forMember(d => d.destMember, mapFrom(s => s.sourceMember))
  • Pre-Condition: preCondition() is also a separate function. Use in v6 as follow
// before
Mapper.createMap(Source, Destination).forMember(
  d => d.destMember,
  opts => opts.preCondition(predicate).mapFrom(s => s.sourceMember)
);

// after
Mapper.createMap(Source, Destination).forMember(
  d => d.destMember,
  preCondition(predicate),
  mapFrom(s => s.sourceMember)
);

Migrations from automapper-nartc

The only migration step you need is to modify forMember() method.

In automapper-nartc, forMember() takes in a property string as the first argument. Now, forMember() in @nartc/automapper takes in a selector instead. This wil allow reverseMap() to work better.

// Before
Mapper.createMap(User, UserVm)
  .forMember('fullName', opts => opts.mapFrom(...));

// Now
Mapper.createMap(User, UserVm)
  .forMember(dest => dest.fullName, opts => opts.mapFrom(...));

Migrations to v3

  • Change @Expose() and @ExposedType() to @AutoMap()
// Before
class User {
  @Expose()
  firstName: string;
  @ExposedType(() => Profile)
  profile: Profile;
}

// v3
class User {
  @AutoMap()
  firstName: string;
  @AutoMap(() => Profile)
  profile: Profile;
}

Features

So far, the following is supported:

  • [x] Basic Mapping between two classes

  • [x] Basic Mapping for nested classes

  • [x] Mapping Inheritance - with caveats regarding typings.

  • [x] Array/List Mapping

  • [x] Flattening

  • [x] ReverseMap

  • [x] Value Converters

  • [x] Value Resolvers

  • [x] Async (Read more at Async Support)

  • [x] Before/After Callback

  • [x] Naming Conventions

  • [x] Null Substitution - @lqmanh pointed out the difference in fromValue() and nullSubstitution() use-case, and that difference is totally valid. Hence, nullSubstitution is now supported.

  • [x] Circular Dependencies

  • [x] Tree-shakable

Unsupported features:

  • [ ] Type Converters
  • [ ] Value Transformers

Circular Dependencies

Please check out the Circular Dependencies Documentations

Documentations

Check out the AutoMapper TypeScript Documentations

Demo

Codesandbox Demo

Contribution

Contribution of any kind is always welcomed.

MIT License