New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@automapper/pojos

Package Overview
Dependencies
Maintainers
1
Versions
140
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@automapper/pojos

AutoMapper TypeScript POJOs plugin

  • 8.8.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35K
increased by3.81%
Maintainers
1
Weekly downloads
 
Created
Source

@automapper/pojos

This is the official strategy from @automapper to work with Interfaces/Types along with Plain Objects

Installation

npm i @automapper/pojos

or with yarn:

yarn add @automapper/pojos
peerDependencies

@automapper/pojos depends on @automapper/core

npm i @automapper/core

or with yarn:

yarn add @automapper/core

Usage

@automapper/pojos provides pojos as a MappingStrategyInitializer. Pass pojos() to createMapper to create a Mapper that uses pojos strategy.

import { pojos, PojosMetadataMap } from '@automapper/pojos';
import { createMapper, createMap, forMember, mapFrom } from '@automapper/core';

const mapper = createMapper({
  ...,
  strategyInitializer: pojos()
});

interface User {
    firstName: string;
    lastName: string;
}

interface UserDto {
    firstName: string;
    lastName: string;
    fullName: string;
}

PojosMetadataMap.create<User>('SomeTokenForUser', {
    firstName: String,
    lastName: String
});

PojosMetadataMap.create<UserDto>('SomeTokenForUserDto', {
  firstName: String,
  lastName: String,
  fullName: String
});

createMap<User, UserDto>(
    mapper,
    'SomeTokenForUser',
    'SomeTokenForUserDto',
    forMember(
        d => d.fullName,
        mapFrom(s => s.firstName + ' ' + s.lastName)
    )
);
mapper.map<User, UserDto>(
    {firstName: 'Auto', lastName: 'Mapper'},
    'SomeTokenForUser',
    'SomeTokenForUserDto'
);
// { firstName: 'Auto', lastName: 'Mapper', fullName: 'Auto Mapper' }

Read more about this strategy on pojos documentation

Keywords

FAQs

Package last updated on 23 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc