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

@witty-services/ts-mapperize

v1.0.3

Published

Typescript mapping library

Downloads

14

Readme

TS-Mapperize

ts-mapperize-ci Coverage Status npm version GitHub GitHub repo size GitHub last commit GitHub issues GitHub top language

Informations

:warning: Since version 1.0.2, ts-mapperize has been published under @paddls namespace. We continue to maintain @witty-services namespace.

Get Started

Install

npm install @paddls/ts-mapperize

or

npm install @witty-services/ts-mapperize

Create simple mapper

class A {
  a: string;
}

class B {
  b: string;
}


class MyMapper {

    @Mapper(() => B, [
      {target: 'b', source: 'a'}
    ])
    public mapAToB: MapperFn<A, B>;
  
}

const mapper: MyMapper = new MyMapper();

mapper.mapAToB(new A())
// should return B{ b: '...' }

Working with array

Define all mapping behavior

class A {
  a: string;
}

class B {
  b: string;
}


class MyMapper {

    @ArrayMapper(() => B, [
      {target: 'b', source: 'a'}
    ])
    public mapAToB: ArrayMapperFn<A, B>;
  
}

const mapper: MyMapper = new MyMapper();

mapper.mapAToB([new A()])
// should return [B{ b: '...' }]

Reuse behavior from function

class A {
  a: string;
}

class B {
  b: string;
}


class MyMapper {

    @Mapper(() => B, [
      {target: 'b', source: 'a'}
    ])
    public mapAToB: MapperFn<A, B>;

    @ArrayMapper('mapAToB')
    public mapAToBArray: ArrayMapperFn<A, B>;
  
}

const mapper: MyMapper = new MyMapper();

mapper.mapAToBArray([new A()])
// should return [B{ b: '...' }]

API

MapperParamContext

Argument | Type | Required | Description ---------|------|----------|------------ source | string, keyof<Input> | false | select from the input, the value to be mapped target | string, keyof<Output> | false | select the destination of the value inside the output object customTransformer | (() => new(...args: any[]) => CustomTransformer<any, any>) | false | use an existing CustomTransformer class transform | (input: any) => any | false | custom function to map value from selected source to target type | () => new(...args: any[]) => any | false | type of the child object params | MapperParamContext<any, any>[] | false | list of mapping information for child object

How to run Unit Tests

To run unit tests and generate coverage with Jest, run :

npm run test