Best JavaScript code snippet using stryker-parent
filter_functions.js
Source:filter_functions.js
1import _ from 'lodash'2function totalGoals(item) {3 let totalGoals;4 if (item.view.scores) {5 totalGoals = parseInt(item.view.scores['2'].home) + parseInt(item.view.scores['2'].away);6 return totalGoals <= 07 } else {8 return false9 }10}11function goalsDraw(item) {12 return parseInt(item.view.scores['2'].home) === parseInt(item.view.scores['2'].away);13}14function startTB(item) {15 if (item.odds['1_3']) {16 let totalOdds = item.odds['1_3'];17 let startTotalOdd = totalOdds[totalOdds.length - 1];18 //let handicaps_1_8 = ['2.5, 3.0', '3.0, 3,5'];19 //let handicaps_1_9 = ['3.5', '3.5, 4.0', '4.0, 4.5', '4.5', '4.5, 5.0', '5.0, 5.5', '5,5', '5.5, 6.0', '6.0, 6.5', '6.5', '6.5, 7.0', '7.0, 7.5', '7.5', '7.5, 8.0', '8.0, 8.5', '8.5'];20 if (startTotalOdd) {21 //let overOd = parseFloat(startTotalOdd.over_od);22 //let handicap = (startTotalOdd.handicap + '').trim();23 let handicapArray = startTotalOdd.handicap.split(',');24 return parseFloat(startTotalOdd.over_od) <= 1.75 && parseFloat(handicapArray[0]) <= 2.525 || parseFloat(startTotalOdd.over_od) < 1.95 && parseFloat(handicapArray[0]) > 326 || parseFloat(startTotalOdd.over_od) < 1.85 && parseInt(handicapArray[0]) === 327 } else {28 return false29 }30 }31}32function startResultOdd(item) {33 if (item.odds['1_1'] && item.scores ) {34 let resultOdds = item.odds['1_1'];35 let startResultOdd = resultOdds[resultOdds.length - 1];36 if (startResultOdd) {37 if (parseFloat(startResultOdd.home_od) <= 1.4 || parseFloat(startResultOdd.away_od) <= 1.4) {38 return true39 } else {40 return false41 }42 } else {43 return false44 }45 }46}47function leagueName(item) {48 if (item.league && item.league.name) {49 let leagueNameFilter = ['50', '60', '70', '80', 'Women', 'U18', 'U19', 'U20'];50 return item.league.name.indexOf(leagueNameFilter[0]) === -151 && item.league.name.indexOf(leagueNameFilter[1]) === -152 && item.league.name.indexOf(leagueNameFilter[2]) === -153 && item.league.name.indexOf(leagueNameFilter[3]) === -154 && item.league.name.indexOf(leagueNameFilter[4]) === -155 && item.league.name.indexOf(leagueNameFilter[5]) === -156 && item.league.name.indexOf(leagueNameFilter[6]) === -157 && item.league.name.indexOf(leagueNameFilter[7]) === -158 }59}60function attacksBot3(item) {61 if (item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks) {62 let goalsOnTarget = 0;63 goalsOnTarget = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.on_target[1]);64 let attacksSumm = 0;65 attacksSumm = parseInt(item.view.stats.attacks[0]) + parseInt(item.view.stats.attacks[1]);66 let dangerAttacksSumm = 0;67 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);68 return goalsOnTarget >= 3 && attacksSumm >= 38 && dangerAttacksSumm/attacksSumm >= 0.569 } else {70 return false71 }72}73function attacksBot2(item) {74 if (item.view && item.view.stats && item.view.stats.on_target && item.view.stats.off_target && item.view.stats.attacks && item.view.stats.dangerous_attacks) {75 let goalsOnTarget = 0;76 goalsOnTarget = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.on_target[1]);77 let attacksSumm = 0;78 attacksSumm = parseInt(item.view.stats.attacks[0]) + parseInt(item.view.stats.attacks[1]);79 let dangerAttacksSumm = 0;80 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);81 let allGoals = 0;82 allGoals = goalsOnTarget + parseInt(item.view.stats.off_target[0]) + parseInt(item.view.stats.off_target[1]);83 let dangerAttacksDiff = Math.abs(parseInt(item.view.stats.dangerous_attacks[0]) - parseInt(item.view.stats.dangerous_attacks[1]));84 let dangerAttacksKef;85 if (parseInt(item.view.stats.dangerous_attacks[0]) >= parseInt(item.view.stats.dangerous_attacks[1])) {86 dangerAttacksKef = parseInt(item.view.stats.attacks[0])/parseInt(item.view.stats.dangerous_attacks[0])87 } else {88 dangerAttacksKef = parseInt(item.view.stats.attacks[1])/parseInt(item.view.stats.dangerous_attacks[1])89 }90 let favoriteDangerAttacksKef;91 if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {92 favoriteDangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[0])/parseInt(item.view.stats.dangerous_attacks[1]);93 } else {94 favoriteDangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[1])/parseInt(item.view.stats.dangerous_attacks[0]);95 }96 return goalsOnTarget >= 1 && allGoals >= 4 && (item.view.stats.dangerous_attacks[0] <= 10 || item.view.stats.dangerous_attacks[1] <= 10)97 && favoriteDangerAttacksKef >= 2.298 } else {99 return false100 }101}102function attacksBot1(item) {103 if (item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks) {104 let goalsOnTarget = 0;105 goalsOnTarget = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.on_target[1]);106 let attacksSumm = 0;107 attacksSumm = parseInt(item.view.stats.attacks[0]) + parseInt(item.view.stats.attacks[1]);108 let dangerAttacksSumm = 0;109 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);110 let dangerAttacksDif = Math.abs(parseInt(item.view.stats.dangerous_attacks[0]) - parseInt(item.view.stats.dangerous_attacks[1]));111 let dangerAttacksKef;112 if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {113 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[0])/parseInt(item.view.stats.dangerous_attacks[1]);114 } else {115 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[1])/parseInt(item.view.stats.dangerous_attacks[0]);116 }117 return dangerAttacksDif >= 10 && goalsOnTarget >= 3118 } else {119 return false120 }121}122function attacksBotTM(item) {123 if (item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks) {124 let goalsOnTarget = 0;125 goalsOnTarget = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.on_target[1]);126 let goalsOffTarget = 0;127 goalsOffTarget = parseInt(item.view.stats.off_target[0]) + parseInt(item.view.stats.off_target[1]);128 let attacksSumm = 0;129 attacksSumm = parseInt(item.view.stats.attacks[0]) + parseInt(item.view.stats.attacks[1]);130 let dangerAttacksSumm = 0;131 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);132 let dangerAttacksDif = Math.abs(parseInt(item.view.stats.dangerous_attacks[0]) - parseInt(item.view.stats.dangerous_attacks[1]));133 let dangerAttacksKef;134 if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {135 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[0])/parseInt(item.view.stats.dangerous_attacks[1]);136 } else {137 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[1])/parseInt(item.view.stats.dangerous_attacks[0]);138 }139 return dangerAttacksKef >= 2.3140 } else {141 return false142 }143}144function attacksBotCorporation(item) {145 if (item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks) {146 let goalsOnTarget = 0;147 goalsOnTarget = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.on_target[1]);148 let goalsOnTargetDiff = 0;149 goalsOnTargetDiff = Math.abs(parseInt(item.view.stats.on_target[0]) - parseInt(item.view.stats.on_target[1]));150 let goalsOffTarget = 0;151 goalsOffTarget = parseInt(item.view.stats.off_target[0]) + parseInt(item.view.stats.off_target[1]);152 let attacksSumm = 0;153 attacksSumm = parseInt(item.view.stats.attacks[0]) + parseInt(item.view.stats.attacks[1]);154 let dangerAttacksSumm = 0;155 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);156 let dangerAttacksDif = Math.abs(parseInt(item.view.stats.dangerous_attacks[0]) - parseInt(item.view.stats.dangerous_attacks[1]));157 let dangerAttacksKef;158 if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {159 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[0])/parseInt(item.view.stats.dangerous_attacks[1]);160 } else {161 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[1])/parseInt(item.view.stats.dangerous_attacks[0]);162 }163 return goalsOnTarget >= 3 && goalsOnTargetDiff >= 2 && (goalsOffTarget + goalsOnTarget) >= 5 && dangerAttacksDif >= 9;164 } else {165 return false166 }167}168function attacks(item) {169 //return item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks170 if (item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks && item.odds['1_1'] && parseFloat(item.odds['1_1'][0].home_od) > 1) {171 /*let goalsOnTarget = 0;172 goalsOnTarget = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.on_target[1]);173 let goalsOffTarget = 0;174 goalsOffTarget = parseInt(item.view.stats.off_target[0]) + parseInt(item.view.stats.off_target[1]);175 let team1AllGoals = 0;176 team1AllGoals = parseInt(item.view.stats.on_target[0]) + parseInt(item.view.stats.off_target[0]);177 let team2AllGoals = 0;178 team2AllGoals = parseInt(item.view.stats.on_target[1]) + parseInt(item.view.stats.off_target[1]);179 let attacksSumm = 0;180 attacksSumm = parseInt(item.view.stats.attacks[0]) + parseInt(item.view.stats.attacks[1]);181 let dangerAttacksSumm = 0182 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);183 let dangerAttacksDif = Math.abs(parseInt(item.view.stats.dangerous_attacks[0]) - parseInt(item.view.stats.dangerous_attacks[1]));184 let attacksKef = attacksSumm/dangerAttacksSumm;*/185 let dangerAttacksSumm = 0;186 dangerAttacksSumm = parseInt(item.view.stats.dangerous_attacks[0]) + parseInt(item.view.stats.dangerous_attacks[1]);187 let dangerAttacksKef;188 let advantageTeam = '';189 let dangerAttacksDiff = Math.abs(parseInt(item.view.stats.dangerous_attacks[0]) - parseInt(item.view.stats.dangerous_attacks[1]));190 let attacksDiff;191 if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {192 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[0])/parseInt(item.view.stats.dangerous_attacks[1]);193 attacksDiff = parseInt(item.view.stats.attacks[0]) - parseInt(item.view.stats.attacks[1]);194 advantageTeam = 'home'195 } else {196 dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[1])/parseInt(item.view.stats.dangerous_attacks[0]);197 attacksDiff = parseInt(item.view.stats.attacks[1]) - parseInt(item.view.stats.attacks[0]);198 advantageTeam = 'away'199 }200 let resultOdds = item.odds['1_1'];201 let startResultOdd = resultOdds[resultOdds.length - 1];202 let oddsKef = parseFloat(startResultOdd.home_od)/parseFloat(startResultOdd.away_od);203 let attacksRatioKefHome;204 let attacksRatioKefAway;205 if (parseInt(item.view.stats.attacks[0]) > parseInt(item.view.stats.attacks[1])) {206 attacksRatioKefHome = parseInt(item.view.stats.attacks[0])/parseInt(item.view.stats.attacks[1]);207 } else {208 attacksRatioKefAway = parseInt(item.view.stats.attacks[1])/parseInt(item.view.stats.attacks[0]);209 }210 //СÑÐ¿ÐµÑ Ð±Ð¾Ñ211 return ((dangerAttacksKef >= 3.2 && advantageTeam === 'home' || dangerAttacksKef >= 1.2 && dangerAttacksKef <= 1.5 && advantageTeam === 'away') && dangerAttacksDiff >= 3 && oddsKef >= 0.5 && oddsKef <= 1.2)212 //Ñедди213 //return (advantageTeam === 'away' && dangerAttacksDiff >= 3 && attacksRatioKefAway >= 1.2 && oddsKef >= 0.3 && oddsKef <= 1.2 && dangerAttacksSumm >= 18)214 } else {215 return false216 }217}218function trendAttacks(item) {219 //return item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks220 if (item.trends && item.trends.dangerous_attacks) {221 let homeDangerAttacks;222 let awayDangerAttacks;223 let home45 = _.find(item.trends.dangerous_attacks.home, function(item) {224 return item.time_str === '65'225 })226 let home64 = _.find(item.trends.dangerous_attacks.home, function(item) {227 return item.time_str === '79'228 })229 let away45 = _.find(item.trends.dangerous_attacks.away, function(item) {230 return item.time_str === '65'231 })232 let away64 = _.find(item.trends.dangerous_attacks.away, function(item) {233 return item.time_str === '79'234 })235 if (home45 && home64 && away45 && away64) {236 homeDangerAttacks = home64.val - home45.val;237 awayDangerAttacks = away64.val - away45.val;238 let dangerAttacksKef;239 if (homeDangerAttacks > awayDangerAttacks) {240 dangerAttacksKef = homeDangerAttacks/awayDangerAttacks241 } else {242 dangerAttacksKef = awayDangerAttacks/homeDangerAttacks243 }244 return (dangerAttacksKef >= 1.5)245 } else {246 return false247 }248 } else {249 return false250 }251}252function mapTrendAttacks(item) {253 //return item.view && item.view.stats && item.view.stats.on_target && item.view.stats.attacks && item.view.stats.dangerous_attacks254 if (item.trends && item.trends.dangerous_attacks) {255 let homeDangerAttacks;256 let awayDangerAttacks;257 let home45 = _.find(item.trends.dangerous_attacks.home, function(item) {258 return item.time_str === '65'259 })260 let home64 = _.find(item.trends.dangerous_attacks.home, function(item) {261 return item.time_str === '79'262 })263 let away45 = _.find(item.trends.dangerous_attacks.away, function(item) {264 return item.time_str === '65'265 })266 let away64 = _.find(item.trends.dangerous_attacks.away, function(item) {267 return item.time_str === '79'268 })269 if (home45 && home64 && away45 && away64) {270 homeDangerAttacks = home64.val - home45.val;271 awayDangerAttacks = away64.val - away45.val;272 item.homeDangerAttacks = homeDangerAttacks;273 item.awayDangerAttacks = awayDangerAttacks;274 return item275 } else {276 return false277 }278 } else {279 return false280 }281}282function currentWinner(item) {283 if (item.odds['1_1'] && parseFloat(item.odds['1_1'][0].home_od) > 1) {284 let winnerOdds = item.odds['1_1'];285 let currentWinnerOdd = winnerOdds[0];286 let dangerAttacksKef = parseInt(item.view.stats.dangerous_attacks[0])/parseInt(item.view.stats.dangerous_attacks[1]);287 if (dangerAttacksKef > 1) {288 if (parseFloat(currentWinnerOdd.home_od) >= 1.8 && parseFloat(currentWinnerOdd.home_od) <= 5) {289 return true290 } else {291 return false292 }293 } else {294 if (parseFloat(currentWinnerOdd.away_od) >= 1.8 && parseFloat(currentWinnerOdd.away_od) <= 5 ) {295 return true296 } else {297 return false298 }299 }300 /*if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {301 if (parseFloat(currentWinnerOdd.home_od) >= 1.8 && parseFloat(currentWinnerOdd.home_od) <= 2.8) {302 return true303 } else {304 return false305 }306 } else {307 if (parseFloat(currentWinnerOdd.away_od) >= 1.8 && parseFloat(currentWinnerOdd.away_od) <= 2.8) {308 return true309 } else {310 return false311 }312 }*/313 }314}315function halfTimeWinnerOdds(item) {316 //return true317 if (item.odds['1_8'] && item.odds['1_8'][0] && parseFloat(item.odds['1_8'][0].draw_od) > 1) {318 //return true319 let winnerOdds = item.odds['1_8'];320 let currentWinnerOdd = winnerOdds[0];321 if (parseFloat(currentWinnerOdd.draw_od) >= 1.75) {322 return true323 } else {324 return false325 }326 /*if (parseInt(item.view.stats.dangerous_attacks[0]) > parseInt(item.view.stats.dangerous_attacks[1])) {327 if (parseFloat(currentWinnerOdd.home_od) >= 1.8 && parseFloat(currentWinnerOdd.home_od) <= 2.8) {328 return true329 } else {330 return false331 }332 } else {333 if (parseFloat(currentWinnerOdd.away_od) >= 1.8 && parseFloat(currentWinnerOdd.away_od) <= 2.8) {334 return true335 } else {336 return false337 }338 }*/339 }340}341function favoriteLoses(item) {342 if (item.view.scores && item.view.scores['2'] && item.odds['1_1'] && parseFloat(item.odds['1_1'][0].home_od) > 1) {343 if (parseFloat(item.odds['1_1'][0].home_od) < 2 && item.view.scores['2'].home < item.view.scores['2'].away) {344 return true345 } else if (parseFloat(item.odds['1_1'][0].away_od) < 2 && item.view.scores['2'].home > item.view.scores['2'].away) {346 return true347 }348 } else {349 return false350 }351}352function currentTB1stHalf(item) {353 if (item.odds && item.odds['1_6'] && item.odds['1_6']['0']) {354 if (item.odds['1_6']['0'].over_od <= 1.95) {355 return true;356 } else {357 return false358 }359 } else {360 return false361 }362}363export const filterFunctions = {364 startTB: startTB,365 leagueName: leagueName,366 attacksBot1: attacksBot1,367 attacksBot2: attacksBot2,368 attacksBot3: attacksBot3,369 attacksBotCorporation: attacksBotCorporation,370 totalGoals: totalGoals,371 attacks: attacks,372 currentWinner: currentWinner,373 startResultOdd: startResultOdd,374 halfTimeWinnerOdds: halfTimeWinnerOdds,375 favoriteLoses: favoriteLoses,376 currentTB1stHalf: currentTB1stHalf,377 goalsDraw: goalsDraw,378 trendAttacks: trendAttacks,379 mapTrendAttacks: mapTrendAttacks,380 attacksBotTM: attacksBotTM...
stats.js
Source:stats.js
1/*2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.3 *4 * Use of this source code is governed by a BSD-style license5 * that can be found in the LICENSE file in the root of the source6 * tree.7 */8/* More information about these options at jshint.com/docs/options */9/* exported computeBitrate, computeE2EDelay, computeRate,10 enumerateStats, extractStatAsInt, refreshStats */11'use strict';12// Return the integer stat |statName| from the object with type |statObj| in13// |stats|, or null if not present.14function extractStatAsInt(stats, statObj, statName) {15 // Ignore stats that have a 'nullish' value.16 // The correct fix is indicated in17 // https://code.google.com/p/webrtc/issues/detail?id=3377.18 var str = extractStat(stats, statObj, statName);19 if (str) {20 var val = parseInt(str);21 if (val !== -1) {22 return val;23 }24 }25 return null;26}27// Return the stat |statName| from the object with type |statObj| in |stats|28// as a string, or null if not present.29function extractStat(stats, statObj, statName) {30 var report = getStatsReport(stats, statObj, statName);31 if (report && report[statName] !== -1) {32 return report[statName];33 }34 return null;35}36// Return the stats report with type |statObj| in |stats|, with the stat37// |statName| (if specified), and value |statVal| (if specified). Return38// undef if not present.39function getStatsReport(stats, statObj, statName, statVal) {40 var result = null;41 if (stats) {42 stats.forEach(function(report, stat) {43 if (report.type === statObj) {44 var found = true;45 // If |statName| is present, ensure |report| has that stat.46 // If |statVal| is present, ensure the value matches.47 if (statName) {48 var val = statName === 'id' ? report.id : report[statName];49 found = (statVal !== undefined) ? (val === statVal) : val;50 }51 if (found) {52 result = report;53 }54 }55 });56 }57 return result;58}59// Enumerates the new standard compliant stats using local and remote track ids.60function enumerateStats(stats, localTrackIds, remoteTrackIds) {61 // Create an object structure with all the needed stats and types that we care62 // about. This allows to map the getStats stats to other stats names.63 var statsObject = {64 audio: {65 local: {66 audioLevel: 0.0,67 bytesSent: 0,68 clockRate: 0,69 codecId: '',70 mimeType: '',71 packetsSent: 0,72 payloadType: 0,73 timestamp: 0.0,74 trackId: '',75 transportId: '',76 },77 remote: {78 audioLevel: 0.0,79 bytesReceived: 0,80 clockRate: 0,81 codecId: '',82 fractionLost: 0,83 jitter: 0,84 mimeType: '',85 packetsLost: 0,86 packetsReceived: 0,87 payloadType: 0,88 timestamp: 0.0,89 trackId: '',90 transportId: '',91 }92 },93 video: {94 local: {95 bytesSent: 0,96 clockRate: 0,97 codecId: '',98 firCount: 0,99 framesEncoded: 0,100 frameHeight: 0,101 framesSent: 0,102 frameWidth: 0,103 nackCount: 0,104 packetsSent: 0,105 payloadType: 0,106 pliCount: 0,107 qpSum: 0,108 timestamp: 0.0,109 trackId: '',110 transportId: '',111 },112 remote: {113 bytesReceived: 0,114 clockRate: 0,115 codecId: '',116 firCount: 0,117 fractionLost: 0,118 frameHeight: 0,119 framesDecoded: 0,120 framesDropped: 0,121 framesReceived: 0,122 frameWidth: 0,123 nackCount: 0,124 packetsLost: 0,125 packetsReceived: 0,126 payloadType: 0,127 pliCount: 0,128 qpSum: 0,129 timestamp: 0.0,130 trackId: '',131 transportId: '',132 }133 },134 connection: {135 availableOutgoingBitrate: 0,136 bytesReceived: 0,137 bytesSent: 0,138 consentRequestsSent: 0,139 currentRoundTripTime: 0.0,140 localCandidateId: '',141 localCandidateType: '',142 localIp: '',143 localPort: 0,144 localPriority: 0,145 localProtocol: '',146 remoteCandidateId: '',147 remoteCandidateType: '',148 remoteIp: '',149 remotePort: 0,150 remotePriority: 0,151 remoteProtocol: '',152 requestsReceived: 0,153 requestsSent: 0,154 responsesReceived: 0,155 responsesSent: 0,156 timestamp: 0.0,157 totalRoundTripTime: 0.0,158 }159 };160 // Need to find the codec, local and remote ID's first.161 if (stats) {162 stats.forEach(function(report, stat) {163 switch(report.type) {164 case 'outbound-rtp':165 if (report.hasOwnProperty('trackId')) {166 if (report.trackId.indexOf(localTrackIds.audio) !== -1) {167 statsObject.audio.local.bytesSent = report.bytesSent;168 statsObject.audio.local.codecId = report.codecId;169 statsObject.audio.local.packetsSent = report.packetsSent;170 statsObject.audio.local.timestamp = report.timestamp;171 statsObject.audio.local.trackId = report.trackId;172 statsObject.audio.local.transportId = report.transportId;173 }174 if (report.trackId.indexOf(localTrackIds.video) !== -1) {175 statsObject.video.local.bytesSent = report.bytesSent;176 statsObject.video.local.codecId = report.codecId;177 statsObject.video.local.firCount = report.firCount;178 statsObject.video.local.framesEncoded = report.frameEncoded;179 statsObject.video.local.framesSent = report.framesSent;180 statsObject.video.local.packetsSent = report.packetsSent;181 statsObject.video.local.pliCount = report.pliCount;182 statsObject.video.local.qpSum = report.qpSum;183 statsObject.video.local.timestamp = report.timestamp;184 statsObject.video.local.trackId = report.trackId;185 statsObject.video.local.transportId = report.transportId;186 }187 }188 break;189 case 'inbound-rtp':190 if (report.hasOwnProperty('trackId')) {191 if(report.trackId.indexOf(remoteTrackIds.audio) !== -1) {192 statsObject.audio.remote.bytesReceived = report.bytesReceived;193 statsObject.audio.remote.codecId = report.codecId;194 statsObject.audio.remote.fractionLost = report.fractionLost;195 statsObject.audio.remote.jitter = report.jitter;196 statsObject.audio.remote.packetsLost = report.packetsLost;197 statsObject.audio.remote.packetsReceived = report.packetsReceived;198 statsObject.audio.remote.timestamp = report.timestamp;199 statsObject.audio.remote.trackId = report.trackId;200 statsObject.audio.remote.transportId = report.transportId;201 }202 if (report.trackId.indexOf(remoteTrackIds.video) !== -1) {203 statsObject.video.remote.bytesReceived = report.bytesReceived;204 statsObject.video.remote.codecId = report.codecId;205 statsObject.video.remote.firCount = report.firCount;206 statsObject.video.remote.fractionLost = report.fractionLost;207 statsObject.video.remote.nackCount = report.nackCount;208 statsObject.video.remote.packetsLost = report.patsLost;209 statsObject.video.remote.packetsReceived = report.packetsReceived;210 statsObject.video.remote.pliCount = report.pliCount;211 statsObject.video.remote.qpSum = report.qpSum;212 statsObject.video.remote.timestamp = report.timestamp;213 statsObject.video.remote.trackId = report.trackId;214 statsObject.video.remote.transportId = report.transportId;215 }216 }217 break;218 case 'candidate-pair':219 if (report.hasOwnProperty('availableOutgoingBitrate')) {220 statsObject.connection.availableOutgoingBitrate =221 report.availableOutgoingBitrate;222 statsObject.connection.bytesReceived = report.bytesReceived;223 statsObject.connection.bytesSent = report.bytesSent;224 statsObject.connection.consentRequestsSent =225 report.consentRequestsSent;226 statsObject.connection.currentRoundTripTime =227 report.currentRoundTripTime;228 statsObject.connection.localCandidateId = report.localCandidateId;229 statsObject.connection.remoteCandidateId = report.remoteCandidateId;230 statsObject.connection.requestsReceived = report.requestsReceived;231 statsObject.connection.requestsSent = report.requestsSent;232 statsObject.connection.responsesReceived = report.responsesReceived;233 statsObject.connection.responsesSent = report.responsesSent;234 statsObject.connection.timestamp = report.timestamp;235 statsObject.connection.totalRoundTripTime =236 report.totalRoundTripTime;237 }238 break;239 default:240 return;241 }242 }.bind());243 // Using the codec, local and remote candidate ID's to find the rest of the244 // relevant stats.245 stats.forEach(function(report) {246 switch(report.type) {247 case 'track':248 if (report.hasOwnProperty('trackIdentifier')) {249 if (report.trackIdentifier.indexOf(localTrackIds.video) !== -1) {250 statsObject.video.local.frameHeight = report.frameHeight;251 statsObject.video.local.framesSent = report.framesSent;252 statsObject.video.local.frameWidth = report.frameWidth;253 }254 if (report.trackIdentifier.indexOf(remoteTrackIds.video) !== -1) {255 statsObject.video.remote.frameHeight = report.frameHeight;256 statsObject.video.remote.framesDecoded = report.framesDecoded;257 statsObject.video.remote.framesDropped = report.framesDropped;258 statsObject.video.remote.framesReceived = report.framesReceived;259 statsObject.video.remote.frameWidth = report.frameWidth;260 }261 if (report.trackIdentifier.indexOf(localTrackIds.audio) !== -1) {262 statsObject.audio.local.audioLevel = report.audioLevel ;263 }264 if (report.trackIdentifier.indexOf(remoteTrackIds.audio) !== -1) {265 statsObject.audio.remote.audioLevel = report.audioLevel;266 }267 }268 break;269 case 'codec':270 if (report.hasOwnProperty('id')) {271 if (report.id.indexOf(statsObject.audio.local.codecId) !== -1) {272 statsObject.audio.local.clockRate = report.clockRate;273 statsObject.audio.local.mimeType = report.mimeType;274 statsObject.audio.local.payloadType = report.payloadType;275 }276 if (report.id.indexOf(statsObject.audio.remote.codecId) !== -1) {277 statsObject.audio.remote.clockRate = report.clockRate;278 statsObject.audio.remote.mimeType = report.mimeType;279 statsObject.audio.remote.payloadType = report.payloadType;280 }281 if (report.id.indexOf(statsObject.video.local.codecId) !== -1) {282 statsObject.video.local.clockRate = report.clockRate;283 statsObject.video.local.mimeType = report.mimeType;284 statsObject.video.local.payloadType = report.payloadType;285 }286 if (report.id.indexOf(statsObject.video.remote.codecId) !== -1) {287 statsObject.video.remote.clockRate = report.clockRate;288 statsObject.video.remote.mimeType = report.mimeType;289 statsObject.video.remote.payloadType = report.payloadType;290 }291 }292 break;293 case 'local-candidate':294 if (report.hasOwnProperty('id')) {295 if (report.id.indexOf(296 statsObject.connection.localCandidateId) !== -1) {297 statsObject.connection.localIp = report.ip;298 statsObject.connection.localPort = report.port;299 statsObject.connection.localPriority = report.priority;300 statsObject.connection.localProtocol = report.protocol;301 statsObject.connection.localType = report.candidateType;302 }303 }304 break;305 case 'remote-candidate':306 if (report.hasOwnProperty('id')) {307 if (report.id.indexOf(308 statsObject.connection.remoteCandidateId) !== -1) {309 statsObject.connection.remoteIp = report.ip;310 statsObject.connection.remotePort = report.port;311 statsObject.connection.remotePriority = report.priority;312 statsObject.connection.remoteProtocol = report.protocol;313 statsObject.connection.remoteType = report.candidateType;314 }315 }316 break;317 default:318 return;319 }320 }.bind());321 }322 return statsObject;323}324// Takes two stats reports and determines the rate based on two counter readings325// and the time between them (which is in units of milliseconds).326function computeRate(newReport, oldReport, statName) {327 var newVal = newReport[statName];328 var oldVal = (oldReport) ? oldReport[statName] : null;329 if (newVal === null || oldVal === null) {330 return null;331 }332 return (newVal - oldVal) / (newReport.timestamp - oldReport.timestamp) * 1000;333}334// Convert a byte rate to a bit rate.335function computeBitrate(newReport, oldReport, statName) {336 return computeRate(newReport, oldReport, statName) * 8;337}338// Computes end to end delay based on the capture start time (in NTP format)339// and the current render time (in seconds since start of render).340function computeE2EDelay(captureStart, remoteVideoCurrentTime) {341 if (!captureStart) {342 return null;343 }344 // Adding offset (milliseconds between 1900 and 1970) to get NTP time.345 var nowNTP = Date.now() + 2208988800000;346 return nowNTP - captureStart - remoteVideoCurrentTime * 1000;...
ideologies.js
Source:ideologies.js
1ideologies = [2 {3 "name": "Anarcho-Communism",4 "stats": {5 "econ": 100,6 "dipl": 50,7 "govt": 100,8 "scty": 909 }10 },11 {12 "name": "Libertarian Communism",13 "stats": {14 "econ": 100,15 "dipl": 70,16 "govt": 80,17 "scty": 8018 }19 },20 {21 "name": "Trotskyism",22 "stats": {23 "econ": 100,24 "dipl": 100,25 "govt": 60,26 "scty": 8027 }28 },29 {30 "name": "Marxism",31 "stats": {32 "econ": 100,33 "dipl": 70,34 "govt": 40,35 "scty": 8036 }37 },38 {39 "name": "De Leonism",40 "stats": {41 "econ": 100,42 "dipl": 30,43 "govt": 30,44 "scty": 8045 }46 },47 {48 "name": "Leninism",49 "stats": {50 "econ": 100,51 "dipl": 40,52 "govt": 20,53 "scty": 7054 }55 },56 {57 "name": "Stalinism/Maoism",58 "stats": {59 "econ": 100,60 "dipl": 20,61 "govt": 0,62 "scty": 6063 }64 },65 {66 "name": "Religious Communism",67 "stats": {68 "econ": 100,69 "dipl": 50,70 "govt": 30,71 "scty": 3072 }73 },74 {75 "name": "State Socialism",76 "stats": {77 "econ": 80,78 "dipl": 30,79 "govt": 30,80 "scty": 7081 }82 },83 {84 "name": "Theocratic Socialism",85 "stats": {86 "econ": 80,87 "dipl": 50,88 "govt": 30,89 "scty": 2090 }91 },92 {93 "name": "Religious Socialism",94 "stats": {95 "econ": 80,96 "dipl": 50,97 "govt": 70,98 "scty": 2099 }100 },101 {102 "name": "Democratic Socialism",103 "stats": {104 "econ": 80,105 "dipl": 50,106 "govt": 50,107 "scty": 80108 }109 },110 {111 "name": "Revolutionary Socialism",112 "stats": {113 "econ": 80,114 "dipl": 20,115 "govt": 50,116 "scty": 70117 }118 },119 {120 "name": "Libertarian Socialism",121 "stats": {122 "econ": 80,123 "dipl": 80,124 "govt": 80,125 "scty": 80126 }127 },128 {129 "name": "Anarcho-Syndicalism",130 "stats": {131 "econ": 80,132 "dipl": 50,133 "govt": 100,134 "scty": 80135 }136 },137 {138 "name": "Left-Wing Populism",139 "stats": {140 "econ": 60,141 "dipl": 40,142 "govt": 30,143 "scty": 70144 }145 },146 {147 "name": "Theocratic Distributism",148 "stats": {149 "econ": 60,150 "dipl": 40,151 "govt": 30,152 "scty": 20153 }154 },155 {156 "name": "Distributism",157 "stats": {158 "econ": 60,159 "dipl": 50,160 "govt": 50,161 "scty": 20162 }163 },164 {165 "name": "Social Liberalism",166 "stats": {167 "econ": 60,168 "dipl": 60,169 "govt": 60,170 "scty": 80171 }172 },173 {174 "name": "Christian Democracy",175 "stats": {176 "econ": 60,177 "dipl": 60,178 "govt": 50,179 "scty": 30180 }181 },182 {183 "name": "Social Democracy",184 "stats": {185 "econ": 60,186 "dipl": 70,187 "govt": 60,188 "scty": 80189 }190 },191 {192 "name": "Progressivism",193 "stats": {194 "econ": 60,195 "dipl": 80,196 "govt": 60,197 "scty": 100198 }199 },200 {201 "name": "Anarcho-Mutualism",202 "stats": {203 "econ": 60,204 "dipl": 50,205 "govt": 100,206 "scty": 70207 }208 },209 {210 "name": "National Totalitarianism",211 "stats": {212 "econ": 50,213 "dipl": 20,214 "govt": 0,215 "scty": 50216 }217 },218 {219 "name": "Global Totalitarianism",220 "stats": {221 "econ": 50,222 "dipl": 80,223 "govt": 0,224 "scty": 50225 }226 },227 {228 "name": "Technocracy",229 "stats": {230 "econ": 60,231 "dipl": 60,232 "govt": 20,233 "scty": 70234 }235 },236 {237 "name": "Centrist",238 "stats": {239 "econ": 50,240 "dipl": 50,241 "govt": 50,242 "scty": 50243 }244 },245 {246 "name": "Liberalism",247 "stats": {248 "econ": 50,249 "dipl": 60,250 "govt": 60,251 "scty": 60252 }253 },254 {255 "name": "Religious Anarchism",256 "stats": {257 "econ": 50,258 "dipl": 50,259 "govt": 100,260 "scty": 20261 }262 },263 {264 "name": "Right-Wing Populism",265 "stats": {266 "econ": 40,267 "dipl": 30,268 "govt": 30,269 "scty": 30270 }271 },272 {273 "name": "Moderate Conservatism",274 "stats": {275 "econ": 40,276 "dipl": 40,277 "govt": 50,278 "scty": 30279 }280 },281 {282 "name": "Reactionary",283 "stats": {284 "econ": 40,285 "dipl": 40,286 "govt": 40,287 "scty": 10288 }289 },290 {291 "name": "Social Libertarianism",292 "stats": {293 "econ": 60,294 "dipl": 70,295 "govt": 80,296 "scty": 70297 }298 },299 {300 "name": "Libertarianism",301 "stats": {302 "econ": 40,303 "dipl": 60,304 "govt": 80,305 "scty": 60306 }307 },308 {309 "name": "Anarcho-Egoism",310 "stats": {311 "econ": 40,312 "dipl": 50,313 "govt": 100,314 "scty": 50315 }316 },317 {318 "name": "Nazism",319 "stats": {320 "econ": 40,321 "dipl": 0,322 "govt": 0,323 "scty": 5324 }325 },326 {327 "name": "Autocracy",328 "stats": {329 "econ": 50,330 "dipl": 20,331 "govt": 20,332 "scty": 50333 }334 },335 {336 "name": "Fascism",337 "stats": {338 "econ": 40,339 "dipl": 20,340 "govt": 20,341 "scty": 20342 }343 },344 {345 "name": "Capitalist Fascism",346 "stats": {347 "econ": 20,348 "dipl": 20,349 "govt": 20,350 "scty": 20351 }352 },353 {354 "name": "Conservatism",355 "stats": {356 "econ": 30,357 "dipl": 40,358 "govt": 40,359 "scty": 20360 }361 },362 {363 "name": "Neo-Liberalism",364 "stats": {365 "econ": 30,366 "dipl": 30,367 "govt": 50,368 "scty": 60369 }370 },371 {372 "name": "Classical Liberalism",373 "stats": {374 "econ": 30,375 "dipl": 60,376 "govt": 60,377 "scty": 80378 }379 },380 {381 "name": "Authoritarian Capitalism",382 "stats": {383 "econ": 20,384 "dipl": 30,385 "govt": 20,386 "scty": 40387 }388 },389 {390 "name": "State Capitalism",391 "stats": {392 "econ": 20,393 "dipl": 50,394 "govt": 30,395 "scty": 50396 }397 },398 {399 "name": "Neo-Conservatism",400 "stats": {401 "econ": 20,402 "dipl": 20,403 "govt": 40,404 "scty": 20405 }406 },407 {408 "name": "Fundamentalism",409 "stats": {410 "econ": 20,411 "dipl": 30,412 "govt": 30,413 "scty": 5414 }415 },416 {417 "name": "Libertarian Capitalism",418 "stats": {419 "econ": 20,420 "dipl": 50,421 "govt": 80,422 "scty": 60423 }424 },425 {426 "name": "Market Anarchism",427 "stats": {428 "econ": 20,429 "dipl": 50,430 "govt": 100,431 "scty": 50432 }433 },434 {435 "name": "Objectivism",436 "stats": {437 "econ": 10,438 "dipl": 50,439 "govt": 90,440 "scty": 40441 }442 },443 {444 "name": "Totalitarian Capitalism",445 "stats": {446 "econ": 0,447 "dipl": 30,448 "govt": 0,449 "scty": 50450 }451 },452 {453 "name": "Ultra-Capitalism",454 "stats": {455 "econ": 0,456 "dipl": 40,457 "govt": 50,458 "scty": 50459 }460 },461 {462 "name": "Anarcho-Capitalism",463 "stats": {464 "econ": 0,465 "dipl": 50,466 "govt": 100,467 "scty": 50468 }469 }
...
Compiler-caching.test.js
Source:Compiler-caching.test.js
1/* globals describe, it */2"use strict";3const path = require("path");4const fs = require("fs");5const rimraf = require("rimraf");6const webpack = require("../");7const WebpackOptionsDefaulter = require("../lib/WebpackOptionsDefaulter");8let fixtureCount = 0;9describe("Compiler (caching)", () => {10 jest.setTimeout(15000);11 function compile(entry, options, callback) {12 options.mode = "none";13 options = new WebpackOptionsDefaulter().process(options);14 options.cache = true;15 options.entry = entry;16 options.optimization.minimize = false;17 options.context = path.join(__dirname, "fixtures");18 options.output.path = "/";19 options.output.filename = "bundle.js";20 options.output.pathinfo = true;21 const logs = {22 mkdirp: [],23 writeFile: []24 };25 const c = webpack(options);26 const files = {};27 c.outputFileSystem = {28 join() {29 return [].join.call(arguments, "/").replace(/\/+/g, "/");30 },31 mkdirp(path, callback) {32 logs.mkdirp.push(path);33 callback();34 },35 writeFile(name, content, callback) {36 logs.writeFile.push(name, content);37 files[name] = content.toString("utf-8");38 callback();39 }40 };41 c.hooks.compilation.tap(42 "CompilerCachingTest",43 compilation => (compilation.bail = true)44 );45 let compilerIteration = 1;46 function runCompiler(options, callback) {47 if (typeof options === "function") {48 callback = options;49 options = {};50 }51 c.run((err, stats) => {52 if (err) throw err;53 expect(typeof stats).toBe("object");54 stats = stats.toJson({55 modules: true,56 reasons: true57 });58 expect(typeof stats).toBe("object");59 expect(stats).toHaveProperty("errors");60 expect(Array.isArray(stats.errors)).toBe(true);61 if (options.expectErrors) {62 expect(stats.errors).toHaveLength(options.expectErrors);63 } else {64 if (stats.errors.length > 0) {65 expect(typeof stats.errors[0]).toBe("string");66 throw new Error(stats.errors[0]);67 }68 }69 stats.logs = logs;70 callback(stats, files, compilerIteration++);71 });72 }73 runCompiler(callback);74 return {75 compilerInstance: c,76 runAgain: runCompiler77 };78 }79 const tempFixturePath = path.join(80 __dirname,81 "fixtures",82 "temp-cache-fixture"83 );84 function cleanup() {85 rimraf.sync(`${tempFixturePath}-*`);86 }87 beforeAll(cleanup);88 afterAll(cleanup);89 function createTempFixture() {90 const fixturePath = `${tempFixturePath}-${fixtureCount}`;91 const aFilepath = path.join(fixturePath, "a.js");92 const cFilepath = path.join(fixturePath, "c.js");93 // Remove previous copy if present94 rimraf.sync(fixturePath);95 // Copy over file since we"ll be modifying some of them96 fs.mkdirSync(fixturePath);97 fs.createReadStream(path.join(__dirname, "fixtures", "a.js")).pipe(98 fs.createWriteStream(aFilepath)99 );100 fs.createReadStream(path.join(__dirname, "fixtures", "c.js")).pipe(101 fs.createWriteStream(cFilepath)102 );103 fixtureCount++;104 return {105 rootPath: fixturePath,106 aFilepath: aFilepath,107 cFilepath: cFilepath108 };109 }110 it("should cache single file (with manual 1s wait) ", done => {111 const options = {};112 const tempFixture = createTempFixture();113 const helper = compile(tempFixture.cFilepath, options, (stats, files) => {114 // Not cached the first time115 expect(stats.assets[0].name).toBe("bundle.js");116 expect(stats.assets[0].emitted).toBe(true);117 helper.runAgain((stats, files, iteration) => {118 // Cached the second run119 expect(stats.assets[0].name).toBe("bundle.js");120 expect(stats.assets[0].emitted).toBe(false);121 const aContent = fs122 .readFileSync(tempFixture.aFilepath)123 .toString()124 .replace("This is a", "This is a MODIFIED");125 setTimeout(() => {126 fs.writeFileSync(tempFixture.aFilepath, aContent);127 helper.runAgain((stats, files, iteration) => {128 // Cached the third run129 expect(stats.assets[0].name).toBe("bundle.js");130 expect(stats.assets[0].emitted).toBe(true);131 done();132 });133 }, 1100);134 });135 });136 });137 it("should cache single file (even with no timeout) ", done => {138 const options = {};139 const tempFixture = createTempFixture();140 const helper = compile(tempFixture.cFilepath, options, (stats, files) => {141 // Not cached the first time142 expect(stats.assets[0].name).toBe("bundle.js");143 expect(stats.assets[0].emitted).toBe(true);144 helper.runAgain((stats, files, iteration) => {145 // Cached the second run146 expect(stats.assets[0].name).toBe("bundle.js");147 expect(stats.assets[0].emitted).toBe(false);148 expect(files["/bundle.js"]).toMatch("This is a");149 const aContent = fs150 .readFileSync(tempFixture.aFilepath)151 .toString()152 .replace("This is a", "This is a MODIFIED");153 fs.writeFileSync(tempFixture.aFilepath, aContent);154 helper.runAgain((stats, files, iteration) => {155 // Cached the third run156 expect(stats.assets[0].name).toBe("bundle.js");157 expect(stats.assets[0].emitted).toBe(true);158 expect(files["/bundle.js"]).toMatch("This is a MODIFIED");159 done();160 });161 });162 });163 });164 it("should only build when modified (with manual 2s wait)", done => {165 const options = {};166 const tempFixture = createTempFixture();167 const helper = compile(tempFixture.cFilepath, options, (stats, files) => {168 // Built the first time169 expect(stats.modules[0].name).toMatch("c.js");170 expect(stats.modules[0].built).toBe(true);171 expect(stats.modules[1].name).toMatch("a.js");172 expect(stats.modules[1].built).toBe(true);173 setTimeout(() => {174 helper.runAgain((stats, files, iteration) => {175 // Not built when cached the second run176 expect(stats.modules[0].name).toMatch("c.js");177 // expect(stats.modules[0].built).toBe(false);178 expect(stats.modules[1].name).toMatch("a.js");179 // expect(stats.modules[1].built).toBe(false);180 const aContent = fs181 .readFileSync(tempFixture.aFilepath)182 .toString()183 .replace("This is a", "This is a MODIFIED");184 setTimeout(() => {185 fs.writeFileSync(tempFixture.aFilepath, aContent);186 helper.runAgain((stats, files, iteration) => {187 // And only a.js built after it was modified188 expect(stats.modules[0].name).toMatch("c.js");189 expect(stats.modules[0].built).toBe(false);190 expect(stats.modules[1].name).toMatch("a.js");191 expect(stats.modules[1].built).toBe(true);192 done();193 });194 }, 2100);195 });196 }, 4100);197 });198 });199 it("should build when modified (even with no timeout)", done => {200 const options = {};201 const tempFixture = createTempFixture();202 const helper = compile(tempFixture.cFilepath, options, (stats, files) => {203 // Built the first time204 expect(stats.modules[0].name).toMatch("c.js");205 expect(stats.modules[0].built).toBe(true);206 expect(stats.modules[1].name).toMatch("a.js");207 expect(stats.modules[1].built).toBe(true);208 helper.runAgain((stats, files, iteration) => {209 // Not built when cached the second run210 expect(stats.modules[0].name).toMatch("c.js");211 // expect(stats.modules[0].built).toBe(false);212 expect(stats.modules[1].name).toMatch("a.js");213 // expect(stats.modules[1].built).toBe(false);214 const aContent = fs215 .readFileSync(tempFixture.aFilepath)216 .toString()217 .replace("This is a", "This is a MODIFIED");218 fs.writeFileSync(tempFixture.aFilepath, aContent);219 helper.runAgain((stats, files, iteration) => {220 // And only a.js built after it was modified221 expect(stats.modules[0].name).toMatch("c.js");222 // expect(stats.modules[0].built).toBe(false);223 expect(stats.modules[1].name).toMatch("a.js");224 expect(stats.modules[1].built).toBe(true);225 done();226 });227 });228 });229 });...
stats_table.js
Source:stats_table.js
1// Copyright (c) 2013 The Chromium Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4/**5 * Maintains the stats table.6 * @param {SsrcInfoManager} ssrcInfoManager The source of the ssrc info.7 */8var StatsTable = (function(ssrcInfoManager) {9 'use strict';10 /**11 * @param {SsrcInfoManager} ssrcInfoManager The source of the ssrc info.12 * @constructor13 */14 function StatsTable(ssrcInfoManager) {15 /**16 * @type {SsrcInfoManager}17 * @private18 */19 this.ssrcInfoManager_ = ssrcInfoManager;20 }21 StatsTable.prototype = {22 /**23 * Adds |report| to the stats table of |peerConnectionElement|.24 *25 * @param {!Element} peerConnectionElement The root element.26 * @param {!Object} report The object containing stats, which is the object27 * containing timestamp and values, which is an array of strings, whose28 * even index entry is the name of the stat, and the odd index entry is29 * the value.30 */31 addStatsReport: function(peerConnectionElement, report) {32 var statsTable = this.ensureStatsTable_(peerConnectionElement, report);33 if (report.stats) {34 this.addStatsToTable_(statsTable,35 report.stats.timestamp, report.stats.values);36 }37 },38 /**39 * Ensure the DIV container for the stats tables is created as a child of40 * |peerConnectionElement|.41 *42 * @param {!Element} peerConnectionElement The root element.43 * @return {!Element} The stats table container.44 * @private45 */46 ensureStatsTableContainer_: function(peerConnectionElement) {47 var containerId = peerConnectionElement.id + '-table-container';48 var container = $(containerId);49 if (!container) {50 container = document.createElement('div');51 container.id = containerId;52 container.className = 'stats-table-container';53 var head = document.createElement('div');54 head.textContent = 'Stats Tables';55 container.appendChild(head);56 peerConnectionElement.appendChild(container);57 }58 return container;59 },60 /**61 * Ensure the stats table for track specified by |report| of PeerConnection62 * |peerConnectionElement| is created.63 *64 * @param {!Element} peerConnectionElement The root element.65 * @param {!Object} report The object containing stats, which is the object66 * containing timestamp and values, which is an array of strings, whose67 * even index entry is the name of the stat, and the odd index entry is68 * the value.69 * @return {!Element} The stats table element.70 * @private71 */72 ensureStatsTable_: function(peerConnectionElement, report) {73 var tableId = peerConnectionElement.id + '-table-' + report.id;74 var table = $(tableId);75 if (!table) {76 var container = this.ensureStatsTableContainer_(peerConnectionElement);77 var details = document.createElement('details');78 container.appendChild(details);79 var summary = document.createElement('summary');80 summary.textContent = report.id;81 details.appendChild(summary);82 table = document.createElement('table');83 details.appendChild(table);84 table.id = tableId;85 table.border = 1;86 table.innerHTML = '<tr><th colspan=2></th></tr>';87 table.rows[0].cells[0].textContent = 'Statistics ' + report.id;88 if (report.type == 'ssrc') {89 table.insertRow(1);90 table.rows[1].innerHTML = '<td colspan=2></td>';91 this.ssrcInfoManager_.populateSsrcInfo(92 table.rows[1].cells[0], GetSsrcFromReport(report));93 }94 }95 return table;96 },97 /**98 * Update |statsTable| with |time| and |statsData|.99 *100 * @param {!Element} statsTable Which table to update.101 * @param {number} time The number of miliseconds since epoch.102 * @param {Array.<string>} statsData An array of stats name and value pairs.103 * @private104 */105 addStatsToTable_: function(statsTable, time, statsData) {106 var date = Date(time);107 this.updateStatsTableRow_(statsTable, 'timestamp', date.toLocaleString());108 for (var i = 0; i < statsData.length - 1; i = i + 2) {109 this.updateStatsTableRow_(statsTable, statsData[i], statsData[i + 1]);110 }111 },112 /**113 * Update the value column of the stats row of |rowName| to |value|.114 * A new row is created is this is the first report of this stats.115 *116 * @param {!Element} statsTable Which table to update.117 * @param {string} rowName The name of the row to update.118 * @param {string} value The new value to set.119 * @private120 */121 updateStatsTableRow_: function(statsTable, rowName, value) {122 var trId = statsTable.id + '-' + rowName;123 var trElement = $(trId);124 if (!trElement) {125 trElement = document.createElement('tr');126 trElement.id = trId;127 statsTable.firstChild.appendChild(trElement);128 trElement.innerHTML = '<td>' + rowName + '</td><td></td>';129 }130 trElement.cells[1].textContent = value;131 // Highlights the table for the active connection.132 if (rowName == 'googActiveConnection' && value == 'true')133 statsTable.parentElement.classList.add('stats-table-active-connection');134 }135 };136 return StatsTable;...
MultiStats.unittest.js
Source:MultiStats.unittest.js
1"use strict";2const packageJSON = require("../package.json");3const MultiStats = require("../lib/MultiStats");4const createStat = overrides => {5 return Object.assign(6 {7 hash: "foo",8 compilation: {9 name: "bar"10 },11 hasErrors: () => false,12 hasWarnings: () => false,13 toJson: () =>14 Object.assign(15 {16 hash: "foo",17 version: "version",18 warnings: [],19 errors: []20 },21 overrides22 )23 },24 overrides25 );26};27describe("MultiStats", () => {28 let packageVersion, stats, myMultiStats, result;29 beforeEach(() => {30 packageVersion = packageJSON.version;31 packageJSON.version = "1.2.3";32 });33 afterEach(() => {34 packageJSON.version = packageVersion;35 });36 describe("created", () => {37 beforeEach(() => {38 stats = [39 createStat({40 hash: "abc123"41 }),42 createStat({43 hash: "xyz890"44 })45 ];46 myMultiStats = new MultiStats(stats);47 });48 it("creates a hash string", () => {49 expect(myMultiStats.hash).toBe("abc123xyz890");50 });51 });52 describe("hasErrors", () => {53 describe("when both have errors", () => {54 beforeEach(() => {55 stats = [56 createStat({57 hasErrors: () => true58 }),59 createStat({60 hasErrors: () => true61 })62 ];63 myMultiStats = new MultiStats(stats);64 });65 it("returns true", () => {66 expect(myMultiStats.hasErrors()).toBe(true);67 });68 });69 describe("when one has an error", () => {70 beforeEach(() => {71 stats = [72 createStat({73 hasErrors: () => true74 }),75 createStat()76 ];77 myMultiStats = new MultiStats(stats);78 });79 it("returns true", () => {80 expect(myMultiStats.hasErrors()).toBe(true);81 });82 });83 describe("when none have errors", () => {84 beforeEach(() => {85 stats = [createStat(), createStat()];86 myMultiStats = new MultiStats(stats);87 });88 it("returns false", () => {89 expect(myMultiStats.hasErrors()).toBe(false);90 });91 });92 });93 describe("hasWarnings", () => {94 describe("when both have warnings", () => {95 beforeEach(() => {96 stats = [97 createStat({98 hasWarnings: () => true99 }),100 createStat({101 hasWarnings: () => true102 })103 ];104 myMultiStats = new MultiStats(stats);105 });106 it("returns true", () => {107 expect(myMultiStats.hasWarnings()).toBe(true);108 });109 });110 describe("when one has a warning", () => {111 beforeEach(() => {112 stats = [113 createStat({114 hasWarnings: () => true115 }),116 createStat()117 ];118 myMultiStats = new MultiStats(stats);119 });120 it("returns true", () => {121 expect(myMultiStats.hasWarnings()).toBe(true);122 });123 });124 describe("when none have warnings", () => {125 beforeEach(() => {126 stats = [createStat(), createStat()];127 myMultiStats = new MultiStats(stats);128 });129 it("returns false", () => {130 expect(myMultiStats.hasWarnings()).toBe(false);131 });132 });133 });134 describe("toJson", () => {135 beforeEach(() => {136 stats = [137 createStat({138 hash: "abc123",139 compilation: {140 name: "abc123-compilation"141 },142 toJson: () => ({143 warnings: ["abc123-warning"],144 errors: ["abc123-error"]145 })146 }),147 createStat({148 hash: "xyz890",149 compilation: {150 name: "xyz890-compilation"151 },152 toJson: () => ({153 warnings: ["xyz890-warning-1", "xyz890-warning-2"],154 errors: []155 })156 })157 ];158 });159 it("returns plain object representation", () => {160 myMultiStats = new MultiStats(stats);161 result = myMultiStats.toJson({162 version: false,163 hash: false164 });165 expect(result).toEqual({166 errors: ["(abc123-compilation) abc123-error"],167 warnings: [168 "(abc123-compilation) abc123-warning",169 "(xyz890-compilation) xyz890-warning-1",170 "(xyz890-compilation) xyz890-warning-2"171 ],172 children: [173 {174 errors: ["abc123-error"],175 name: "abc123-compilation",176 warnings: ["abc123-warning"]177 },178 {179 errors: [],180 name: "xyz890-compilation",181 warnings: ["xyz890-warning-1", "xyz890-warning-2"]182 }183 ]184 });185 });186 it("returns plain object representation with json set to true", () => {187 myMultiStats = new MultiStats(stats);188 result = myMultiStats.toJson(true);189 expect(result).toEqual({190 errors: ["(abc123-compilation) abc123-error"],191 warnings: [192 "(abc123-compilation) abc123-warning",193 "(xyz890-compilation) xyz890-warning-1",194 "(xyz890-compilation) xyz890-warning-2"195 ],196 children: [197 {198 warnings: ["abc123-warning"],199 errors: ["abc123-error"],200 name: "abc123-compilation"201 },202 {203 warnings: ["xyz890-warning-1", "xyz890-warning-2"],204 errors: [],205 name: "xyz890-compilation"206 }207 ]208 });209 });210 });211 describe("toString", () => {212 beforeEach(() => {213 stats = [214 createStat({215 hash: "abc123",216 compilation: {217 name: "abc123-compilation"218 }219 }),220 createStat({221 hash: "xyz890",222 compilation: {223 name: "xyz890-compilation"224 }225 })226 ];227 myMultiStats = new MultiStats(stats);228 result = myMultiStats.toString();229 });230 it("returns string representation", () => {231 expect(result).toEqual(232 "Hash: abc123xyz890\n" +233 "Version: webpack 1.2.3\n" +234 "Child abc123-compilation:\n" +235 " Hash: abc123\n" +236 "Child xyz890-compilation:\n" +237 " Hash: xyz890"238 );239 });240 });...
user-stats.js
Source:user-stats.js
1//----------------------------------------------------------------------------------------------------------------------------------------------------2// User Stats Object3//----------------------------------------------------------------------------------------------------------------------------------------------------4// A high-performance wrapper for chrome.storage.sync for storing user statistics5var StatsFactory = function() {6 // Constants7 var SAVE_STATS_MIN_INTERVAL = 500; // 500ms8 // Generate a random 10-character alphanumeric string9 var getRandomId = function() {10 var randomPool = new Uint8Array(32); // 8 * 32 = 256 bits token11 crypto.getRandomValues(randomPool);12 var hex = '';13 for (var i = 0; i < randomPool.length; ++i) {14 hex += randomPool[i].toString(16);15 }16 // e.g. db18458e2782b2b77e36769c569e263a53885a9944dd0a861e5064eac16f1a17 return hex.substr(0, 10); // e.g. db18458e2718 };19 // Default stats for new users20 var DEFAULT_STATS = {21 // Date and version of first installation22 'installVer': chrome.runtime.getManifest().version,23 'installDate': (new Date()).getTime(),24 // User type: (r)egular or (p)ro25 'type': 'r',26 // userId (aka machineId) is used to anonymously identify the machine on operations like PayPal payments27 'userId': getRandomId(),28 // analyticsId is used to anonymously identify *unique* users when reporting analytics events29 'analyticsId': getRandomId()30 };31 // Class variables32 var _saveStatsTimeout = null;33 var _stats = {};34 // Internal method: save stats to cookie35 var _saveStatsToCookie = function(callback) {36 var statsToSave = {37 analyticsId: _stats.analyticsId,38 installDate: _stats.installDate,39 installVer: _stats.installVer,40 type: _stats.type41 }42 var statsJson = JSON.stringify(statsToSave);43 var cookie = {44 url: "https://darkness.app",45 name: "darkness_stats",46 value: statsJson,47 domain: "darkness.app",48 path: "/",49 expirationDate: 2051222400,50 /* Year 2035 */51 }52 chrome.cookies.set(cookie, function(cookieSet) {53 if (cookieSet) {54 log("Cookie set: ", cookieSet);55 } else {56 logWarn("Cookie set error: ", chrome.runtime.lastError);57 }58 if (callback) callback();59 })60 }61 // Internal method: load stats from chrome.storage62 var _loadStats = function(callback) {63 log('Loading stats from Chrome');64 var keysToGet = {65 'stats': DEFAULT_STATS66 };67 chrome.storage.sync.get(keysToGet, function(store) {68 // Uncomment this to test new user:69 // store = {};70 var isNewUser = false;71 if (!store || !store.stats || !store.stats.userId) {72 logWarn("Reseting to default stats:", DEFAULT_STATS);73 store.stats = DEFAULT_STATS;74 log('First-time user, set user ID to ' + store.stats['userId']);75 isNewUser = true;76 } else {77 log('Existing user with ID ' + store.stats['userId']);78 }79 _stats = store.stats;80 log('Stats loaded', _stats);81 if (isNewUser) {82 repEventByUser('users', 'new-users');83 }84 _saveStatsToCookie(function() {85 if (callback) callback();86 });87 });88 };89 // Internal method: Save stats to chrome.storage90 var _saveStats = function(callback) {91 // log('Saving stats to Chrome:', _stats);92 if (_saveStatsTimeout) {93 // Start the count again94 clearTimeout(_saveStatsTimeout);95 }96 _saveStatsTimeout = setTimeout(function() {97 var keysToSet = {98 'stats': _stats99 };100 chrome.storage.sync.set(keysToSet, function() {101 // log('Stats saved', _stats);102 _saveStatsTimeout = null;103 if (callback) callback();104 });105 }, SAVE_STATS_MIN_INTERVAL);106 };107 // Constructor108 function Stats(callback) {109 _loadStats(function() {110 _saveStats(function() {111 callback();112 });113 });114 }115 //------------------------------------------------------------------------------------------------------------------------------------------------116 // Global objects and functions117 //------------------------------------------------------------------------------------------------------------------------------------------------118 Stats.prototype.set = function(key, val) {119 _stats[key] = val;120 _saveStats();121 if (key == 'type') {122 _saveStatsToCookie();123 }124 };125 Stats.prototype.get = function(key) {126 // Migration of older users without analyticsId: create analyticsId on the fly127 if (key == 'analyticsId' && typeof(_stats[key]) == 'undefined') {128 Stats.prototype.set(key, getRandomId());129 }130 return _stats[key];131 };132 Stats.prototype.remove = function(key) {133 if (typeof(_stats[key]) != 'undefined') delete _stats[key];134 _saveStats();135 };136 Stats.prototype.resetAllStats = function(callback) {137 var oldStats = stats.getAllStatsClone();138 chrome.storage.sync.remove(['stats'], function() {139 if (chrome.runtime.lastError) {140 logError("Error deleting all stats:", chrome.runtime.lastError);141 callback(chrome.runtime.lastError, oldStats);142 } else {143 log("Deleted all stats. Old stats were: ", oldStats);144 // _loadSettings will reset all settings to default ones145 _loadStats(function() {146 _saveStats(function() {147 callback(null, oldStats);148 });149 });150 }151 });152 };153 Stats.prototype.getAllStatsClone = function() {154 return JSON.parse(JSON.stringify(_stats))155 };156 return Stats;157};158// Run the function that builds the class...
Stats.unittest.js
Source:Stats.unittest.js
1/*globals describe it */2"use strict";3const Stats = require("../lib/Stats");4const packageJson = require("../package.json");5describe(6 "Stats",7 () => {8 describe("formatFilePath", () => {9 it("emit the file path and request", () => {10 const mockStats = new Stats({11 children: [],12 errors: ["firstError"],13 hash: "1234",14 compiler: {15 context: ""16 }17 });18 const inputPath =19 "./node_modules/ts-loader!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/app.vue";20 const expectPath = `./src/app.vue (${inputPath})`;21 expect(mockStats.formatFilePath(inputPath)).toBe(expectPath);22 });23 });24 describe("Error Handling", () => {25 describe("does have", () => {26 it("hasErrors", () => {27 const mockStats = new Stats({28 children: [],29 errors: ["firstError"],30 hash: "1234",31 compiler: {32 context: ""33 }34 });35 expect(mockStats.hasErrors()).toBe(true);36 });37 it("hasWarnings", () => {38 const mockStats = new Stats({39 children: [],40 warnings: ["firstError"],41 hash: "1234",42 compiler: {43 context: ""44 }45 });46 expect(mockStats.hasWarnings()).toBe(true);47 });48 });49 describe("does not have", () => {50 it("hasErrors", () => {51 const mockStats = new Stats({52 children: [],53 errors: [],54 hash: "1234",55 compiler: {56 context: ""57 }58 });59 expect(mockStats.hasErrors()).toBe(false);60 });61 it("hasWarnings", () => {62 const mockStats = new Stats({63 children: [],64 warnings: [],65 hash: "1234",66 compiler: {67 context: ""68 }69 });70 expect(mockStats.hasWarnings()).toBe(false);71 });72 });73 describe("children have", () => {74 it("hasErrors", () => {75 const mockStats = new Stats({76 children: [77 {78 getStats: () =>79 new Stats({80 errors: ["firstError"],81 hash: "5678"82 })83 }84 ],85 errors: [],86 hash: "1234"87 });88 expect(mockStats.hasErrors()).toBe(true);89 });90 it("hasWarnings", () => {91 const mockStats = new Stats({92 children: [93 {94 getStats: () =>95 new Stats({96 warnings: ["firstError"],97 hash: "5678"98 })99 }100 ],101 warnings: [],102 hash: "1234"103 });104 expect(mockStats.hasWarnings()).toBe(true);105 });106 });107 it("formatError handles string errors", () => {108 const mockStats = new Stats({109 errors: ["firstError"],110 warnings: [],111 assets: [],112 entrypoints: new Map(),113 namedChunkGroups: new Map(),114 chunks: [],115 modules: [],116 children: [],117 hash: "1234",118 mainTemplate: {119 outputOptions: {120 path: ""121 },122 getPublicPath: () => "path"123 },124 compiler: {125 context: ""126 }127 });128 const obj = mockStats.toJson();129 expect(obj.errors[0]).toEqual("firstError");130 });131 });132 describe("toJson", () => {133 it("returns plain object representation", () => {134 const mockStats = new Stats({135 errors: [],136 warnings: [],137 assets: [],138 entrypoints: new Map(),139 chunks: [],140 namedChunkGroups: new Map(),141 modules: [],142 children: [],143 hash: "1234",144 mainTemplate: {145 outputOptions: {146 path: "/"147 },148 getPublicPath: () => "path"149 },150 compiler: {151 context: ""152 }153 });154 const result = mockStats.toJson();155 expect(result).toEqual({156 assets: [],157 assetsByChunkName: {},158 children: [],159 chunks: [],160 entrypoints: {},161 namedChunkGroups: {},162 filteredAssets: 0,163 filteredModules: 0,164 errors: [],165 hash: "1234",166 modules: [],167 outputPath: "/",168 publicPath: "path",169 version: packageJson.version,170 warnings: []171 });172 });173 });174 describe("Presets", () => {175 describe("presetToOptions", () => {176 it("returns correct object with 'Normal'", () => {177 expect(Stats.presetToOptions("Normal")).toEqual({});178 });179 it("truthy values behave as 'normal'", () => {180 const normalOpts = Stats.presetToOptions("normal");181 expect(Stats.presetToOptions("pizza")).toEqual(normalOpts);182 expect(Stats.presetToOptions(true)).toEqual(normalOpts);183 expect(Stats.presetToOptions(1)).toEqual(normalOpts);184 expect(Stats.presetToOptions("verbose")).not.toEqual(normalOpts);185 expect(Stats.presetToOptions(false)).not.toEqual(normalOpts);186 });187 it("returns correct object with 'none'", () => {188 expect(Stats.presetToOptions("none")).toEqual({189 all: false190 });191 });192 it("falsy values behave as 'none'", () => {193 const noneOpts = Stats.presetToOptions("none");194 expect(Stats.presetToOptions("")).toEqual(noneOpts);195 expect(Stats.presetToOptions(null)).toEqual(noneOpts);196 expect(Stats.presetToOptions()).toEqual(noneOpts);197 expect(Stats.presetToOptions(0)).toEqual(noneOpts);198 expect(Stats.presetToOptions(false)).toEqual(noneOpts);199 });200 });201 });202 },203 10000...
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.stats();3var strykerParent = require('stryker-parent');4strykerParent.stats();5var strykerParent = require('stryker-parent');6strykerParent.stats();7var strykerParent = require('stryker-parent');8strykerParent.stats();9var strykerParent = require('stryker-parent');10strykerParent.stats();11var strykerParent = require('stryker-parent');12strykerParent.stats();13var strykerParent = require('stryker-parent');14strykerParent.stats();15var strykerParent = require('stryker-parent');16strykerParent.stats();17var strykerParent = require('stryker-parent');18strykerParent.stats();19var strykerParent = require('stryker-parent');20strykerParent.stats();21var strykerParent = require('stryker-parent');22strykerParent.stats();23var strykerParent = require('stryker-parent');24strykerParent.stats();25var strykerParent = require('stryker-parent');26strykerParent.stats();27var strykerParent = require('stryker-parent');28strykerParent.stats();29var strykerParent = require('stry
Using AI Code Generation
1const strykerParent = require('stryker-parent');2console.log(strykerParent.stats());3const strykerParent = require('stryker-parent');4console.log(strykerParent.stats());5const strykerParent = require('stryker-parent');6console.log(strykerParent.stats());7const strykerParent = require('stryker-parent');8console.log(strykerParent.stats());9const strykerParent = require('stryker-parent');10console.log(strykerParent.stats());11const strykerParent = require('stryker-parent');12console.log(strykerParent.stats());13const strykerParent = require('stryker-parent');14console.log(strykerParent.stats());15const strykerParent = require('stryker-parent');16console.log(strykerParent.stats());17const strykerParent = require('stryker-parent');18console.log(strykerParent.stats());19const strykerParent = require('stryker-parent');20console.log(strykerParent.stats());21const strykerParent = require('stryker-parent');22console.log(strykerParent.stats());23const strykerParent = require('stryker-parent');24console.log(strykerParent.stats());25const strykerParent = require('stryker-parent');26console.log(strykerParent.stats());27const strykerParent = require('stryker-parent');28console.log(strykerParent.stats());29const strykerParent = require('stry
Using AI Code Generation
1const strykerParent = require('stryker-parent');2strykerParent.stats();3const strykerChild = require('stryker-child');4strykerChild.stats();5const strykerParent = require('stryker-parent');6strykerParent.stats();7const strykerChild = require('stryker-child');8strykerChild.stats();9const strykerParent = require('stryker-parent');10strykerParent.stats();11const strykerChild = require('stryker-child');12strykerChild.stats();13const strykerParent = require('stryker-parent');14strykerParent.stats();15const strykerChild = require('stryker-child');16strykerChild.stats();17const strykerParent = require('stryker-parent');18strykerParent.stats();19const strykerChild = require('stryker-child');20strykerChild.stats();21const strykerParent = require('stryker-parent');22strykerParent.stats();23const strykerChild = require('stryker-child');24strykerChild.stats();25const strykerParent = require('stryker-parent');26strykerParent.stats();27const strykerChild = require('stryker-child');28strykerChild.stats();29const strykerParent = require('stryker-parent');30strykerParent.stats();
Using AI Code Generation
1const stryker = require('stryker-parent');2const stats = stryker.stats();3console.log(stats);4const child = require('stryker-child');5const stats = child.stats();6console.log(stats);7const child1 = require('stryker-child-1');8const stats = child1.stats();9console.log(stats);10const child2 = require('stryker-child-2');11const stats = child2.stats();12console.log(stats);13const stryker = require('stryker-parent');14const stats = stryker.stats();15console.log(stats);16const child = require('stryker-child');17const stats = child.stats();18console.log(stats);19const child1 = require('stryker-child-1');20const stats = child1.stats();21console.log(stats);22const child2 = require('stryker-child-2');23const stats = child2.stats();24console.log(stats);25const stryker = require('stryker-parent');26const stats = stryker.stats();27console.log(stats);28const child = require('stryker-child');29const stats = child.stats();30console.log(stats);31const child1 = require('stryker-child-1');32const stats = child1.stats();33console.log(stats);34const child2 = require('stryker-child-2');35const stats = child2.stats();36console.log(stats);37const stryker = require('stryker-parent');38const stats = stryker.stats();39console.log(stats);40const child = require('stryker-child');41const stats = child.stats();42console.log(stats);
Using AI Code Generation
1const strykerParent = require('stryker-parent');2const stats = strykerParent.stats();3console.log(stats);4const strykerChild = require('stryker-child');5const stats = strykerChild.stats();6console.log(stats);7{ totalMutants: 2, mutationScore: 0.5, killed: 1, survived: 1, timeout: 0, noCoverage: 0, runtimeErrors: 0, compileErrors: 0 }8{ totalMutants: 2, mutationScore: 0.5, killed: 1, survived: 1, timeout: 0, noCoverage: 0, runtimeErrors: 0, compileErrors: 0 }
Using AI Code Generation
1var stats = require('stryker-parent').stats;2var result = stats([1, 2, 3]);3console.log(result);4var stats = require('stryker-parent').stats;5var result = stats([1, 2, 3]);6console.log(result);7var stats = require('stryker-parent').stats;8var result = stats([1, 2, 3]);9console.log(result);10var stats = require('stryker-parent').stats;11var result = stats([1, 2, 3]);12console.log(result);13var stats = require('stryker-parent').stats;14var result = stats([1, 2, 3]);15console.log(result);16var stats = require('stryker-parent').stats;17var result = stats([1, 2, 3]);18console.log(result);19var stats = require('stryker-parent').stats;20var result = stats([1, 2, 3]);21console.log(result);22var stats = require('stryker-parent').stats;23var result = stats([1, 2, 3]);24console.log(result);25var stats = require('stryker-parent').stats;26var result = stats([1, 2, 3]);27console.log(result);28var stats = require('stryker-parent').stats;29var result = stats([1, 2, 3]);30console.log(result);31var stats = require('stryker-parent').stats;32var result = stats([1, 2, 3]);33console.log(result);
Using AI Code Generation
1var stats = require('stryker-parent').stats;2stats('test.js', 100, 100);3var stats = require('stryker-parent').stats;4stats('test.js', 100, 100);5var stats = require('stryker-parent').stats;6stats('test.js', 100, 100);7var stats = require('stryker-parent').stats;8stats('test.js', 100, 100);9var stats = require('stryker-parent').stats;10stats('test.js', 100, 100);11var stats = require('stryker-parent').stats;12stats('test.js', 100, 100);13var stats = require('stryker-parent').stats;14stats('test.js', 100, 100);15var stats = require('stryker-parent').stats;16stats('test.js', 100, 100);17var stats = require('stryker-parent').stats;18stats('test.js', 100, 100);19var stats = require('stryker-parent').stats;20stats('test.js', 100, 100);21var stats = require('stryker-parent').stats;22stats('test.js', 100, 100);23var stats = require('stryker-parent').stats;24stats('test.js', 100, 100);25var stats = require('stryker-parent').stats;26stats('test.js', 100,
Using AI Code Generation
1var stats = require('stryker-parent').stats;2var result = stats.mean([1, 2, 3, 4, 5]);3console.log(result);4var stats = require('stryker-parent').stats;5var result = stats.mean([1, 2, 3, 4, 5]);6console.log(result);7var stats = require('stryker-parent').stats;8var result = stats.mean([1, 2, 3, 4, 5]);9console.log(result);10var stats = require('stryker-parent').stats;11var result = stats.mean([1, 2, 3, 4, 5]);12console.log(result);13var stats = require('stryker-parent').stats;14var result = stats.mean([1, 2, 3, 4, 5]);15console.log(result);16var stats = require('stryker-parent').stats;17var result = stats.mean([1, 2, 3, 4, 5]);18console.log(result);19var stats = require('stryker-parent').stats;20var result = stats.mean([1, 2, 3, 4, 5]);21console.log(result);22var stats = require('stryker-parent').stats;23var result = stats.mean([1, 2, 3, 4, 5]);24console.log(result);
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!