New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

light-mapper

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

light-mapper

typescript mapper from object to object

latest
Source
npmnpm
Version
1.1.9
Version published
Weekly downloads
154
-29.03%
Maintainers
1
Weekly downloads
 
Created
Source

LightMapper

typescript mapper from object to object

Install

npm install light-mapper

Use

import { Mapping, MappingRequirement, LightMapper } from "light-mapper";

class Target {

    @Mapping({
        requirement: MappingRequirement.REQUIRED,
        from: ['sourceA'],
        transformation: (value: any) => {
            return value + ' transformed by decorator'
        }
    })
    public targetA: string

    @Mapping({
        requirement: MappingRequirement.REQUIRED,
        from: ['sourceB']
    })
    public targetB: string

    @Mapping({
        requirement: MappingRequirement.REQUIRED,
        from: ['sourceC']
    })
    public targetC: string

    @Mapping(MappingRequirement.REQUIRED)
    public targetD: string

}

class Source {
    public sourceA: string = 'to target A'
    public sourceB: string = 'to target B'
}

const mapper = new LightMapper()

const result = mapper
    .transform('targetA', value => value + ' transformed A')
    .transform('targetB', value => value + ' transformed B')
    .replace('targetC', 'replaced C')
    .replace('targetD', 'replaced D')
    .map(Target, new Source())

console.log(result)
/* Output
Target {
  targetA: 'to target A transformed by decorator transformed A',
  targetB: 'to target B transformed B',
  targetC: 'replaced C',
  targetD: 'replaced D' }
*/

Keywords

mapper

FAQs

Package last updated on 22 Feb 2021

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