1.0.1 • Published 3 years ago

@jswork/next-try-apply-get v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

next-try-apply-get

Try to get value from target(fn) or target(other data).

version license size download

installation

npm install -S @jswork/next-try-apply-get

usage

import '@jswork/next-try-apply-get';

// 1. target is function
const target1 = (data) => {
  return { name: 'fei', ...data };
};

// 2. target is not a function
const target2 = { name: 'aric' };


// get the results
const res1 = nx.tryApplyGet(target1, [{ github: 'afeiship', hobby: 'coding' }]);
const res2 = nx.tryApplyGet(target2);

/*
// res1
{
  name: 'fei',
  github: 'afeiship',
  hobby: 'coding'
}

// res2
{ name: 'aric' }
*/

license

Code released under the MIT license.