How to use the union function from lodash
Find comprehensive JavaScript lodash.union code examples handpicked from public code repositorys.
5766 5767 5768 5769 5770 5771 5772 5773 5774 5775
* @category Arrays * @param {...Array} [array] The arrays to inspect. * @returns {Array} Returns an array of combined values. * @example * * _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]); * // => [1, 2, 3, 5, 4] */ function union() { return baseUniq(baseFlatten(arguments, true, true));
73
711
29
408 409 410 411 412 413 414 415 416 417
module.exports.truncate = _.truncate; module.exports.truthy = _.truthy; module.exports.truthyAll = _.truthyAll; module.exports.unary = _.unary; module.exports.unescape = _.unescape; module.exports.union = _.union; module.exports.unionBy = _.unionBy; module.exports.unionWith = _.unionWith; module.exports.uniq = _.uniq; module.exports.uniqBy = _.uniqBy;
19
122
0
+ 92 other calls in file
GitHub: flickz/newspaperjs
100 101 102 103 104 105 106 107 108 109
} } } } } return _.union(categoriesUrl); }; exports._getArticlesUrl = function ($, categoryUrl) { const articlesUrl = [];
19
66
4
+ 31 other calls in file
GitHub: sergeyksv/tinelic
71 72 73 74 75 76 77 78 79 80
mod = require(mpath); } if (!mod) return cb(new Error("Can't not load module " + module.name)); var args = _.clone(module.deps || []); args = _.union(mod.deps || [],args); _.each(args, function (m) { requested[m]=1; }); args.push(function (cb) {
11
77
6
113 114 115 116 117 118 119 120 121 122
} }); } }; plugins = _.union(config.js.base, fs.readdirSync('./js')); jsEntry += '\'use strict\';\n\n' + 'var $ = require(\'jquery\');\n'; plugins.forEach(function(plugin, i) {
10
26
5
13 14 15 16 17 18 19 20 21 22
return a; } return _.clone(a); }, union: (target, sources, isObject) => { var rs = _.union(_.clone(target), sources); var getKey = (obj) => { return Object.keys(obj).find(e => { return e.indexOf('_') === -1; });
1
7
3
+ 3 other calls in file
354 355 356 357 358 359 360 361 362 363
if(origparentmodel.onroute) parentmodel.onroute = origparentmodel.onroute; model._inherits = parentmodel._inherits.concat([model.inherits]); if(!_.includes(model.using, parentmodel.namespace)) model.using.push(parentmodel.namespace); //Add Parent Model Groups model.groups = _.union(parentmodel.groups, model.groups); model.using = _.union(parentmodel.using, model.using); //Merge Models //Extend this to enable delete existing values by making them NULL
5
5
2
34 35 36 37 38 39 40 41 42 43
let allIngredients = [] L.map(e => e[0].map(f=>allIngredients.push(f))) let possible = [...allAllergens].map(a => { return _.intersection(...L.filter(e => e[1].includes(a)).map(e => e[0])) }) let canHaveAllergen = _.union(...possible) let none = allIngredients.filter(e => !canHaveAllergen.includes(e)) clog(allAllergens) clog(possible) clog(none.length)
1
4
3
GitHub: mdmarufsarker/lodash
150 151 152 153 154 155 156 157 158 159 160 161 162
console.log(takeRightWhile); // => [2, 3] const takeWhile = _.takeWhile([1, 2, 3], n => n < 3); console.log(takeWhile); // => [1, 2] const union = _.union([2], [1, 2]); console.log(union); // => [2, 1] const unionBy = _.unionBy([2.1], [1.2, 2.3], Math.floor); console.log(unionBy); // => [2.1, 1.2]
0
4
0
+ 15 other calls in file
GitHub: sluukkonen/iiris
687 688 689 690 691 692 693 694 695 696
const clone = _.clone(arr) const nativeUnion = (xs, ys) => Array.from(new Set([...xs, ...ys])) return { iiris: () => A.from(S.union(S.from(arr), S.from(clone))), ramda: () => R.union(arr, clone), lodash: () => _.union(arr, clone), native: () => nativeUnion(arr, clone), } }, },
1
31
0
26 27 28 29 30 31 32 33 34 35
const { blackLists } = await blacklistModel .find({ user: { $in: admins } }, { followLists: 1, blackList: 1 }); _.forEach(blackLists, (el) => { followList = _.union(followList, el.followLists); resultBlacklist = _.union(resultBlacklist, el.blackList); }); const { result: muted } = await mutedModel.find({ condition: { mutedBy: { $in: admins } }, select: { userName: 1 },
0
3
3
+ 2 other calls in file
GitHub: fivefog/G_design
67 68 69 70 71 72 73 74 75
if (item2.down_num === undefined) { item2.num = item2.s_num item2.down_num = 0 //下架数量 } result3 = _.union(result3, result4) //合并 result3 = _.unionBy(result3, 'g_id') //完全去重 }); })
0
2
1
GitHub: Eveble/eveble
6355 6356 6357 6358 6359 6360 6361 6362 6363 6364
for (const command of commit.commands) { serializedCommit.commands.push({ type: command.getTypeName(), data: this.serializer.toData(command), }); serializedCommit.commandTypes = lodash.union(serializedCommit.commandTypes, [ command.getTypeName(), ]); } for (const receiver of commit.receivers) {
0
2
0
+ 9 other calls in file
438 439 440 441 442 443 444 445 446 447
*/ findAll: function findAll(options) { options = options || {}; // fetch relations passed to options.include options.withRelated = _.union(options.withRelated, options.include); return ghostBookshelf.Model.findAll.call(this, options); }, /**
0
1
2
+ 3 other calls in file
276 277 278 279 280 281 282 283 284 285
data = this.filterData(data); // Support finding by role if (lookupRole) { options.withRelated = _.union(options.withRelated, ['roles']); options.include = _.union(options.include, ['roles']); query = this.forge(data, {include: options.include}); query.query('join', 'roles_users', 'users.id', '=', 'roles_users.id');
0
1
2
+ 6 other calls in file
GitHub: kosinix/hris
144 145 146 147 148 149 150 151 152 153
} if (res.user.roles.includes('campusdirectormosqueda')) { employeesForThisCampuses = lodash.union(employeesForThisCampuses, ['mosqueda']) } if (res.user.roles.includes('campusdirectorbaterna')) { employeesForThisCampuses = lodash.union(employeesForThisCampuses, ['baterna']) } if (employeesForThisCampuses.length > 0) { let employments = await req.app.locals.db.main.Employment.find({
0
1
0
+ 5 other calls in file
GitHub: DenzelHopkins/ghost
363 364 365 366 367 368 369 370 371 372
* that event listeners have to re-fetch a resource. This function is used in the context of inserting * and updating resources. We won't return the relations by default for now. */ defaultRelations: function defaultRelations(methodName, options) { if (['edit', 'add', 'destroy'].indexOf(methodName) !== -1) { options.withRelated = _.union(['labels'], options.withRelated || []); } return options; },
0
0
1
102 103 104 105 106 107 108 109 110 111
* @return {Promise<brebuildCssResult>} * */ function prebuildCss(pagesInfo) { console.log('prebuildCss'); const modules = _.union.apply(null, pagesInfo.map(page => page.modules)); const pages = pagesInfo.map(page => page.name); const cssFiles = collectFiles('styl', pages, modules); return Promise.all(cssFiles.map(css.convert)).then(modulesCssInfo => ({ pagesInfo, modulesCssInfo})); }
0
0
2
+ 5 other calls in file
54 55 56 57 58 59 60 61 62 63
const def = definition.load(item, null, resp, null); distribution = def.distribution; } prev = item; results = _.union(results, [item]); return; } /* Ignore the deps pattern if it's the first entry. */
0
0
5
+ 27 other calls in file
GitHub: pappukrs/nodash-lib
221 222 223 224 225 226 227 228 229 230
// const arrq2 = [2, -5, 7, 8, 10, 1]; // const arrq3 = [-1, 2, 3, 4, 5, 1]; // const arrq4 = [9, 10, 11, 12, 13, 14, 1, 2]; // console.log( // "unique value identified", // lodash.union(arrq1, arrq2, arrq3, arrq4) // ); // console.log( // "unique value intersection", // lodash.intersection(arrq1, arrq2, arrq3, arrq4)
0
0
0
+ 4 other calls in file
lodash.get is the most popular function in lodash (7670 examples)