mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
21 lines
452 B
JavaScript
21 lines
452 B
JavaScript
/**
|
|
* 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) {
|
|
let index = -1
|
|
const length = source.length
|
|
|
|
array || (array = new Array(length))
|
|
while (++index < length) {
|
|
array[index] = source[index]
|
|
}
|
|
return array
|
|
}
|
|
|
|
export default copyArray
|