default-prop

1.0.0 • Public • Published

Default Prop

Create an iterable function that assigns a default value to given property name

Installation

npm install default-prop --save

Usage

var defaultProp = require('default-prop')
 
var accounts = [{
    name: 'alice',
    inUse: true
  },{
    name: 'bob'
  },{
    name: 'charlie'
  }]
 
accounts.forEach(defaultProp('inUse', false))
 
console.log(accounts)
// =>
// accounts = [{
//     name: 'alice',
//     inUse: true
//   },{
//     name: 'bob',
//     inUse: false
//   },{
//     name: 'charlie',
//     inUse: false
//   }]

License

MIT

Package Sidebar

Install

npm i default-prop

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • whoaa