UNPKG

mout

Version:

Modular Utilities

15 lines (13 loc) 396 B
define(['./difference', '../lang/toArray'], function (difference, toArray) { /** * Insert item into array if not already present. */ function insert(arr, rest_items) { var diff = difference(toArray(arguments).slice(1), arr); if (diff.length) { Array.prototype.push.apply(arr, diff); } return arr.length; } return insert; });