Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

object-concat

wilmoore54MIT0.2.9

Assigns properties of source object(s) to a new object.

$.extend, Object.assign, Object.create, _.assign, _.extend, assign, callback, concat, concatenation, concatenative, concatenative inheritance, customizer, extend, inheritance, iteratee, jQuery.extend, lodash.extend, object, predicate, transform, underscore.extend

readme

object-concat

Assigns properties of source object(s) to a new object.

Build Status Code Climate js-standard-style

npm install object-concat --save
npm stats

npm NPM downloads Dependency Status

Example

basic
var concat = require('object-concat')

var defaults = { level: 1 }
var restored = { player: 'isaac', level: 5 }
var gamedata = concat(defaults, restored)

assert.equal(gamedata.player, 'isaac')
//=> undefined

assert.equal(gamedata.level, 5)
//=> undefined

assert.notDeepEqual(gamedata, defaults)
//=> undefined

assert.notDeepEqual(gamedata, restored)
//=> undefined
transform
var concat = require('object-concat')

var defaults = { level: 1 }
var restored = { player: 'isaac', level: 5 }
var gamedata = concat(defaults, restored, function (key, sourceVal, targetVal) {
  return key === 'player' ? sourceVal.toUpperCase() : sourceVal
})

assert.equal(gamedata.player, 'ISAAC')
//=> 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)
  • 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.

Licenses

GitHub license

changelog

Change Log

All notable changes to this project will be documented in this file (keepachangelog.com).

0.2.9 - 2015-05-22

Added

  • Concatenative inheritance.

0.2.8 - 2015-05-22

Added

  • keywords.

0.2.7 - 2015-05-06

Changed

  • removed semi-colon from examples.

0.2.6 - 2015-04-29

Added

  • fixpack.

0.2.5 - 2015-04-28

Added

  • add .gitattributes.

Changed

  • update .travis.yml.
  • reog badges.

0.2.4 - 2015-04-24

Changed

  • changed readme example to use correct signature for example iteratee function.

0.2.3 - 2015-04-23

Removed

  • removed related section from readme.

0.2.2 - 2015-04-23

Changed

  • undefined to void 0

0.2.1 - 2015-04-23

Changed

  • "standard": "^3.7.1"
  • "tape": "^4.0.0"

0.2.0 - 2015-04-23

Added

  • Added Related section to readme.

Changed

  • Re-arranged iteratee parameter order from (key, targetVal, sourceVal) to (key, sourceVal, targetVal).

0.1.0 - 2015-04-22

Added

  • Initial Version.