# muder

> an object mapper

Latest version **0.2.0** (published 2016-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install muder
pnpm add muder
yarn add muder
bun add muder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-04-08 |
| First published | 2015-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | wahack |
| Maintainers | wahack |
| Keywords | object, mapper |

## Links

- npm: https://www.npmjs.com/package/muder
- Repository: https://github.com/wahack/muder
- Homepage: https://github.com/wahack/muder#readme
- Issues: https://github.com/wahack/muder/issues
- npm.io page: https://npm.io/package/muder

## Recent versions

- 0.2.0 (latest) — 2016-04-08
- 0.1.0 — 2015-10-10

## README

# muder
An  object-mapper easy to use.

## install
`npm install muder`

**usage**

    var muder = require('muder')

    var result = muder(source, mapper[, addon]);


For a full example check the `test/example*.js` file.



## example

**source object**

    {
      studentID: '123',
      firstName: 'liao',
      lastName: 'ethan',
      sex: 'male',
      age: '23',
      detailInfo: {
        classMates: [
          {
            studentID: '44',
            name: 'Lisa',
            sex: 'female'
          },
          {
            studentID: '55',
            name: 'Joe',
            sex: 'male'
          }
        ],
        tags: ['grade-two','good']
      }
    }

**mapper**

    {
      id: 'studentID|num',
      name: {
        firstName: 'firstName',
        lastName: 'lastName'
      },
      sex: 'sex',
      age: 'age|num',
      extra: {
        classMates: [
          {
            id: 'detailInfo.classMates[].studentID|num',
            name: 'detailInfo.classMates[].name',
            sex: 'detailInfo.classMates[].sex'
          }
        ],
        tags: [
          'detailInfo.tags[]'
        ]
      },
      sayHello: 'lastName|hello',
      sayMorning: function (source) {
        return 'Morning ' + source.lastName + ' ' +source.firstName;
      },
      constant: function() {
        return 'this is a constant';
      }
    }

**map the object**

      var result = muder(source, mapper,{
          hello: function (name) {
            return 'hello '+name;
          }
      });

**result**

    {
      id: 123,
      name: {
        firstName: 'liao',
        lastName: 'ethan'
      },
      sex: 'male',
      age: 23,
      extra: {
        classMates: [
          {
            id: 44,
            name: 'Lisa',
            sex: 'female'
          },{
            id: 55,
            name: 'Joe',
            sex: 'male'
          }
        ],
        tags: [
          'grade-two','good'
        ]
      },
      sayHello: 'hello ethan',
      sayMorning: 'Morning ethan liao',
      constant: 'this is a constant'
    }



**This project is inspired by**

https://github.com/imyelo/barrow

---
_Source: https://npm.io/package/muder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
