@appveen/data-mapper

1.1.0 • Public • Published

ds-mapper

A Node JS Based Data Mapping Library.

Install

npm i @appveen/data-mapper

How it works

const Mapper = require("@appveen/data-mapper");

(async () => {

const mappings = [....]; // Mapping JSON

  const mapper = new Mapper('first-mapper', mappings, {
    //Additional Libraries or Objects you want to use
  });

  const result = await mapper.convert({
      firstName: "John",
      lastName: "Doe",
      email: "johndoe@gmail.com"
    });

  console.log(result);
})();

Mapping JSON

The Mapping JSON Contains a data path, This data path follows LoDash Library Data Path pattern.

[
  {
    source: [
      {
        type: "String",
        dataPath: "firstName",
      },
      {
        type: "String",
        dataPath: "lastName",
      },
    ],
    target: {
      type: "String",
      dataPath: "name",
    },
    formula: "return input1 + ' ' +input2;",
  },
];

User can write a JS code block in the formula to do much more.

Example

Check example.js in the repo.

LICENSE

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @appveen/data-mapper

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

6.9 kB

Total Files

5

Last publish

Collaborators

  • appveen