mout
Version:
Modular Utilities
23 lines (19 loc) • 444 B
text/typescript
import indexOf from './indexOf';
/**
* Combines an array with all the items of another.
* Does not allow duplicates and is case and type sensitive.
*/
function combine(arr1, arr2) {
if (arr2 == null) {
return arr1;
}
let i = -1;
const len = arr2.length;
while (++i < len) {
if (indexOf(arr1, arr2[i]) === -1) {
arr1.push(arr2[i]);
}
}
return arr1;
}
export default combine;