]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/vim-mode/node_modules/grim/node_modules/emissary/node_modules/es6-weak-map/node_modules/es5-ext/array/#/intersection.js
fadcb525308964d4782bd6182b9a69f6e53f0ec8
[rbdr/dotfiles] / atom / packages / vim-mode / node_modules / grim / node_modules / emissary / node_modules / es6-weak-map / node_modules / es5-ext / array / # / intersection.js
1 'use strict';
2
3 var value = require('../../object/valid-value')
4 , contains = require('./contains')
5 , byLength = require('./_compare-by-length')
6
7 , filter = Array.prototype.filter, push = Array.prototype.push
8 , slice = Array.prototype.slice;
9
10 module.exports = function (/*…list*/) {
11 var lists;
12 if (!arguments.length) slice.call(this);
13 push.apply(lists = [this], arguments);
14 lists.forEach(value);
15 lists.sort(byLength);
16 return lists.reduce(function (a, b) {
17 return filter.call(a, function (x) { return contains.call(b, x); });
18 });
19 };