1.0.2 • Published 6 years ago

lodash-extendall v1.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Lodash extendall

Build Status Known Vulnerabilities NPM version

Extend Lodash to allow all objects in an array of objects to be extended i.e. to have new properties added or existing properties updated based on input object properties. Returns a new array with the original array left unchanged.
Does minimal checking of inputs; assumes the array is an array of objects.

_.extendAll(arr, obj)

Arguments
arr (array): The array of objects to be extended. Required.
obj (object): The object to be used to extend each object in the array. Where a property in this object doesn't exist in the array object it will be added. Where it does exist it will be replaced.

Returns
(array): An new array of extended objects.

Examples

var _ = require('lodash')
require('lodash-extendall')

_.extendAll([{a:1, b:2},{a:3, b:4}], {x:'new1', y:'new2'}) // [{a:1, b:2, x:'new1', y:'new2'},{a:3, b:4, x:'new1', y:'new2'}]
_.extendAll([{a:1, b:2},{a:3, b:4}], {a:999, x:'new1'}) // [{a:999, b:2, x:'new1'},{a:999, b:4, x:'new1'}]
_.extendAll([{a:1, b:2},{a:3, b:4}], {}}) // [{a:1, b:2},{a:3, b:4}]
_.extendAll([{a:1, b:2},{a:3, b:4}], ['abc']) // [{a:1, b:2},{a:3, b:4}]
_.extendAll([]], {a:false, x:false}) // []
_.extendAll([{a:1, b:2},{a:3}], {b:false}) // [{a:1, b:false},{a:3, b:false}]

Version History

VersionRelease DateDetails
1.0.227th February, 2018Update the Version History. No functionality changes.
1.0.127th February, 2018Fix layout issues with Examples in the README. No functionality changes.
1.0.026th February, 2018Initial release.