Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

getters-to-props

1.1.1 • Public • Published

getters-to-props.js

Get simple properties from object of getters.

Install

Node

npm install --save getters-to-props

Bower (AMD, Global)

bower install --save getters-to-props

Use

var gettersToProps = require('getters-to-props');
 
var obj = {
  getThing: function () {
    return 1;
  },
  setThing: function () {},
  getMore: function () {
    return { another: 'yep' };
  },
  notMe: 'nope',
  getFailure: function () {
    throw new Error("oops");
  }
};
 
props = gettersToProps(obj);
 
// props is now:
{
  thing: 1,
  more: { another: 'yep' },
  failure: undefined
}
 
// or options, e.g. "others"
 
props = gettersToProps(obj, {
  others: true
});
 
// props is now:
{
  thing: 1,
  more: { another: 'yep' },
  failure: undefined,
  notMe: 'nope'
}
 

Install

npm i getters-to-props

DownloadsWeekly Downloads

2

Version

1.1.1

License

ISC

Unpacked Size

4.28 kB

Total Files

6

Last publish

Collaborators

  • avatar