lodash.concat
Advanced tools
Comparing version 4.1.1 to 4.2.0
94
index.js
/** | ||
* lodash 4.1.1 (Custom Build) <https://lodash.com/> | ||
* lodash 4.2.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modularize exports="npm" -o ./` | ||
* Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/> | ||
* Copyright jQuery Foundation and other contributors <https://jquery.org/> | ||
* Released under MIT license <https://lodash.com/license> | ||
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
*/ | ||
var baseFlatten = require('lodash._baseflatten'), | ||
rest = require('lodash.rest'); | ||
var baseFlatten = require('lodash._baseflatten'); | ||
@@ -37,2 +36,21 @@ /** | ||
/** | ||
* Copies the values of `source` to `array`. | ||
* | ||
* @private | ||
* @param {Array} source The array to copy values from. | ||
* @param {Array} [array=[]] The array to copy values to. | ||
* @returns {Array} Returns `array`. | ||
*/ | ||
function copyArray(source, array) { | ||
var index = -1, | ||
length = source.length; | ||
array || (array = Array(length)); | ||
while (++index < length) { | ||
array[index] = source[index]; | ||
} | ||
return array; | ||
} | ||
/** | ||
* Creates a new array concatenating `array` with any additional arrays | ||
@@ -43,2 +61,3 @@ * and/or values. | ||
* @memberOf _ | ||
* @since 4.0.0 | ||
* @category Array | ||
@@ -59,11 +78,58 @@ * @param {Array} array The array to concatenate. | ||
*/ | ||
var concat = rest(function(array, values) { | ||
if (!isArray(array)) { | ||
array = array == null ? [] : [Object(array)]; | ||
function concat() { | ||
var length = arguments.length, | ||
array = castArray(arguments[0]); | ||
if (length < 2) { | ||
return length ? copyArray(array) : []; | ||
} | ||
values = baseFlatten(values, 1); | ||
return arrayConcat(array, values); | ||
}); | ||
var args = Array(length - 1); | ||
while (length--) { | ||
args[length - 1] = arguments[length]; | ||
} | ||
return arrayConcat(array, baseFlatten(args, 1)); | ||
} | ||
/** | ||
* Casts `value` as an array if it's not one. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @since 4.4.0 | ||
* @category Lang | ||
* @param {*} value The value to inspect. | ||
* @returns {Array} Returns the cast array. | ||
* @example | ||
* | ||
* _.castArray(1); | ||
* // => [1] | ||
* | ||
* _.castArray({ 'a': 1 }); | ||
* // => [{ 'a': 1 }] | ||
* | ||
* _.castArray('abc'); | ||
* // => ['abc'] | ||
* | ||
* _.castArray(null); | ||
* // => [null] | ||
* | ||
* _.castArray(undefined); | ||
* // => [undefined] | ||
* | ||
* _.castArray(); | ||
* // => [] | ||
* | ||
* var array = [1, 2, 3]; | ||
* console.log(_.castArray(array) === array); | ||
* // => true | ||
*/ | ||
function castArray() { | ||
if (!arguments.length) { | ||
return []; | ||
} | ||
var value = arguments[0]; | ||
return isArray(value) ? value : [value]; | ||
} | ||
/** | ||
* Checks if `value` is classified as an `Array` object. | ||
@@ -73,6 +139,8 @@ * | ||
* @memberOf _ | ||
* @since 0.1.0 | ||
* @type {Function} | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. | ||
* @returns {boolean} Returns `true` if `value` is correctly classified, | ||
* else `false`. | ||
* @example | ||
@@ -79,0 +147,0 @@ * |
{ | ||
"name": "lodash.concat", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "The lodash method `_.concat` exported as a module.", | ||
@@ -18,5 +18,4 @@ "homepage": "https://lodash.com/", | ||
"dependencies": { | ||
"lodash._baseflatten": "~4.1.0", | ||
"lodash.rest": "^4.0.0" | ||
"lodash._baseflatten": "~4.1.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash.concat v4.1.1 | ||
# lodash.concat v4.2.0 | ||
@@ -18,2 +18,2 @@ The [lodash](https://lodash.com/) method `_.concat` exported as a [Node.js](https://nodejs.org/) module. | ||
See the [documentation](https://lodash.com/docs#concat) or [package source](https://github.com/lodash/lodash/blob/4.1.1-npm-packages/lodash.concat) for more details. | ||
See the [documentation](https://lodash.com/docs#concat) or [package source](https://github.com/lodash/lodash/blob/4.2.0-npm-packages/lodash.concat) for more details. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6706
1
149
1
- Removedlodash.rest@^4.0.0
- Removedlodash.rest@4.0.5(transitive)