default-prop
v1.0.0
Published
Create an iterable function that assigns a default value to given property name
Downloads
1
Maintainers
Readme
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