object-concat
Assigns properties of source object(s) to a new object.
npm install object-concat --save
npm stats
Example
basic
var concat = var defaults = level: 1 var restored = player: 'isaac' level: 5 var gamedata = assert//=> undefined assert//=> undefined assert//=> undefined assert//=> undefined
transform
var concat = var defaults = level: 1 var restored = player: 'isaac' level: 5 var gamedata = assert//=> undefined
Features
- Concatenative inheritance.
- Return a new object instead of mutating a
target
object. - Subsequent source properties overwrite previous.
- Supports optional
iteratee
function allowing transformation of target values.
Anti-Features
- Will never make you seed your parameter list with an empty object:
- No
_.extend({}, source)
- No
- Will never mutate existing objects.
- Will never overwrite native
Object
prototype methods (i.e.Object.assign
polyfills).
API
concat([sources], [iteratee])
Arguments
[sources]: (…Object)
The source objects.[iteratee]: (Function)
Function that produces desired target value (must be last parameter).key: (String)
Object key name.sourceVal: (*)
Object source value.targetVal: (*)
Object target value.
Returns
(Object)
The new object.
Alternatives
Most, if not all of the alternatives listed have varying semantics so be careful which you choose for your own applications.