@jswork/next-try-apply-get

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i @jswork/next-try-apply-get

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

5.04 kB

Total Files

5

Last publish

Collaborators

  • afeiship