Sha256: 88d9e3b846097b973de5ffce1e2fc9d154508ebba0633b86633061760291a8b4
Contents?: true
Size: 900 Bytes
Versions: 10
Compression:
Stored size: 900 Bytes
Contents
/*! * arr-diff <https://github.com/jonschlinkert/arr-diff> * * Copyright (c) 2014 Jon Schlinkert, contributors. * Licensed under the MIT License */ 'use strict'; var slice = require('array-slice'); /** * Expose `diff` */ module.exports = diff; /** * Return the difference between the first array and * additional arrays. * * ```js * var diff = require('{%= name %}'); * * var a = ['a', 'b', 'c', 'd']; * var b = ['b', 'c']; * * console.log(diff(a, b)) * //=> ['a', 'd'] * ``` * * @param {Array} `a` * @param {Array} `b` * @return {Array} * @api public */ function diff(a, b, c) { var len = a.length; var arr = []; var rest; if (!b) { return a; } if (!c) { rest = b; } else { rest = [].concat.apply([], slice(arguments, 1)); } while (len--) { if (rest.indexOf(a[len]) === -1) { arr.unshift(a[len]); } } return arr; }
Version data entries
10 entries across 10 versions & 1 rubygems