Skip to content

Latest commit

 

History

History
64 lines (51 loc) · 1.37 KB

README.md

File metadata and controls

64 lines (51 loc) · 1.37 KB

next-map-to

Map source to target.

version license size download

installation

npm install -S @jswork/next-map-to

usage

import '@jswork/next-map-to';

const obj = {
  name: 'afeiship',
  age: 18,
  email: 'email@example.com'
};

const ctx1 = {};
const ctx2 = {
  set: function (key, value) {
    this[`kv_${key}`] = value;
  }
};

const res2 = nx.mapTo(obj, ctx);

/*
// res1
{
  name: 'afeiship',
  age: 18,
  email: 'email@example.com'
}

// res2
{
  set: [Function: set],
  kv_name: 'afeiship',
  kv_age: 18,
  kv_email: 'email@example.com'
}
*/

license

Code released under the MIT license.