mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
855 B
36 lines
855 B
9 years ago
|
var arrayConcat = require('./_arrayConcat'),
|
||
|
baseFlatten = require('./_baseFlatten'),
|
||
|
isArray = require('./isArray'),
|
||
|
rest = require('./rest');
|
||
|
|
||
|
/**
|
||
|
* Creates a new array concatenating `array` with any additional arrays
|
||
|
* and/or values.
|
||
|
*
|
||
|
* @static
|
||
|
* @memberOf _
|
||
|
* @category Array
|
||
|
* @param {Array} array The array to concatenate.
|
||
|
* @param {...*} [values] The values to concatenate.
|
||
|
* @returns {Array} Returns the new concatenated array.
|
||
|
* @example
|
||
|
*
|
||
|
* var array = [1];
|
||
|
* var other = _.concat(array, 2, [3], [[4]]);
|
||
|
*
|
||
|
* console.log(other);
|
||
|
* // => [1, 2, 3, [4]]
|
||
|
*
|
||
|
* console.log(array);
|
||
|
* // => [1]
|
||
|
*/
|
||
|
var concat = rest(function(array, values) {
|
||
|
if (!isArray(array)) {
|
||
|
array = array == null ? [] : [Object(array)];
|
||
|
}
|
||
|
values = baseFlatten(values);
|
||
|
return arrayConcat(array, values);
|
||
|
});
|
||
|
|
||
|
module.exports = concat;
|