module.exports = function(gulp, config) { var tasks = _.intersection(_.keys(gulp.tasks), ['bower:install', 'bower:prune']); var bowerFilesOptions = { paths: { bowerJson: config.build.bowerjson }, filter: /\.js$/i }; gulp.task('bowerScripts', tasks, function() { var result = gulp.src(bowerFiles(bowerFilesOptions)) .pipe(gulpif(config.build.bowerDebug, debug())) .pipe(sourceMaps.init()) .pipe(gulpif(isFirstRun, newer(config.bowerScripts.dest + vendorFile))) .pipe(concat(vendorFile)) .pipe(gulpif(config.build.uglify, uglify())) .pipe(gulpif(config.build.rev, rev())) .pipe(sourceMaps.write(config.build.sourceMapPath)) .pipe(gulp.dest(config.bowerScripts.dest)) .pipe(gulpif(config.build.rev, rev.manifest({cwd: config.statics.dest, merge: true}))) .pipe(gulpif(config.build.rev, gulp.dest(config.statics.dest))); isFirstRun = false; return result; }); };
_getDidLabelsChange(newLabels, oldLabels) { oldLabels = oldLabels ? oldLabels.labels : []; oldLabels = oldLabels || []; const newLabelNames = newLabels.map(({name}) => name); const oldLabelNames = oldLabels.map(({name}) => name); return _.intersection(oldLabelNames, newLabelNames).length !== newLabels.length; }
.then(function() { // Upgrading! // We don't want the pre/post prepare hooks to fire during upgrade. hooks.unregisterHooks(); // Remove the old file based pre/post prepare hooks // TODO: Remove this later. Last version to use file based hooks was 4.0.0 released in Oct 2014. shelljs.rm('-f', path.join('hooks', 'before_prepare', 'cca-pre-prepare.js')); shelljs.rm('-f', path.join('hooks', 'after_prepare', 'cca-post-prepare.js')); // Remember what platforms we had before deleting them. If we only had one, don't install the other after upgrade. hadPlatforms = getInstalledPlatfroms(); shelljs.rm('-rf', 'platforms'); shelljs.rm('-f', path.join('plugins', 'android.json')); shelljs.rm('-f', path.join('plugins', 'ios.json')); var installedPlugins = cordova.cordova_lib.PluginInfo.loadPluginsDir('plugins'); installedPlugins = __.pluck(installedPlugins, 'id'); // Only remove the CCA managed plugins var allCcaPlugins = getCcaPlugins(); var pluginsToRemove = __.intersection(allCcaPlugins, installedPlugins); if (pluginsToRemove && pluginsToRemove.length) { return require('./cordova-commands').runCmd(['plugin', 'rm', pluginsToRemove]); } })
function findCommonAncestorId (moduleId1, moduleId2) { var array1 = [] var array2 = [] var module1 = resourceMap[moduleId1] var module2 = resourceMap[moduleId2] var commonAncestorId = null while (true) { if (!module1) break array1.push(moduleId1) moduleId1 = module1.parentModuleId module1 = resourceMap[moduleId1] } while (true) { if (!module2) break array2.push(moduleId2) moduleId2 = module2.parentModuleId module2 = resourceMap[moduleId2] } commonAncestorId = _.intersection(array1, array2)[0] return commonAncestorId || null }
Cartero.prototype.writeIndividualAssetsToDisk = function( thePackage, assetTypesToWriteToDisk, callback ) { var _this = this; var outputDirectoryPath = this.getPackageOutputDirectory( thePackage ); assetTypesToWriteToDisk = _.intersection( assetTypesToWriteToDisk, Object.keys( thePackage.assetsByType ) ); async.each( assetTypesToWriteToDisk, function( thisAssetType, nextAssetType ) { async.each( thePackage.assetsByType[ thisAssetType ], function( thisAsset, nextAsset ) { var thisAssetDstPath = path.join( _this.outputDirPath, _this.assetMap[ path.relative( _this.appRootDir, thisAsset.srcPath ) ] ); // assetMap contains path starting from fingerprint folder if( thisAssetType === 'style' ) thisAssetDstPath = renameFileExtension( thisAssetDstPath, '.css' ); thisAsset.writeToDisk( thisAssetDstPath, function( err ) { if( err ) return nextAsset( err ); _this.applyPostProcessorsToFiles( [ thisAssetDstPath ], function( err ) { if( err ) return nextAsset( err ); _this.emit( 'fileWritten', thisAssetDstPath, thisAssetType, false, _this.watching ); // why were we doing this? metaData does not contain references to individual assets // if( _this.watching ) _this.writeMetaDataFile( function() {} ); nextAsset(); } ); } ); }, nextAssetType ); }, callback ); };
, mods: function(data) { var self = this; var onlineStaff = []; var realModerators = []; _.toArray(self.room.staff).forEach(function(staffMember) { if ( self.room.staff[staffMember.plugID].role > 1 ) { realModerators.push(staffMember); } }); _.intersection( _.toArray(realModerators).map(function(staffMember) { return staffMember._id.toString(); }), _.toArray(self.room.audience).map(function(audienceMember) { return audienceMember._id.toString(); }) ).forEach(function(staffMember) { onlineStaff.push(staffMember); }); Person.find({ _id: { $in: onlineStaff } }).exec(function(err, staff) { self.chat(staff.length + ' online staff members: ' + staff.map(function(staffMember) { console.log(staffMember); console.log(self.room.staff); //return staffMember.name + self.room.staff[staffMember.plugID].role; return '@' + staffMember.name; }).join(', ') ); }); }
module.exports = function(gulp, config, browserSync) { var tasks = _.intersection(_.keys(gulp.tasks), ['fonts']); gulp.task('styles', tasks, function () { var optionsSass = { outputStyle: 'compressed', importer: nodeSassGlobbing }; if (config.build.rev && config.fonts) { var optionsRev = { manifest: gulp.src('./' + config.fonts.dest + 'rev-manifest.json') }; } return gulp.src(config.styles.src) .pipe(sourceMaps.init()) .pipe(gulpif(config.preprocess && config.preprocess.apply.styles, preprocess(config.preprocess))) .pipe(sass(optionsSass).on('error', sass.logError)) .pipe(autoPrefixer(config.styles.prefixer)) .pipe(gulpif(config.build.rev && config.fonts, revReplace(optionsRev))) .pipe(gulpif(config.build.rev, rev())) .pipe(sourceMaps.write(config.build.sourceMapPath)) .pipe(gulp.dest(config.styles.dest)) .pipe(browserSync.stream({match: '**/*.css'})) .pipe(gulpif(config.build.rev, rev.manifest({cwd: config.statics.dest, merge: true}))) .pipe(gulpif(config.build.rev, gulp.dest(config.statics.dest))); }); };
var hasFood = function(ev) { // split the words in price by regex var words = ev.price.toLowerCase().split(re); // if intersection with keywords nonempty, then got food var match = _.intersection(keywords, words); return !(match.length == 0); }
}, function (err, rows) { if (_.isNull(rows)) rows = []; if (rows.length == 0) { var retData = translateSingle ? _.first(sourceData) : sourceData; cb(err, retData); } else { if (_.isEmpty(fields)) { var indexes_source = _.keys(_.first(sourceData)); var indexes_translation = _.keys(_.first(rows)); var common_indexes = _.intersection(indexes_translation, indexes_source); fields = _.object(common_indexes, common_indexes); } // Apply translate row to source data. _.each(rows, function (translateRow) { // fields object : {sourceField: translateField} // example: {taxonomies_title: title} _.each(fields,function (translateField, sourceField) { _.each(sourceData, function (sourceDataItem, index) { if (getPrimaryValue(tablename, key, sourceDataItem) == translateRow[key]) { sourceData[index][sourceField] = translateRow[translateField]; } }); }) }); var retData = translateSingle ? _.first(sourceData) : sourceData; cb(err, retData); } });
function getWhitelistLinks(meta, rels) { var result = []; var sources = _.intersection(rels, CONFIG.KNOWN_SOURCES); if (sources.length == 0 && rels.indexOf("player") > -1) { // Skip single player rel. } else { sources.forEach(function(source) { CONFIG.REL[source].forEach(function(type) { var iframelyType = CONFIG.REL_MAP[type] || type; if (rels.indexOf(iframelyType) > -1) { result.push({ source: source, type: type }); } }); }); } return result; }
combinations.forEach(function(combo){ var int = _.intersection(pMoves, combo); if(_.isEqual(int, combo)){ win = true; winner = player; } });
function checkRow(row){ row.occur_time = validator.trim(row.occur_time); row.duration_time = validator.trim(row.duration_time); row.bussiness = validator.trim(row.bussiness); row.comment = validator.trim(row.comment); if (!row.occur_time || !row.duration_time || !row.bussiness) { return null; } if(!validator.isDate(row.occur_time) || validator.isAfter(row.occur_time)){ return null; } if(!validator.isInt(row.duration_time) || row.duration_time < 0){ return null; } var buss = getAllBuss(); var bussiness = row.bussiness.split(/[\s,;]+/g); row.bussiness = _.intersection(buss, bussiness); if(row.bussiness.length < 1){ return null; } if(row.comment.indexOf('�') != -1){ console.log('errcode:----' + row.comment); return null; } return row; }
exports.add = function(req, res, next) { var occur_time = validator.trim(req.body.occur_time); var duration_time = validator.trim(req.body.duration_time); var bussiness = validator.trim(req.body.bussiness); var comment = validator.trim(req.body.comment); if (!occur_time || !duration_time || !bussiness || bussiness.split(',').length < 1) { res.render('risk_event/add', {error: "数据不完整。", occur_time: occur_time, duration_time: duration_time, bussiness: bussiness, comment: comment}); return; } if(!validator.isDate(occur_time) || validator.isAfter(occur_time)){ res.render('risk_event/add', {error: "occurTime格式不正确或者晚于现在时间", occur_time: occur_time, duration_time: duration_time, bussiness: bussiness, comment: comment}); return; } if(!validator.isInt(duration_time) || duration_time < 0){ res.render('risk_event/add', {error: "请输入正整数", occur_time: occur_time, duration_time: duration_time, bussiness: bussiness, comment: comment}); return; } bussiness = bussiness.split(','); var busss = getAllBuss(); bussiness = _.intersection(bussiness, busss); if(bussiness.length < 1){ res.render('risk_event/add', { error: '请选择正确的bussiness' }); } RiskEvent.newAndSave(occur_time, duration_time, bussiness, comment, function(err){ if(err){ return next(err); } res.render('risk_event/add', { success: '添加成功 ' }); }); }
joola.dispatch.collections.get(context, workspace, collection, function (err, _collection) { if (err) return callback(err); var result = _.filter(_collection.metrics, function (item) { return item.key === key; }); if (!result || typeof result === 'undefined' || result === null || result.length === 0) return callback(new Error('metric [' + key + '] does not exist.')); result = result[0]; var hasRole = false; if (joola.config.get('authentication:requireroles') === false) hasRole = ['anonymous']; else hasRole = _.intersection(context.user.roles, result.roles); if (hasRole.length > 0) return callback(null, result); else { var directaccesserr = new Error('Forbidden'); directaccesserr.code = 403; return callback(directaccesserr); } });
client.listMachines(function(err, machines) { if (err) { return callback(err); } var toDelete = names; var existing = []; _.each(machines, function(machine) { existing.push(machine.name); }); var remaining = _.intersection(toDelete, existing); var deleted = _.difference(toDelete, existing); _.each(deleted, function(machineName) { if (!_.contains(_deleted, machineName)) { slapchop.util.log(machineName, 'I am deleted', 'green'); _deleted.push(machineName); } }); if (remaining.length > 0) { if (_i !== 0 && _i % 5 === 0) { log('slapchop', 'Still waiting for ' + remaining.length + ' machines to be deleted'); } return setTimeout(_monitorDeleted, 1000, client, names, callback, _deleted, _i + 1); } else { return callback(); } });
function getStyles(dataset) { var styles = _.map(dataset, function (d, i) { var list = _.sortBy(_.map(d.ratingsList.style, function (style) { return { name: style.name, count: style.count, rating: style.rating }; }), function(d) { return d.count; }); return i === 1 ? list.reverse() : list; }); var commonStyles = _.intersection(_.pluck(styles[0], 'name'), _.pluck(styles[1], 'name')); function addRow(user, styles, second) { var row = []; var getValue = function (d, same) { var isContains = _.contains(commonStyles, user.name); var value = 0; if ((isContains && !same || !isContains && same) && d.name === user.name) { value = user.count; } return value; }; _.each(styles[1], function (d) { row.push(getValue(d, !second)); }); _.each(styles[0], function (d) { row.push(getValue(d, second)); }); return row; } var matrix = []; var names = []; //reverse order _.each(styles[1], function (user) { var row = addRow(user, styles, false); matrix.push(row); names.push(user.name); }); _.each(styles[0], function (user, i) { var row = addRow(user, styles, true); matrix.push(row); names.push(user.name); }); return { matrix: matrix, names: names, divide: _.size(styles[1]), common: commonStyles.length }; }
removePartyMembers(characterIds) { const existing = this.getPartyMemberIds(); const leaving = _.intersection(existing, characterIds); if (leaving.length) { const newMembers = _.difference(existing, leaving); this.addEntry(new PartyChangeEntry(this.end, newMembers, leaving, 'left')); } }
_.each(kn, function(v, k){ var queSeg = v.question.split('^'); var l = _.intersection(msgSeg, queSeg).length; if(l / queSeg.length > .4 && l >= sameLength){ //相同的词在整句话中占比大于40%,才能认为找对了 sameLength = l; ans = v.answer; } });
function(post, cb) { var friends = _.intersection(facebookFriendIds, post.facebook_friends); if (!_.isEmpty(friends)) { cb(true); } else { cb(false); } },
function (state) { var message = this.parseErrorMessage(state.getMessage()); message = u.intersection(this.getRawValue(), message); if (u.isArray(message) && !u.isEmpty(message)) { this.showErrors(message); state.setMessage(this.itemErrorMessage); } },
return _.every(permissions, function(permission) { var roles = settings.permissions[permission]; if (!roles) { return !expected; } var found = _.intersection(userRoles, roles).length > 0; return expected === found; });
handleChange: function (model) { if (model !== undefined && _.intersection(Object.keys(model.changedAttributes()), [ 'result', 'saved', 'metacard.modified', 'id', 'subscribed' ]).length === 0) { this.set('saved', false); } },
var links = promo.links.filter(function(link) { var match = _.intersection(link.rel, CONFIG.PROMO_RELS); if (match.length > 1 || (match.length > 0 && match.indexOf(CONFIG.R.thumbnail) === -1)) { // Detect if has something except thumbnail. hasGoodLinks = true; } return match.length; });
_.each(qvalues, function(qvalue) { var typesInGroup = _.pluck(answer.acceptGroups[qvalue], 'type'); var intersect = _.intersection(typesInGroup,possibleRepresentations); if(intersect.length > 0 && !found){ bestMatch = intersect[0]; found = true; } });
MetricsValidator.prototype.toValidFields = function(){ var allValidFields = _.intersection(this.metrics.concat([this.newField]), this.cityFields), lastValidField = _.last(allValidFields); if (allValidFields.length > 5) { allValidFields = _.first(allValidFields,4).concat([lastValidField]); } return allValidFields; }
return function (file) { onfile(file); if (skips) { if (_.intersection(file.split('/'), skips).length > 0) { return true; } } }
function intersectSentences(s1, s2) { var s1_words = toWordArray(s1), s2_words = toWordArray(s2), intersect = _.intersection(s1_words, s2_words), splice = ((s1_words.length + s2_words.length) / 2); return intersect.splice(0, splice).length; }
it( "works like _.intersection", function() { var a = [1, 2, 3, 4]; var b = [3, 4, 5, 6]; var d = [1, 2, 7, 8]; var cResult = c( a ).intersection( b, d ).toArray(); var uResult = _.intersection( a, b, d ); expect( cResult ).to.deep.equal( uResult ); });
function isAllowed(path, option) { var bits = path.split('.'); var tags = getTags.apply(this, bits); options = _.union(option && [option] || [], ["allow"]); return _.intersection(tags, options).length == options.length; }
findCoplayFilms: function(character1, character2){ var filmsList1 = characterFilmMapping[character1]; var filmsList2 = characterFilmMapping[character2]; var filmsIds1 = _.pluck(filmsList1, 'id'); var filmsIds2 = _.pluck(filmsList2, 'id'); var filmsCoplay = _.intersection(filmsIds1, filmsIds2); return filmsCoplay; },