0.2.1 • Published 2 months ago

@stdlib/object-assign v0.2.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

assign

NPM version Build Status Coverage Status

Copy enumerable own properties from one or more source objects to a target object.

Installation

npm install @stdlib/object-assign

Usage

var assign = require( '@stdlib/object-assign' );

assign( target, source1[, source2[,...,sourceN]] )

Copies enumerable own properties from one or more source objects to a target object.

var x = {
    'a': 'beep'
};
var y = {
    'b': 'boop'
};

var z = assign( x, y );

var v = z.b;
// returns 'boop'

var bool = ( z === x );
// returns true

Notes

  • If a property key is present in multiple sources, the property from the last source that defines the key prevails.
  • The target object is mutated.

Examples

var assign = require( '@stdlib/object-assign' );

var obj1 = {
    'name': 'Jane',
    'age': 29
};
var obj2 = {
    'country': 'US',
    'city': 'San Francisco'
};
var obj3 = {
    'hobby': 'Reading'
};

var result = assign( obj1, obj2, obj3 );
// returns { 'name': 'Jane', 'age': 29, 'country': 'US', 'city': 'San Francisco', 'hobby': 'Reading' }

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.

@everything-registry/sub-chunk-869@stdlib/streams-node-debug@stdlib/streams-node-debug-sink@stdlib/streams-node-empty@stdlib/streams-node-from-array@stdlib/streams-node-from-iterator@stdlib/streams-node-from-strided-array@stdlib/streams-node-inspect@stdlib/streams-node-inspect-sink@stdlib/streams-node-join@stdlib/streams-node-split@stdlib/streams-node-transform@stdlib/streams-node-from-circular-array@stdlib/streams-node-from-constant@stdlib/random-iter-bernoulli@stdlib/fs-read-file-list@stdlib/ndarray-base-flags@stdlib/random-base-negative-binomial@stdlib/random-base-t@stdlib/random-base-gamma@stdlib/random-iter-beta@stdlib/random-iter-betaprime@stdlib/random-iter-binomial@stdlib/random-iter-box-muller@stdlib/random-iter-cauchy@stdlib/random-iter-chi@stdlib/random-iter-chisquare@stdlib/random-iter-cosine@stdlib/random-iter-discrete-uniform@stdlib/random-iter-erlang@stdlib/random-base-beta@stdlib/random-iter-arcsine@stdlib/array-to-fancy@stdlib/random-streams-logistic@stdlib/random-streams-lognormal@stdlib/random-streams-minstd@stdlib/random-streams-minstd-shuffle@stdlib/random-streams-mt19937@stdlib/random-streams-negative-binomial@stdlib/random-streams-normal@stdlib/random-streams-pareto-type1@stdlib/random-streams-poisson@stdlib/random-streams-randi@stdlib/random-streams-gamma@stdlib/random-streams-geometric@stdlib/random-streams-gumbel@stdlib/random-streams-hypergeometric@stdlib/random-streams-improved-ziggurat@stdlib/random-streams-invgamma@stdlib/random-streams-kumaraswamy@stdlib/random-streams-laplace@stdlib/random-streams-levy@stdlib/random-streams-binomial@stdlib/random-streams-box-muller@stdlib/random-streams-cauchy@stdlib/random-streams-chi@stdlib/random-streams-chisquare@stdlib/random-streams-cosine@stdlib/random-streams-discrete-uniform@stdlib/random-streams-erlang@stdlib/random-streams-exponential@stdlib/random-streams-f@stdlib/random-streams-frechet@stdlib/random-iter-rayleigh@stdlib/random-iter-t@stdlib/random-iter-triangular@stdlib/random-iter-uniform@stdlib/random-iter-weibull@stdlib/random-streams-arcsine@stdlib/random-streams-bernoulli@stdlib/random-streams-beta@stdlib/random-streams-betaprime@stdlib/random-iter-exponential@stdlib/random-iter-f@stdlib/random-iter-frechet@stdlib/random-iter-gamma@stdlib/random-iter-geometric@stdlib/random-iter-gumbel@stdlib/random-iter-hypergeometric@stdlib/random-iter-improved-ziggurat@stdlib/random-iter-invgamma@stdlib/random-iter-kumaraswamy@stdlib/random-iter-laplace@stdlib/random-iter-levy@stdlib/random-iter-logistic@stdlib/random-iter-lognormal@stdlib/random-iter-minstd@stdlib/random-iter-minstd-shuffle@stdlib/random-iter-mt19937@stdlib/random-streams-randn@stdlib/random-streams-randu@stdlib/random-streams-rayleigh@stdlib/random-streams-t@stdlib/random-streams-triangular@stdlib/random-streams-uniform@stdlib/random-streams-weibull@stdlib/random-iter-negative-binomial@stdlib/random-iter-normal@stdlib/random-iter-pareto-type1@stdlib/random-iter-poisson
0.2.1

2 months ago

0.2.0

3 months ago

0.1.0

8 months ago