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'
}
 

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.1
    1
  • 1.1.0
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i getters-to-props

Weekly Downloads

1

Version

1.1.1

License

ISC

Unpacked Size

4.28 kB

Total Files

6

Last publish

Collaborators

  • adjohnson916