// `rewriteNode` replaces wildcards with matched wildcard values function rewriteNode(wildcards, replacement, node) { node = node || {}; switch (replacement.type) { case 'Identifier': if (isWildcard(replacement)) { if (replacement.name in wildcards) { replacement = wildcards[replacement.name]; } } break; case 'Program': case 'BlockStatement': replacement.body = rewritePartial(wildcards, replacement.body); break; case 'ArrayExpression': replacement.elements = rewritePartial(wildcards, replacement.elements); break; case 'MemberExpression': replacement.object = rewriteNode(wildcards, replacement.object, node.object); replacement.property = rewriteNode(wildcards, replacement.property, node.property); break; case 'CallExpression': replacement.callee = rewriteNode(wildcards, replacement.callee, node.callee); replacement.arguments = rewritePartial(wildcards, replacement.arguments); // Unpack rest param from wildcards var rest = _.last(replacement.arguments); if (rest && isRestWildcard(rest)) { replacement.arguments.pop(); replacement.arguments = replacement.arguments.concat(wildcards['...' + rest.argument.name]); } break; case 'FunctionExpression': replacement.body = rewriteNode(wildcards, replacement.body, node.body); replacement.params = rewritePartial(wildcards, replacement.params); replacement.defaults = rewritePartial(wildcards, replacement.defaults); // Unpack rest param from wildcards if (replacement.rest && isWildcard(replacement.rest)) { replacement.params = replacement.params.concat(wildcards['...' + replacement.rest.name]); } break; case 'FunctionDeclaration': replacement.id = rewriteNode(wildcards, replacement.id, node.id); replacement.body = rewriteNode(wildcards, replacement.body, node.body); replacement.params = rewritePartial(wildcards, replacement.params); replacement.defaults = rewritePartial(wildcards, replacement.defaults); // Unpack rest param from wildcards if (replacement.rest && isWildcard(replacement.rest)) { replacement.params = replacement.params.concat(wildcards['...' + replacement.rest.name]); } break; case 'Property': replacement.key = rewriteNode(wildcards, replacement.key, node.key); replacement.value = rewriteNode(wildcards, replacement.value, node.value); replacement.kind = rewriteNode(wildcards, replacement.kind, node.kind); break; case 'BinaryExpression': replacement.left = rewriteNode(wildcards, replacement.left, node.left); replacement.right = rewriteNode(wildcards, replacement.right, node.right); break; case 'UnaryExpression': replacement.argument = rewriteNode(wildcards, replacement.argument); break; case 'VariableDeclaration': replacement.declarations = rewritePartial(wildcards, replacement.declarations); break; case 'VariableDeclarator': replacement.id = rewriteNode(wildcards, replacement.id, node.id); replacement.init = rewriteNode(wildcards, replacement.init, node.init); break; case 'ReturnStatement': replacement.argument = rewriteNode(wildcards, replacement.argument, node.argument); break; case 'ExpressionStatement': replacement.expression = rewriteNode(wildcards, replacement.expression, node.expression); break; case 'SpreadElement': replacement.argument = rewriteNode(wildcards, replacement.argument, node.expression); break; case 'UpdateExpression': replacement.argument = rewriteNode(wildcards, replacement.argument, node.argument); break; case 'ForStatement': replacement.init = rewriteNode(wildcards, replacement.init, node.init); replacement.test = rewriteNode(wildcards, replacement.test, node.test); replacement.update = rewriteNode(wildcards, replacement.update, node.update); replacement.body = rewriteNode(wildcards, replacement.body, node.body); break; case 'ObjectExpression': replacement.properties = rewritePartial(wildcards, replacement.properties); break; case 'Literal': break; // no-op default: console.error(replacement.type, "not yet supported in replace", replacement); break; } return replacement; }
glob.sync(playerDir + '/games/*.html').forEach(function(d, i){ parseLog(d, i, player.subs, player.fullName[0] + '. ' + _.last(player.fullName.split(' ')), player.slug) })
visitPattern: function() { var resultType = _.last(t.prune(newEnv[v.tag.value]).types).fresh(newNonGeneric); unify(currentValue, resultType, v.lineno); addVarsToEnv(v, path); }
that.model.addMeta(that.model.get('duplicationsParsed')); } that.model.checkIfHasDuplications(); that.render(); that.scrollToFirstLine(firstLine); if (that.model.get('hasSourceBefore') || that.model.get('hasSourceAfter')) { that.bindScrollEvents(); } }); }, loadSourceAfter () { this.unbindScrollEvents(); const that = this; let source = this.model.get('source'); const lastLine = _.last(source).line; const url = '/api/sources/lines'; const options = { uuid: this.model.id, from: lastLine + 1, to: lastLine + this.LINES_AROUND }; return $.get(url, options).done(function (data) { source = source.concat(data.sources); if (source.length > that.TOTAL_LINES_LIMIT + 1) { source = source.slice(source.length - that.TOTAL_LINES_LIMIT); that.model.set({ hasSourceBefore: true }); } source = source.map(function (row) { return _.extend(row, { utCoverageStatus: that.getUTCoverageStatus(row),
}), function(assetPath){ return _.last(assetPath.split('!')); });
stackUnbinder('name'); // get the all the value of var 'name' --> cicciosgamino_pop // dynamicLookup provides a way to look at the top value function dynamicLookup(a){ var a_array = globals[a] || []; return _.last(a_array); }
_.each(roomifyRecords,function(roomRecordArray){ ret.push(_.last(_.sortBy(roomRecordArray,function(record){ return record.timestamp.getTime(); }))) });
'the basePath ends with a sha1 in hex of the repo': function(repo) { assert.isString(repo.basePath); assert.match(repo.basePath, /\/[0-9a-f]{40}$/); var expBasePath = crypto.createHash('sha1').update(repo.url).digest('hex'); assert.equal(_.last(repo.basePath.split('/')), expBasePath); },
Model.remove(searchCriteria, function (err) { if (err) return _.last(arguments)(err, false); stepDone(null, true); });
get currentAbilityContext() { return _.last(this.abilityCardStack); }
posts.Grab(board+url, function (post) { callback({ board: board, url: url, posts: post, threadid: _.last(url.split("/")) }); });
tailLength: function (code) { return _.last(code.split('\n')).length; },
var getFileName = function(sourceFile) { var fileNameWithExtension = _.last(sourceFile.split('/')); var fileName = fileNameWithExtension.slice(0, fileNameWithExtension.length - 3); return fileName; };
var HistoryTab, DeploymentHistoryScreen; HistoryTab = React.createClass({ statics: { breadcrumbsPath() { return [ [i18n('cluster_page.tabs.history'), null, {active: true}] ]; }, getSubtabs({cluster}) { return _.map(cluster.get('transactions').filterTasks({active: false}), 'id'); }, checkSubroute(tabProps) { var {activeTab, cluster, tabOptions} = tabProps; var subtabs = this.getSubtabs(tabProps); var defaultSubtab = _.last(subtabs); if (activeTab === 'history') { var transactionId = Number(tabOptions[0]); if (!transactionId || !_.includes(subtabs, transactionId)) { app.navigate( '/cluster/' + cluster.id + '/history' + (defaultSubtab ? '/' + defaultSubtab : ''), {replace: true} ); } return {activeTransactionId: transactionId || null}; } return {activeTransactionId: defaultSubtab || null}; } }, getInitialState() { return {
uduvudu.helper.getTerm = function(string) { var getTerm = /(#|\/)([^#\/]*)$/; return _.last(getTerm.exec(string)); };
function () { req.user.isMemberOfOrganization({_id: req.body.organization}, _.last(arguments)); }, function () {
return [_.first(_.first(b)), _.map(b, function(c) {return _.last(c);})];
}, function () { var lastCheck = arguments[0]; if (!lastCheck) return _.last(arguments)(null, lastCheck); Model.find(searchCriteria).exec(_.last(arguments)); }, function () {
function push(item) { _.last(groupsStack).push(item); }
testUnderscoreImport() { //test underscore import var underscoreTest = _.last([34,1,55,2,20], 1); debug('underscore test result: ' + underscoreTest); }
app.getMoreOfComponent = function(component_id,cb_ok,cb_error){ var component = app.components.get(component_id); if( component ){ var component_data = component.get('data'); if( component_data.hasOwnProperty('ids') ){ var token = getToken('component'); var ws_url = token +'/component/'+ component_id; var last_item_id = _.last(component_data.ids); ws_url += '?before_item='+ last_item_id; $.ajax({ type: 'GET', url: Config.wp_ws_url + ws_url, success: function(answer) { if( answer.result && answer.result.status == 1 ){ if( answer.component.slug == component_id ){ var global = answer.component.global; if( app.globals.hasOwnProperty(global) ){ var new_ids = _.difference(answer.component.data.ids,component_data.ids); component_data.ids = _.union(component_data.ids,answer.component.data.ids); //merge ids component.set('data',component_data); var current_items = app.globals[global]; _.each(answer.globals[global],function(item, id){ current_items.add(_.extend({id:id},item)); //auto merges if "id" already in items }); var new_items = []; _.each(new_ids,function(item_id){ new_items.push(current_items.get(item_id)); }); var nb_left = component_data.total - component_data.ids.length; var is_last = !_.isEmpty(answer.component.data.query.is_last_page) ? true : nb_left <= 0; Utils.log('More content retrieved for component',{component_id:component_id,new_ids:new_ids,new_items:new_items,component:component}); cb_ok(new_items,is_last,{nb_left:nb_left,new_ids:new_ids,global:global,component:component}); }else{ app.triggerError( 'getmore:global-not-found', {type:'not-found',where:'app::getMoreOfComponent',message:'Global not found : '+ global}, cb_error ); } }else{ app.triggerError( 'getmore:wrong-component-id', {type:'not-found',where:'app::getMoreOfComponent',message:'Wrong component id : '+ component_id}, cb_error ); } }else{ app.triggerError( 'getmore:ws-return-error', {type:'web-service',where:'app::getMoreOfComponent',message:'Web service "component" returned an error : ['+ answer.result.message +']'}, cb_error ); } }, error: function(jqXHR, textStatus, errorThrown){ app.triggerError( 'getmore:ajax', {type:'ajax',where:'app::getMoreOfComponent',message: textStatus + ': '+ errorThrown,data:{url: Config.wp_ws_url + ws_url, jqXHR:jqXHR, textStatus:textStatus, errorThrown:errorThrown}}, cb_error ); } }); } } };
async.eachSeries(games, function (game, cb) { console.log('Check game: ' + game._id); // get stats var matchCreationDate = moment(game.matchCreation); var matchDuration = game.data.matchDuration; var kill = 0; var doubleKill = 0; var tripleKill = 0; var quadraKill = 0; var pentaKill = 0; var death = 0; var assist = 0; var minion = 0; var gold = 0; var killRed = 0; var doubleKillRed = 0; var tripleKillRed = 0; var quadraKillRed = 0; var pentaKillRed = 0; var deathRed = 0; var assistRed = 0; var minionRed = 0; var goldRed = 0; var killBlue = 0; var doubleKillBlue = 0; var tripleKillBlue = 0; var quadraKillBlue = 0; var pentaKillBlue = 0; var deathBlue = 0; var assistBlue = 0; var minionBlue = 0; var goldBlue = 0; var blueTeam = []; var redTeam = []; var winner = game.data.teams[0].winner ? 'blue' : 'red'; var champ; game.data.participants.forEach(function (participant) { champ = _.findWhere(champions, {riotId: participant.championId}); kill += participant.stats.kills; doubleKill += participant.stats.doubleKills; tripleKill += participant.stats.tripleKills; quadraKill += participant.stats.quadraKills; pentaKill += participant.stats.pentaKills; death += participant.stats.deaths; assist += participant.stats.assists; minion += participant.stats.minionsKilled; gold += participant.stats.goldEarned; if (participant.teamId === 100) { blueTeam.push({ championId: champ._id, riotId: champ.riotId, key: champ.key }); killBlue += participant.stats.kills; doubleKillBlue += participant.stats.doubleKills; tripleKillBlue += participant.stats.tripleKills; quadraKillBlue += participant.stats.quadraKills; pentaKillBlue += participant.stats.pentaKills; deathBlue += participant.stats.deaths; assistBlue += participant.stats.assists; minionBlue += participant.stats.minionsKilled; goldBlue += participant.stats.goldEarned; } else { redTeam.push({ championId: champ._id, riotId: champ.riotId, key: champ.key }); killRed += participant.stats.kills; doubleKillRed += participant.stats.doubleKills; tripleKillRed += participant.stats.tripleKills; quadraKillRed += participant.stats.quadraKills; pentaKillRed += participant.stats.pentaKills; deathRed += participant.stats.deaths; assistRed += participant.stats.assists; minionRed += participant.stats.minionsKilled; goldRed += participant.stats.goldEarned; } }); // update total stats matchDurationTotal += matchDuration; killTotal += kill; doubleKillTotal += doubleKill; tripleKillTotal += tripleKill; quadraKillTotal += quadraKill; pentaKillTotal += pentaKill; deathTotal += death; assistTotal += assist; minionTotal += minion; goldTotal += gold; // create event var newEvent = { name: 'URF Match #' + game.riotId, type: 'MATCH', winnerMatch: winner, teams: [blueTeam, redTeam], statsTeams: [ { gold: goldBlue, minion: minionBlue, death: deathBlue, kill: killBlue, doubleKill: doubleKillBlue, tripleKill: tripleKillBlue, quadraKill: quadraKillBlue, pentaKill: pentaKillBlue, assist: assistBlue }, { gold: goldRed, minion: minionRed, death: deathRed, kill: killRed, doubleKill: doubleKillRed, tripleKill: tripleKillRed, quadraKill: quadraKillRed, pentaKill: pentaKillRed, assist: assistRed } ], durationMatch: matchDuration, description: 'Winner ' + winner + ' team', icon: 'match', share: false, comment: false, date: matchCreationDate.toDate() }; // get last timeline var lastTimeline = _.last(timelines); if (lastTimeline.events.length < 20) { // add events lastTimeline.events.push(newEvent); lastTimeline.lastEvent = matchCreationDate.toDate(); } else { var newTimeline = createNewTimeline(REGION, matchCreationDate); newTimeline.events.push(newEvent); timelines.push(newTimeline); } // update daily report var daily = _.findWhere(dailyReports, {dailyDate: matchCreationDate.format('DD/MM/YYYY')}); if (daily) { console.log('Daily found: ' + matchCreationDate.format('DD/MM/YYYY')); // update Statistique.update({_id: daily._id}, { $inc: { 'data.game': 1, 'data.gold': gold, 'data.minion': minion, 'data.totalDeath': death, 'data.totalKill': kill, 'data.totalDoubleKill': doubleKill, 'data.totalTripleKill': tripleKill, 'data.totalQuadraKill': quadraKill, 'data.totalPentaKill': pentaKill, 'data.totalAssist': assist, 'data.totalMinion': minion, 'data.totalTime': matchDuration } }, function (err) { if (err) { return cb(err); } console.log('Daily updated: ' + matchCreationDate.format('DD/MM/YYYY')); // next game return cb(); }); } else { var newDaily = { type: 'GLOBAL', period: 'DAILY', createdDate: moment().toDate(), dailyDate: matchCreationDate.format('DD/MM/YYYY'), data: { game: 1, gold: gold, minion: minion, totalDeath: death, totalKill: kill, totalDoubleKill: doubleKill, totalTripleKill: tripleKill, totalQuadraKill: quadraKill, totalPentaKill: pentaKill, totalAssist: assist, totalMinion: minion, totalTime: matchDuration } }; // create Statistique.insert(newDaily, function (err) { if (err) { return cb(err); } console.log('Daily created: ' + matchCreationDate.format('DD/MM/YYYY')); // add to list of dailyReports dailyReports.push(newDaily); return cb(); }); } }, function (err) {
/** * Returns last (version) apk for provided name. * @param {@String} name name (prefix) for apk files to look for. */ function last(name) { if (!initialized) { init(); } return _.last(apk[name]); };
labels = _.map(labels, function(events) { events = _.sortBy(events, 'time'); return _.last(events); });
const isMessageFromFolderCreation = message => { return _.last(message.activities).verb === 'create'; };
(_.mapObject({foo: 1, bar: 2}, function (v, k) {return (k.length + v).toString()}): {[key: string]: string}); // $ExpectError This type is incompatible with number (_.mapObject({foo: 1, bar: 2}, function (v, k) {return (k.length + v).toString()}): number); (_.pluck([{name: 'bob'}, {name: 'jane'}], 'name'): Array<string>); (_.reduce([1, 2, 3], function(m, o) { return m + o }, 0): number); (_.all([2, 4, 5], function(i) { return i % 2 == 0 }): boolean); // $ExpectError Property not found in Number (_.all([2, 4, 5], function(i) { return i.length }): boolean); (_.some([2, 4, 5], function(i) { return i % 2 == 0 }): boolean); (_.union(['a', 'b'], ['b']): Array<string>); (_.intersection(['a', 'b'], ['b']): Array<string>); (_.difference(['a', 'b'], ['b']): Array<string>); (_.first([1,2,3]): number); (_.first([1,2,3], 2): Array<number>); (_.last([1,2,3]): number); (_.last([1,2,3], 2): Array<number>); (_.sample([1,2,3]): number); (_.sortBy(['hello', 'world'], function(e) { return e.length }): Array<string>); (_.uniq([1,2,2]): Array<number>); (_.compact([1, null]): Array<number>); (_.select([1,2,3], function(e) { return e % 2 == 0 }): Array<number>); (_.reject([1,2,3], function(e) { return e % 2 == 0 }): Array<number>); (_.without([1,2,3], 1, 2): Array<number>); (_.has({a: 1, b: 2}, 'b'): boolean); (_.isArray([1, 2]): boolean); (_.isArray(1): boolean); (_.pick({a: 1, b: 2}, 'a'): {[key: string]: number}); (_.omit({a: 1, b: 2}, 'a'): {[key: string]: number}); _.throttle(function(a) {a.length}, 10)('hello');
_.each(waitingForDependency, function(waitingModel) { if (_.all(_.first(waitingModel, waitingModel.length-2), function(dependency) { return loaded[dependency]; })) { _.last(waitingModel).prototype.relations = waitingModel[waitingModel.length-2](); finished.push(waitingModel); } });
_(_.zip(headers, data)).each(function(tuple) { row[_.first(tuple)] = _.last(tuple) })
.map(function(node) { return { name: _.last(node.key.split('/')), value: node.value === 'true' }; })
return function(errorToBeSent, req, res, next) { // override to support both node callback style // and connect/express next = _.last(arguments); if (typeof next != 'function') { next = function() {}; } // mh: do not process any further under three conditions: // - errorToBeSent is empty // - opts.sendAlways is false && environment is not production // - custom function in opts.ignore tells to ignore the error if (!errorToBeSent || (!opts.sendAlways && env != 'production') || (opts.ignore && typeof opts.ignore == 'function' && opts.ignore(errorToBeSent))) { next(errorToBeSent); return; } var mail = _.clone(opts); async.waterfall([ async.apply(emailTemplates, templatesDir), function(template, callback) { var locals = { subject: opts.subject, title: 'Error' }; if (typeof errorToBeSent == "string") { locals.message = errorToBeSent; locals.stack = ""; } else { locals.message = errorToBeSent.message; locals.stack = errorToBeSent.stack; // append error number and code to title if (typeof errorToBeSent.errno !== 'undefined' && errorToBeSent.errno != "" && typeof errorToBeSent.code !== 'undefined' && errorToBeSent.code != "") { locals.title += ' (Error code ' + errorToBeSent.errno + ' = ' + errorToBeSent.code + ')'; } } locals.req = req; locals._ = _; mail.subject = mail.subject + " " + locals.message; template('basic_error', locals, callback); }, function(html, text, callback) { mail.text = text; mail.html = html; transport.sendMail(mail, callback); } ], function(err) { if(err) { console.log(err); console.log(errorToBeSent.toString()); } next(errorToBeSent); }); };