UNPKG

508 BJavaScriptView Raw
1var indexOf = require('./indexOf');
2
3 /**
4 * Combines an array with all the items of another.
5 * Does not allow duplicates and is case and type sensitive.
6 */
7 function combine(arr1, arr2) {
8 if (arr2 == null) {
9 return arr1;
10 }
11
12 var i = -1, len = arr2.length;
13 while (++i < len) {
14 if (indexOf(arr1, arr2[i]) === -1) {
15 arr1.push(arr2[i]);
16 }
17 }
18
19 return arr1;
20 }
21 module.exports = combine;
22