Best JavaScript code snippet using playwright-internal
CardCase_invTypeLS_LSDocWorks.js
Source:CardCase_invTypeLS_LSDocWorks.js
1import React, {Component} from 'react';2import AntTabs from "./../../../AntTabs";3import MainInfoCaseForm from "../../../caseCards/MainInfoCaseForm";4import Damage from "./DamageWorks";5import {getIdGetObj,getCube} from "../../../../actions/actions";6import {7 CUBE_FOR_AF_CASE,8 DO_FOR_CASE, CUBE_FOR_AF_INV,9 DO_FOR_INV, DP_FOR_INV,CUBE_FOR_WORKS,DP_FOR_WORKS,DO_FOR_WORKS,10 DP_FOR_CASE11} from "../../../../constants/tofiConstants";12import connect from "react-redux/es/connect/connect";13import {isEmpty} from "lodash";14import {parseCube_new, parseForTable} from "../../../../utils/cubeParser";15import cubes from "../../../../reducers/cubes";16class CardCase_invTypeLS_LSDoc extends Component {17 state={18 idDimObjCase:'',19 data:{},20 dataInv:[],21 dataWork:[],22 rendercard:false,23 cubeger:false,24 keyInv:"",25 getInclusive:false ,26 showDamage:false27 };28 componentDidMount() {29 this.getById()30 }31 componentDidUpdate(prevProps){32 if (prevProps.initialValues !== this.props.initialValues) {33 this.getById()34 }35 }36 getWorks=()=>{37 this.setState({38 cubeger:true39 })40 const filters = {41 filterDOAnd: [42 {43 dimConst:DO_FOR_WORKS ,44 concatType: "and",45 conds: [{46 ids: String(this.props.stateRecord.key)47 }48 ]49 }50 ],51 filterDPAnd: [52 {53 dimConst: DP_FOR_WORKS,54 concatType: "and",55 conds: [56 {57 consts: "workRegInv"58 }59 ]60 }61 ]62 };63 this.props.getCube(CUBE_FOR_WORKS, JSON.stringify(filters))64 .then((res) => {65 this.parseWork(res.cube)66 })67 .catch(err => {68 console.error(err);69 this.setState({loading: false})70 })71 }72 componentWillUpdate (nextProps) {73 if (isEmpty(this.props.tofiConstants)) return;74 if (this.props.CubeForAF_Case !== nextProps.CubeForAF_Case) {75 const {doForCase, dpForCase} = nextProps.tofiConstants;76 this.setState(77 {78 data: parseCube_new(79 nextProps.CubeForAF_Case['cube'],80 [],81 'dp',82 'do',83 nextProps.CubeForAF_Case[`do_${doForCase.id}`],84 nextProps.CubeForAF_Case[`dp_${dpForCase.id}`],85 `do_${doForCase.id}`, `dp_${dpForCase.id}`).map(this.renderTableData)86 },()=>{87 if (this.state.getInclusive === false){88 let newArr = [...this.state.data]89 newArr[0].caseNumber= this.state.data[0].fundNumber90 this.setState({91 data:newArr92 })93 }94 this.getByIdInv(this.state.data[0].caseInventory.value)95 }96 );97 }98 }99 getById=()=>{100 this.props.initialValues.key? getIdGetObj(this.props.initialValues.key, 'doForCase')101 .then(res =>{102 this.setState({idDimObjCase:res.data.idDimObj, getInclusive:false});103 this.getCubeAct(res.data.idDimObj)104 }):setTimeout(()=>this.getWorks(),1000)105 }106 getByIdInv=(id)=>{107 getIdGetObj(id, DO_FOR_INV)108 .then(res =>{109 this.getCubeInv(res.data.idDimObj)110 if (this.state.cubeger ===true){111 this.getCasecube(res.data.idDimObj)112 }113 })114 }115 renderTableData = item => {116 const constArr = ["caseInventory","section","caseWorkProp","bunchCases","fundNumber","fundIndex","caseDbeg","caseDend","caseStructuralSubdivision","caseNotes","documentFile","caseNumberOfPages","structuralSubdivisionList","caseDocsLang","irreparablyDamaged","caseOCD","caseInsurance","caseFundOfUse","caseStorage","rack","shelf","propAuthenticity","fundFeature","caseDateOfDeposit","documentFile","dateForming","linkToKatalog","linkToUkaz","linkToObzor","surnameOriginator","uprDocType","storageUnitType","caseNomenItem","accountingUnitType","numberOfOriginals","compositionOfTextDocumentation","storageUnitQuantity","documentAuthor","addressee","question","terrain","documentDate","dateAccuracy","inaccurateDateFeature","day","month","year","typeOfPaperCarrier","objectCode","projectName","projectStage","projectPartName","volumeNumber","yearOfCompletion","accountingUnitNumber","authorTitle","cameraOperator","artistOfTheWork","dateOfRecording","timingOfVideoRecording","TypeAndFormatOfRecording","numberOfVideoItems","original","copy","shootingDate","shootPlace","movieVariant","formatAndBase","numberOfMovieItems","movieNegative","doubleNegative","phonogramNegative","phonogramMagnetic","intermediatePositive","positive","colorPassports","playingTime","mainContent","genre","eventLocation","firstLine","initialsOfAuthors","initialsOfTranslators","manufactureDate","manufacturePlace","serialNumber","numberOfPhonoItems","gremoriginal","gramplastine","recordPlace","soundingSpeed","magneticTapeType","photoDescription","documentShootAuthor","numberOfPhotoPrints","externalFeatures","productionNumber","numberOfPhotoItems","photoNegative","photoDoubleNegative","photoPositive","photocast","slide","filmStrip","terrain","electronicDocumentsFormat","personLastName","personName","personPatronymic","publicPositionOfPerson","propNationality","documentLanguage","documentPlaybackMethod"]117 const result = {118 key: item.id,119 name: item.name,120 parent: item.parent121 };122 parseForTable(item.props, this.props.tofiConstants, result, constArr);123 return result;124 };125 renderTableDataInv = item => {126 const constArr = ["invType","documentType"]127 const result = {128 key: item.id,129 };130 parseForTable(item.props, this.props.tofiConstants, result, constArr);131 return result;132 };133 renderTableDataWorks = item => {134 const constArr = ["workRegInv"]135 const result = {136 key: item.id,137 };138 parseForTable(item.props, this.props.tofiConstants, result, constArr);139 return result;140 };141 getCasecube=(id)=>{142 this.setState({143 cubeger:false,144 getInclusive:true145 })146 const filters = {147 filterDOAnd: [148 {149 dimConst: DO_FOR_CASE,150 concatType: "and",151 conds: [152 {153 //ids: '1007_144376'154 data: {155 valueRef: {156 id: String(id)157 }158 }159 }160 ]161 }162 ],163 filterDPAnd: [164 {165 dimConst: DP_FOR_CASE,166 concatType: "and",167 conds: [168 {169 consts: "caseInventory,caseWorkProp,bunchCases,section,fundNumber,fundIndex,caseDbeg,caseDend,caseStructuralSubdivision,caseNotes,documentFile,caseNumberOfPages,structuralSubdivisionList,caseDocsLang,irreparablyDamaged,caseOCD,caseInsurance,caseFundOfUse,caseStorage,rack,shelf,propAuthenticity,fundFeature,caseDateOfDeposit,documentFile,dateForming,linkToKatalog,linkToUkaz,linkToObzor,surnameOriginator,uprDocType,storageUnitType,caseNomenItem,accountingUnitType,numberOfOriginals,compositionOfTextDocumentation,storageUnitQuantity,documentAuthor,addressee,question,terrain,documentDate,dateAccuracy,inaccurateDateFeature,day,month,year,typeOfPaperCarrier,objectCode,projectName,projectStage,projectPartName,volumeNumber,yearOfCompletion,accountingUnitNumber,authorTitle,cameraOperator,artistOfTheWork,dateOfRecording,timingOfVideoRecording,TypeAndFormatOfRecording,numberOfVideoItems,original,copy,shootingDate,shootPlace,movieVariant,formatAndBase,numberOfMovieItems,movieNegative,doubleNegative,phonogramNegative,phonogramMagnetic,intermediatePositive,positive,colorPassports,playingTime,mainContent,genre,eventLocation,firstLine,initialsOfAuthors,initialsOfTranslators,manufactureDate,manufacturePlace,serialNumber,numberOfPhonoItems,gremoriginal,gramplastine,recordPlace,soundingSpeed,magneticTapeType,photoDescription,documentShootAuthor,numberOfPhotoPrints,externalFeatures,productionNumber,numberOfPhotoItems,photoNegative,photoDoubleNegative,photoPositive,photocast,slide,filmStrip,terrain,electronicDocumentsFormat,personLastName,personName,personPatronymic,publicPositionOfPerson,propNationality,documentLanguage,documentPlaybackMethod"170 }171 ]172 }173 ]174 };175 this.setState({loading: true});176 this.props.getCube(CUBE_FOR_AF_CASE, JSON.stringify(filters))177 .then(() => this.setState({loading: false}))178 .catch(err => {179 console.error(err);180 this.setState({loading: false})181 })182 }183 getCubeAct = (id) => {184 const filters = {185 filterDOAnd: [186 {187 dimConst: DO_FOR_CASE,188 concatType: "and",189 conds: [{190 ids: String(id)191 }192 ]193 }194 ],195 filterDPAnd: [196 {197 dimConst: DP_FOR_CASE,198 concatType: "and",199 conds: [200 {201 consts: "caseInventory,bunchCases,section,caseWorkProp,fundNumber,fundIndex,caseDbeg,caseDend,caseStructuralSubdivision,caseNotes,documentFile,caseNumberOfPages,structuralSubdivisionList,caseDocsLang,irreparablyDamaged,caseOCD,caseInsurance,caseFundOfUse,caseStorage,rack,shelf,propAuthenticity,fundFeature,caseDateOfDeposit,documentFile,dateForming,linkToKatalog,linkToUkaz,linkToObzor,surnameOriginator,uprDocType,storageUnitType,caseNomenItem,accountingUnitType,numberOfOriginals,compositionOfTextDocumentation,storageUnitQuantity,documentAuthor,addressee,question,terrain,documentDate,dateAccuracy,inaccurateDateFeature,day,month,year,typeOfPaperCarrier,objectCode,projectName,projectStage,projectPartName,volumeNumber,yearOfCompletion,accountingUnitNumber,authorTitle,cameraOperator,artistOfTheWork,dateOfRecording,timingOfVideoRecording,TypeAndFormatOfRecording,numberOfVideoItems,original,copy,shootingDate,shootPlace,movieVariant,formatAndBase,numberOfMovieItems,movieNegative,doubleNegative,phonogramNegative,phonogramMagnetic,intermediatePositive,positive,colorPassports,playingTime,mainContent,genre,eventLocation,firstLine,initialsOfAuthors,initialsOfTranslators,manufactureDate,manufacturePlace,serialNumber,numberOfPhonoItems,gremoriginal,gramplastine,recordPlace,soundingSpeed,magneticTapeType,photoDescription,documentShootAuthor,numberOfPhotoPrints,externalFeatures,productionNumber,numberOfPhotoItems,photoNegative,photoDoubleNegative,photoPositive,photocast,slide,filmStrip,terrain,electronicDocumentsFormat,personLastName,personName,personPatronymic,publicPositionOfPerson,propNationality,documentLanguage,documentPlaybackMethod"202 }203 ]204 }205 ]206 };207 this.props.getCube(CUBE_FOR_AF_CASE, JSON.stringify(filters))208 .then(() => this.setState({loading: false}))209 .catch(err => {210 console.error(err);211 this.setState({loading: false})212 })213 }214 getCubeInv = (id) => {215 const filters = {216 filterDOAnd: [217 {218 dimConst:DO_FOR_INV ,219 concatType: "and",220 conds: [{221 ids: String(id)222 }223 ]224 }225 ],226 filterDPAnd: [227 {228 dimConst: DP_FOR_INV,229 concatType: "and",230 conds: [231 {232 consts: "invType,documentType"233 }234 ]235 }236 ]237 };238 this.props.getCube(CUBE_FOR_AF_INV, JSON.stringify(filters))239 .then((res) => {240 this.parseInv(res.cube)241 })242 .catch(err => {243 console.error(err);244 this.setState({loading: false})245 })246 }247 parseInv=(cube)=>{248 const {doForInv, dpForInv} = this.props.tofiConstants;249 this.setState(250 {251 dataInv: parseCube_new(252 cube['cube'],253 [],254 'dp',255 'do',256 cube[`do_${doForInv.id}`],257 cube[`dp_${dpForInv.id}`],258 `do_${doForInv.id}`, `dp_${dpForInv.id}`).map(this.renderTableDataInv)259 },()=>{260 this.setState({261 rendercard:true262 })263 }264 );265 }266 parseWork=(cube)=>{267 const {doForWorks, dpForWorks} = this.props.tofiConstants;268 this.setState(269 {270 dataWork: parseCube_new(271 cube['cube'],272 [],273 'dp',274 'do',275 cube[`do_${doForWorks.id}`],276 cube[`dp_${dpForWorks.id}`],277 `do_${doForWorks.id}`, `dp_${dpForWorks.id}`).map(this.renderTableDataWorks)278 },()=>{279 this.setState({280 keyInv:this.state.dataWork[0].workRegInv.value281 })282 this.getByIdInv(this.state.dataWork[0].workRegInv.value)283 }284 );285 }286 render() {287 const {t, tofiConstants, saveProps, initialValues, onCreateObj, keyInv, stateRecord, invType, docType} = this.props;288 return(289 <div style={{overflowY:"auto"}}>290 {291 this.state.rendercard===true?<AntTabs292 tabs={[293 {294 tabKey: 'mainInfo',295 tabName: t('MAIN_INFO'),296 tabContent: <MainInfoCaseForm297 idDimObjCase={this.state.idDimObjCase}298 tofiConstants={tofiConstants}299 saveProps={saveProps}300 t={t}301 invType={this.state.dataInv[0].invType.value}302 docType={ this.state.dataInv[0].documentType.value}303 keyWork={this.props.stateRecord&& String(this.props.stateRecord.key)}304 onCreateObj={onCreateObj}305 keyInv={this.state.keyInv}306 keyInvFund={`1_${stateRecord.workRegInv.value}`}307 initialValues={this.state.getInclusive === false? this.state.data[0]:{sd:"t"} }308 />309 },310 this.state.idDimObjCase && {311 tabKey: 'damage',312 tabName: 'ÐовÑеждениÑ',313 tabContent: <Damage314 idDimObjCase={this.state.idDimObjCase}315 tofiConstants={tofiConstants}316 initialValues={initialValues}317 stateRecord={stateRecord}318 t={t}319 />320 }321 ]}322 />:""323 }324 </div>325 )326 }327}328function mapStateToProps(state) {329 return {330 CubeForAF_Case: state.cubes[CUBE_FOR_AF_CASE],331 CubeForAF_Inv: state.cubes[CUBE_FOR_AF_INV],332 }333}...
68efb5ReactPerf.js
Source:68efb5ReactPerf.js
...78 }).sort(function (a, b) {79 return b.totalDuration - a.totalDuration;80 });81}82function getInclusive() {83 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84 if (!__DEV__) {85 warnInProduction();86 return [];87 }88 var aggregatedStats = {};89 var affectedIDs = {};90 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91 var _treeSnapshot$instanc = treeSnapshot[instanceID],92 displayName = _treeSnapshot$instanc.displayName,93 ownerID = _treeSnapshot$instanc.ownerID;94 var owner = treeSnapshot[ownerID];95 var key = (owner ? owner.displayName + ' > ' : '') + displayName;96 var stats = aggregatedStats[key];97 if (!stats) {98 affectedIDs[key] = {};99 stats = aggregatedStats[key] = {100 key: key,101 instanceCount: 0,102 inclusiveRenderDuration: 0,103 renderCount: 0104 };105 }106 affectedIDs[key][instanceID] = true;107 applyUpdate(stats);108 }109 var isCompositeByID = {};110 flushHistory.forEach(function (flush) {111 var measurements = flush.measurements;112 measurements.forEach(function (measurement) {113 var instanceID = measurement.instanceID,114 timerType = measurement.timerType;115 if (timerType !== 'render') {116 return;117 }118 isCompositeByID[instanceID] = true;119 });120 });121 flushHistory.forEach(function (flush) {122 var measurements = flush.measurements,123 treeSnapshot = flush.treeSnapshot;124 measurements.forEach(function (measurement) {125 var duration = measurement.duration,126 instanceID = measurement.instanceID,127 timerType = measurement.timerType;128 if (timerType !== 'render') {129 return;130 }131 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132 stats.renderCount++;133 });134 var nextParentID = instanceID;135 while (nextParentID) {136 if (isCompositeByID[nextParentID]) {137 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138 stats.inclusiveRenderDuration += duration;139 });140 }141 nextParentID = treeSnapshot[nextParentID].parentID;142 }143 });144 });145 return Object.keys(aggregatedStats).map(function (key) {146 return babelHelpers.extends({}, aggregatedStats[key], {147 instanceCount: Object.keys(affectedIDs[key]).length148 });149 }).sort(function (a, b) {150 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151 });152}153function getWasted() {154 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155 if (!__DEV__) {156 warnInProduction();157 return [];158 }159 var aggregatedStats = {};160 var affectedIDs = {};161 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162 var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163 displayName = _treeSnapshot$instanc2.displayName,164 ownerID = _treeSnapshot$instanc2.ownerID;165 var owner = treeSnapshot[ownerID];166 var key = (owner ? owner.displayName + ' > ' : '') + displayName;167 var stats = aggregatedStats[key];168 if (!stats) {169 affectedIDs[key] = {};170 stats = aggregatedStats[key] = {171 key: key,172 instanceCount: 0,173 inclusiveRenderDuration: 0,174 renderCount: 0175 };176 }177 affectedIDs[key][instanceID] = true;178 applyUpdate(stats);179 }180 flushHistory.forEach(function (flush) {181 var measurements = flush.measurements,182 treeSnapshot = flush.treeSnapshot,183 operations = flush.operations;184 var isDefinitelyNotWastedByID = {};185 operations.forEach(function (operation) {186 var instanceID = operation.instanceID;187 var nextParentID = instanceID;188 while (nextParentID) {189 isDefinitelyNotWastedByID[nextParentID] = true;190 nextParentID = treeSnapshot[nextParentID].parentID;191 }192 });193 var renderedCompositeIDs = {};194 measurements.forEach(function (measurement) {195 var instanceID = measurement.instanceID,196 timerType = measurement.timerType;197 if (timerType !== 'render') {198 return;199 }200 renderedCompositeIDs[instanceID] = true;201 });202 measurements.forEach(function (measurement) {203 var duration = measurement.duration,204 instanceID = measurement.instanceID,205 timerType = measurement.timerType;206 if (timerType !== 'render') {207 return;208 }209 var updateCount = treeSnapshot[instanceID].updateCount;210 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211 return;212 }213 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214 stats.renderCount++;215 });216 var nextParentID = instanceID;217 while (nextParentID) {218 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219 if (isWasted) {220 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221 stats.inclusiveRenderDuration += duration;222 });223 }224 nextParentID = treeSnapshot[nextParentID].parentID;225 }226 });227 });228 return Object.keys(aggregatedStats).map(function (key) {229 return babelHelpers.extends({}, aggregatedStats[key], {230 instanceCount: Object.keys(affectedIDs[key]).length231 });232 }).sort(function (a, b) {233 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234 });235}236function getOperations() {237 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238 if (!__DEV__) {239 warnInProduction();240 return [];241 }242 var stats = [];243 flushHistory.forEach(function (flush, flushIndex) {244 var operations = flush.operations,245 treeSnapshot = flush.treeSnapshot;246 operations.forEach(function (operation) {247 var instanceID = operation.instanceID,248 type = operation.type,249 payload = operation.payload;250 var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251 displayName = _treeSnapshot$instanc3.displayName,252 ownerID = _treeSnapshot$instanc3.ownerID;253 var owner = treeSnapshot[ownerID];254 var key = (owner ? owner.displayName + ' > ' : '') + displayName;255 stats.push({256 flushIndex: flushIndex,257 instanceID: instanceID,258 key: key,259 type: type,260 ownerID: ownerID,261 payload: payload262 });263 });264 });265 return stats;266}267function printExclusive(flushHistory) {268 if (!__DEV__) {269 warnInProduction();270 return;271 }272 var stats = getExclusive(flushHistory);273 var table = stats.map(function (item) {274 var key = item.key,275 instanceCount = item.instanceCount,276 totalDuration = item.totalDuration;277 var renderCount = item.counts.render || 0;278 var renderDuration = item.durations.render || 0;279 return {280 'Component': key,281 'Total time (ms)': roundFloat(totalDuration),282 'Instance count': instanceCount,283 'Total render time (ms)': roundFloat(renderDuration),284 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285 'Render count': renderCount,286 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287 };288 });289 consoleTable(table);290}291function printInclusive(flushHistory) {292 if (!__DEV__) {293 warnInProduction();294 return;295 }296 var stats = getInclusive(flushHistory);297 var table = stats.map(function (item) {298 var key = item.key,299 instanceCount = item.instanceCount,300 inclusiveRenderDuration = item.inclusiveRenderDuration,301 renderCount = item.renderCount;302 return {303 'Owner > Component': key,304 'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305 'Instance count': instanceCount,306 'Render count': renderCount307 };308 });309 consoleTable(table);310}...
f4a167ReactPerf.js
Source:f4a167ReactPerf.js
...78 }).sort(function (a, b) {79 return b.totalDuration - a.totalDuration;80 });81}82function getInclusive() {83 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84 if (!__DEV__) {85 warnInProduction();86 return [];87 }88 var aggregatedStats = {};89 var affectedIDs = {};90 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91 var _treeSnapshot$instanc = treeSnapshot[instanceID],92 displayName = _treeSnapshot$instanc.displayName,93 ownerID = _treeSnapshot$instanc.ownerID;94 var owner = treeSnapshot[ownerID];95 var key = (owner ? owner.displayName + ' > ' : '') + displayName;96 var stats = aggregatedStats[key];97 if (!stats) {98 affectedIDs[key] = {};99 stats = aggregatedStats[key] = {100 key: key,101 instanceCount: 0,102 inclusiveRenderDuration: 0,103 renderCount: 0104 };105 }106 affectedIDs[key][instanceID] = true;107 applyUpdate(stats);108 }109 var isCompositeByID = {};110 flushHistory.forEach(function (flush) {111 var measurements = flush.measurements;112 measurements.forEach(function (measurement) {113 var instanceID = measurement.instanceID,114 timerType = measurement.timerType;115 if (timerType !== 'render') {116 return;117 }118 isCompositeByID[instanceID] = true;119 });120 });121 flushHistory.forEach(function (flush) {122 var measurements = flush.measurements,123 treeSnapshot = flush.treeSnapshot;124 measurements.forEach(function (measurement) {125 var duration = measurement.duration,126 instanceID = measurement.instanceID,127 timerType = measurement.timerType;128 if (timerType !== 'render') {129 return;130 }131 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132 stats.renderCount++;133 });134 var nextParentID = instanceID;135 while (nextParentID) {136 if (isCompositeByID[nextParentID]) {137 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138 stats.inclusiveRenderDuration += duration;139 });140 }141 nextParentID = treeSnapshot[nextParentID].parentID;142 }143 });144 });145 return Object.keys(aggregatedStats).map(function (key) {146 return babelHelpers.extends({}, aggregatedStats[key], {147 instanceCount: Object.keys(affectedIDs[key]).length148 });149 }).sort(function (a, b) {150 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151 });152}153function getWasted() {154 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155 if (!__DEV__) {156 warnInProduction();157 return [];158 }159 var aggregatedStats = {};160 var affectedIDs = {};161 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162 var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163 displayName = _treeSnapshot$instanc2.displayName,164 ownerID = _treeSnapshot$instanc2.ownerID;165 var owner = treeSnapshot[ownerID];166 var key = (owner ? owner.displayName + ' > ' : '') + displayName;167 var stats = aggregatedStats[key];168 if (!stats) {169 affectedIDs[key] = {};170 stats = aggregatedStats[key] = {171 key: key,172 instanceCount: 0,173 inclusiveRenderDuration: 0,174 renderCount: 0175 };176 }177 affectedIDs[key][instanceID] = true;178 applyUpdate(stats);179 }180 flushHistory.forEach(function (flush) {181 var measurements = flush.measurements,182 treeSnapshot = flush.treeSnapshot,183 operations = flush.operations;184 var isDefinitelyNotWastedByID = {};185 operations.forEach(function (operation) {186 var instanceID = operation.instanceID;187 var nextParentID = instanceID;188 while (nextParentID) {189 isDefinitelyNotWastedByID[nextParentID] = true;190 nextParentID = treeSnapshot[nextParentID].parentID;191 }192 });193 var renderedCompositeIDs = {};194 measurements.forEach(function (measurement) {195 var instanceID = measurement.instanceID,196 timerType = measurement.timerType;197 if (timerType !== 'render') {198 return;199 }200 renderedCompositeIDs[instanceID] = true;201 });202 measurements.forEach(function (measurement) {203 var duration = measurement.duration,204 instanceID = measurement.instanceID,205 timerType = measurement.timerType;206 if (timerType !== 'render') {207 return;208 }209 var updateCount = treeSnapshot[instanceID].updateCount;210 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211 return;212 }213 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214 stats.renderCount++;215 });216 var nextParentID = instanceID;217 while (nextParentID) {218 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219 if (isWasted) {220 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221 stats.inclusiveRenderDuration += duration;222 });223 }224 nextParentID = treeSnapshot[nextParentID].parentID;225 }226 });227 });228 return Object.keys(aggregatedStats).map(function (key) {229 return babelHelpers.extends({}, aggregatedStats[key], {230 instanceCount: Object.keys(affectedIDs[key]).length231 });232 }).sort(function (a, b) {233 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234 });235}236function getOperations() {237 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238 if (!__DEV__) {239 warnInProduction();240 return [];241 }242 var stats = [];243 flushHistory.forEach(function (flush, flushIndex) {244 var operations = flush.operations,245 treeSnapshot = flush.treeSnapshot;246 operations.forEach(function (operation) {247 var instanceID = operation.instanceID,248 type = operation.type,249 payload = operation.payload;250 var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251 displayName = _treeSnapshot$instanc3.displayName,252 ownerID = _treeSnapshot$instanc3.ownerID;253 var owner = treeSnapshot[ownerID];254 var key = (owner ? owner.displayName + ' > ' : '') + displayName;255 stats.push({256 flushIndex: flushIndex,257 instanceID: instanceID,258 key: key,259 type: type,260 ownerID: ownerID,261 payload: payload262 });263 });264 });265 return stats;266}267function printExclusive(flushHistory) {268 if (!__DEV__) {269 warnInProduction();270 return;271 }272 var stats = getExclusive(flushHistory);273 var table = stats.map(function (item) {274 var key = item.key,275 instanceCount = item.instanceCount,276 totalDuration = item.totalDuration;277 var renderCount = item.counts.render || 0;278 var renderDuration = item.durations.render || 0;279 return {280 'Component': key,281 'Total time (ms)': roundFloat(totalDuration),282 'Instance count': instanceCount,283 'Total render time (ms)': roundFloat(renderDuration),284 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285 'Render count': renderCount,286 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287 };288 });289 consoleTable(table);290}291function printInclusive(flushHistory) {292 if (!__DEV__) {293 warnInProduction();294 return;295 }296 var stats = getInclusive(flushHistory);297 var table = stats.map(function (item) {298 var key = item.key,299 instanceCount = item.instanceCount,300 inclusiveRenderDuration = item.inclusiveRenderDuration,301 renderCount = item.renderCount;302 return {303 'Owner > Component': key,304 'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305 'Instance count': instanceCount,306 'Render count': renderCount307 };308 });309 consoleTable(table);310}...
6b8a09e6ac23b036fdcd9bbaded5e50e7a430eReactPerf.js
Source:6b8a09e6ac23b036fdcd9bbaded5e50e7a430eReactPerf.js
...78 }).sort(function (a, b) {79 return b.totalDuration - a.totalDuration;80 });81}82function getInclusive() {83 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84 if (!__DEV__) {85 warnInProduction();86 return [];87 }88 var aggregatedStats = {};89 var affectedIDs = {};90 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91 var _treeSnapshot$instanc = treeSnapshot[instanceID],92 displayName = _treeSnapshot$instanc.displayName,93 ownerID = _treeSnapshot$instanc.ownerID;94 var owner = treeSnapshot[ownerID];95 var key = (owner ? owner.displayName + ' > ' : '') + displayName;96 var stats = aggregatedStats[key];97 if (!stats) {98 affectedIDs[key] = {};99 stats = aggregatedStats[key] = {100 key: key,101 instanceCount: 0,102 inclusiveRenderDuration: 0,103 renderCount: 0104 };105 }106 affectedIDs[key][instanceID] = true;107 applyUpdate(stats);108 }109 var isCompositeByID = {};110 flushHistory.forEach(function (flush) {111 var measurements = flush.measurements;112 measurements.forEach(function (measurement) {113 var instanceID = measurement.instanceID,114 timerType = measurement.timerType;115 if (timerType !== 'render') {116 return;117 }118 isCompositeByID[instanceID] = true;119 });120 });121 flushHistory.forEach(function (flush) {122 var measurements = flush.measurements,123 treeSnapshot = flush.treeSnapshot;124 measurements.forEach(function (measurement) {125 var duration = measurement.duration,126 instanceID = measurement.instanceID,127 timerType = measurement.timerType;128 if (timerType !== 'render') {129 return;130 }131 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132 stats.renderCount++;133 });134 var nextParentID = instanceID;135 while (nextParentID) {136 if (isCompositeByID[nextParentID]) {137 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138 stats.inclusiveRenderDuration += duration;139 });140 }141 nextParentID = treeSnapshot[nextParentID].parentID;142 }143 });144 });145 return Object.keys(aggregatedStats).map(function (key) {146 return babelHelpers.extends({}, aggregatedStats[key], {147 instanceCount: Object.keys(affectedIDs[key]).length148 });149 }).sort(function (a, b) {150 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151 });152}153function getWasted() {154 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155 if (!__DEV__) {156 warnInProduction();157 return [];158 }159 var aggregatedStats = {};160 var affectedIDs = {};161 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162 var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163 displayName = _treeSnapshot$instanc2.displayName,164 ownerID = _treeSnapshot$instanc2.ownerID;165 var owner = treeSnapshot[ownerID];166 var key = (owner ? owner.displayName + ' > ' : '') + displayName;167 var stats = aggregatedStats[key];168 if (!stats) {169 affectedIDs[key] = {};170 stats = aggregatedStats[key] = {171 key: key,172 instanceCount: 0,173 inclusiveRenderDuration: 0,174 renderCount: 0175 };176 }177 affectedIDs[key][instanceID] = true;178 applyUpdate(stats);179 }180 flushHistory.forEach(function (flush) {181 var measurements = flush.measurements,182 treeSnapshot = flush.treeSnapshot,183 operations = flush.operations;184 var isDefinitelyNotWastedByID = {};185 operations.forEach(function (operation) {186 var instanceID = operation.instanceID;187 var nextParentID = instanceID;188 while (nextParentID) {189 isDefinitelyNotWastedByID[nextParentID] = true;190 nextParentID = treeSnapshot[nextParentID].parentID;191 }192 });193 var renderedCompositeIDs = {};194 measurements.forEach(function (measurement) {195 var instanceID = measurement.instanceID,196 timerType = measurement.timerType;197 if (timerType !== 'render') {198 return;199 }200 renderedCompositeIDs[instanceID] = true;201 });202 measurements.forEach(function (measurement) {203 var duration = measurement.duration,204 instanceID = measurement.instanceID,205 timerType = measurement.timerType;206 if (timerType !== 'render') {207 return;208 }209 var updateCount = treeSnapshot[instanceID].updateCount;210 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211 return;212 }213 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214 stats.renderCount++;215 });216 var nextParentID = instanceID;217 while (nextParentID) {218 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219 if (isWasted) {220 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221 stats.inclusiveRenderDuration += duration;222 });223 }224 nextParentID = treeSnapshot[nextParentID].parentID;225 }226 });227 });228 return Object.keys(aggregatedStats).map(function (key) {229 return babelHelpers.extends({}, aggregatedStats[key], {230 instanceCount: Object.keys(affectedIDs[key]).length231 });232 }).sort(function (a, b) {233 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234 });235}236function getOperations() {237 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238 if (!__DEV__) {239 warnInProduction();240 return [];241 }242 var stats = [];243 flushHistory.forEach(function (flush, flushIndex) {244 var operations = flush.operations,245 treeSnapshot = flush.treeSnapshot;246 operations.forEach(function (operation) {247 var instanceID = operation.instanceID,248 type = operation.type,249 payload = operation.payload;250 var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251 displayName = _treeSnapshot$instanc3.displayName,252 ownerID = _treeSnapshot$instanc3.ownerID;253 var owner = treeSnapshot[ownerID];254 var key = (owner ? owner.displayName + ' > ' : '') + displayName;255 stats.push({256 flushIndex: flushIndex,257 instanceID: instanceID,258 key: key,259 type: type,260 ownerID: ownerID,261 payload: payload262 });263 });264 });265 return stats;266}267function printExclusive(flushHistory) {268 if (!__DEV__) {269 warnInProduction();270 return;271 }272 var stats = getExclusive(flushHistory);273 var table = stats.map(function (item) {274 var key = item.key,275 instanceCount = item.instanceCount,276 totalDuration = item.totalDuration;277 var renderCount = item.counts.render || 0;278 var renderDuration = item.durations.render || 0;279 return {280 Component: key,281 'Total time (ms)': roundFloat(totalDuration),282 'Instance count': instanceCount,283 'Total render time (ms)': roundFloat(renderDuration),284 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285 'Render count': renderCount,286 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287 };288 });289 consoleTable(table);290}291function printInclusive(flushHistory) {292 if (!__DEV__) {293 warnInProduction();294 return;295 }296 var stats = getInclusive(flushHistory);297 var table = stats.map(function (item) {298 var key = item.key,299 instanceCount = item.instanceCount,300 inclusiveRenderDuration = item.inclusiveRenderDuration,301 renderCount = item.renderCount;302 return {303 'Owner > Component': key,304 'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305 'Instance count': instanceCount,306 'Render count': renderCount307 };308 });309 consoleTable(table);310}...
4f6f1d9940abdbde02bf79638e13ce51d8d1b7ReactPerf.js
Source:4f6f1d9940abdbde02bf79638e13ce51d8d1b7ReactPerf.js
...78 }).sort(function (a, b) {79 return b.totalDuration - a.totalDuration;80 });81}82function getInclusive() {83 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();84 if (!__DEV__) {85 warnInProduction();86 return [];87 }88 var aggregatedStats = {};89 var affectedIDs = {};90 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {91 var _treeSnapshot$instanc = treeSnapshot[instanceID],92 displayName = _treeSnapshot$instanc.displayName,93 ownerID = _treeSnapshot$instanc.ownerID;94 var owner = treeSnapshot[ownerID];95 var key = (owner ? owner.displayName + ' > ' : '') + displayName;96 var stats = aggregatedStats[key];97 if (!stats) {98 affectedIDs[key] = {};99 stats = aggregatedStats[key] = {100 key: key,101 instanceCount: 0,102 inclusiveRenderDuration: 0,103 renderCount: 0104 };105 }106 affectedIDs[key][instanceID] = true;107 applyUpdate(stats);108 }109 var isCompositeByID = {};110 flushHistory.forEach(function (flush) {111 var measurements = flush.measurements;112 measurements.forEach(function (measurement) {113 var instanceID = measurement.instanceID,114 timerType = measurement.timerType;115 if (timerType !== 'render') {116 return;117 }118 isCompositeByID[instanceID] = true;119 });120 });121 flushHistory.forEach(function (flush) {122 var measurements = flush.measurements,123 treeSnapshot = flush.treeSnapshot;124 measurements.forEach(function (measurement) {125 var duration = measurement.duration,126 instanceID = measurement.instanceID,127 timerType = measurement.timerType;128 if (timerType !== 'render') {129 return;130 }131 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {132 stats.renderCount++;133 });134 var nextParentID = instanceID;135 while (nextParentID) {136 if (isCompositeByID[nextParentID]) {137 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {138 stats.inclusiveRenderDuration += duration;139 });140 }141 nextParentID = treeSnapshot[nextParentID].parentID;142 }143 });144 });145 return Object.keys(aggregatedStats).map(function (key) {146 return babelHelpers.extends({}, aggregatedStats[key], {147 instanceCount: Object.keys(affectedIDs[key]).length148 });149 }).sort(function (a, b) {150 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;151 });152}153function getWasted() {154 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();155 if (!__DEV__) {156 warnInProduction();157 return [];158 }159 var aggregatedStats = {};160 var affectedIDs = {};161 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {162 var _treeSnapshot$instanc2 = treeSnapshot[instanceID],163 displayName = _treeSnapshot$instanc2.displayName,164 ownerID = _treeSnapshot$instanc2.ownerID;165 var owner = treeSnapshot[ownerID];166 var key = (owner ? owner.displayName + ' > ' : '') + displayName;167 var stats = aggregatedStats[key];168 if (!stats) {169 affectedIDs[key] = {};170 stats = aggregatedStats[key] = {171 key: key,172 instanceCount: 0,173 inclusiveRenderDuration: 0,174 renderCount: 0175 };176 }177 affectedIDs[key][instanceID] = true;178 applyUpdate(stats);179 }180 flushHistory.forEach(function (flush) {181 var measurements = flush.measurements,182 treeSnapshot = flush.treeSnapshot,183 operations = flush.operations;184 var isDefinitelyNotWastedByID = {};185 operations.forEach(function (operation) {186 var instanceID = operation.instanceID;187 var nextParentID = instanceID;188 while (nextParentID) {189 isDefinitelyNotWastedByID[nextParentID] = true;190 nextParentID = treeSnapshot[nextParentID].parentID;191 }192 });193 var renderedCompositeIDs = {};194 measurements.forEach(function (measurement) {195 var instanceID = measurement.instanceID,196 timerType = measurement.timerType;197 if (timerType !== 'render') {198 return;199 }200 renderedCompositeIDs[instanceID] = true;201 });202 measurements.forEach(function (measurement) {203 var duration = measurement.duration,204 instanceID = measurement.instanceID,205 timerType = measurement.timerType;206 if (timerType !== 'render') {207 return;208 }209 var updateCount = treeSnapshot[instanceID].updateCount;210 if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {211 return;212 }213 updateAggregatedStats(treeSnapshot, instanceID, function (stats) {214 stats.renderCount++;215 });216 var nextParentID = instanceID;217 while (nextParentID) {218 var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];219 if (isWasted) {220 updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {221 stats.inclusiveRenderDuration += duration;222 });223 }224 nextParentID = treeSnapshot[nextParentID].parentID;225 }226 });227 });228 return Object.keys(aggregatedStats).map(function (key) {229 return babelHelpers.extends({}, aggregatedStats[key], {230 instanceCount: Object.keys(affectedIDs[key]).length231 });232 }).sort(function (a, b) {233 return b.inclusiveRenderDuration - a.inclusiveRenderDuration;234 });235}236function getOperations() {237 var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();238 if (!__DEV__) {239 warnInProduction();240 return [];241 }242 var stats = [];243 flushHistory.forEach(function (flush, flushIndex) {244 var operations = flush.operations,245 treeSnapshot = flush.treeSnapshot;246 operations.forEach(function (operation) {247 var instanceID = operation.instanceID,248 type = operation.type,249 payload = operation.payload;250 var _treeSnapshot$instanc3 = treeSnapshot[instanceID],251 displayName = _treeSnapshot$instanc3.displayName,252 ownerID = _treeSnapshot$instanc3.ownerID;253 var owner = treeSnapshot[ownerID];254 var key = (owner ? owner.displayName + ' > ' : '') + displayName;255 stats.push({256 flushIndex: flushIndex,257 instanceID: instanceID,258 key: key,259 type: type,260 ownerID: ownerID,261 payload: payload262 });263 });264 });265 return stats;266}267function printExclusive(flushHistory) {268 if (!__DEV__) {269 warnInProduction();270 return;271 }272 var stats = getExclusive(flushHistory);273 var table = stats.map(function (item) {274 var key = item.key,275 instanceCount = item.instanceCount,276 totalDuration = item.totalDuration;277 var renderCount = item.counts.render || 0;278 var renderDuration = item.durations.render || 0;279 return {280 Component: key,281 'Total time (ms)': roundFloat(totalDuration),282 'Instance count': instanceCount,283 'Total render time (ms)': roundFloat(renderDuration),284 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,285 'Render count': renderCount,286 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)287 };288 });289 consoleTable(table);290}291function printInclusive(flushHistory) {292 if (!__DEV__) {293 warnInProduction();294 return;295 }296 var stats = getInclusive(flushHistory);297 var table = stats.map(function (item) {298 var key = item.key,299 instanceCount = item.instanceCount,300 inclusiveRenderDuration = item.inclusiveRenderDuration,301 renderCount = item.renderCount;302 return {303 'Owner > Component': key,304 'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),305 'Instance count': instanceCount,306 'Render count': renderCount307 };308 });309 consoleTable(table);310}...
ReactPerf.js
Source:ReactPerf.js
...64 affectedIDs[key][instanceID] = true;65 applyUpdate(stats);66 }67}68function getInclusive(flushHistory = getLastMeasurements()) {69 warnInProduction();70 return [];71 var aggregatedStats = {};72 var affectedIDs = {};73 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {74 var { displayName, ownerID } = treeSnapshot[instanceID];75 var owner = treeSnapshot[ownerID];76 var key = (owner ? owner.displayName + ' > ' : '') + displayName;77 var stats = aggregatedStats[key];78 if (!stats) {79 affectedIDs[key] = {};80 stats = aggregatedStats[key] = {81 key,82 instanceCount: 0,83 inclusiveRenderDuration: 0,84 renderCount: 085 };86 }87 affectedIDs[key][instanceID] = true;88 applyUpdate(stats);89 }90 var isCompositeByID = {};91}92function getWasted(flushHistory = getLastMeasurements()) {93 warnInProduction();94 return [];95 var aggregatedStats = {};96 var affectedIDs = {};97 function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {98 var { displayName, ownerID } = treeSnapshot[instanceID];99 var owner = treeSnapshot[ownerID];100 var key = (owner ? owner.displayName + ' > ' : '') + displayName;101 var stats = aggregatedStats[key];102 if (!stats) {103 affectedIDs[key] = {};104 stats = aggregatedStats[key] = {105 key,106 instanceCount: 0,107 inclusiveRenderDuration: 0,108 renderCount: 0109 };110 }111 affectedIDs[key][instanceID] = true;112 applyUpdate(stats);113 }114}115function getOperations(flushHistory = getLastMeasurements()) {116 warnInProduction();117 return [];118 var stats = [];119}120function printExclusive(flushHistory?: FlushHistory) {121 warnInProduction();122 var stats = getExclusive(flushHistory);123 var table = stats.map(item => {124 var { key, instanceCount, totalDuration } = item;125 var renderCount = item.counts.render || 0;126 var renderDuration = item.durations.render || 0;127 return {128 Component: key,129 'Total time (ms)': roundFloat(totalDuration),130 'Instance count': instanceCount,131 'Total render time (ms)': roundFloat(renderDuration),132 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,133 'Render count': renderCount,134 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)135 };136 });137}138function printInclusive(flushHistory?: FlushHistory) {139 warnInProduction();140 var stats = getInclusive(flushHistory);141 var table = stats.map(item => {142 var { key, instanceCount, inclusiveRenderDuration, renderCount } = item;143 return {144 'Owner > Component': key,145 'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),146 'Instance count': instanceCount,147 'Render count': renderCount148 };149 });150}151function printWasted(flushHistory?: FlushHistory) {152 warnInProduction();153 var stats = getWasted(flushHistory);154 var table = stats.map(item => {...
game.js
Source:game.js
...55 }56 get Width() { return this.x2 - this.x1; }57 get Height() { return this.y2 - this.y1; }58}59function getInclusive(min, max)60{61 return Math.floor( Math.random() * (max + 1 - min) ) + min;62}63function getInclusiveFloat(min, max)64{65 return ( Math.random() * (max - min) ) + min;66}67function spawnCoins(scene, coinamt=1)68{69 let rectangle = new Rectangle(100, -600, 700, 0);70 let maxcols = 6;71 let maxrows = 3;72 let bucketwidth = rectangle.Width / maxcols;73 let bucketheight = rectangle.Height / maxrows;74 let offset_x = rectangle.x1;75 let offset_y = rectangle.y1;76 let center_x = bucketwidth * 0.5;77 let center_y = bucketheight * 0.5;78 let buckets = [];79 for(let i = 0; i < maxcols * maxrows; i++) buckets.push(i);80 for(let i = 0 ; i < coinamt; i++) {81 let bucket = buckets.splice(getInclusive(0, buckets.length - 1), 1)[0];82 let y = offset_y + (Math.floor(bucket / maxcols) * bucketheight) + (center_y * 0.5) + getInclusive(0, center_y);83 let x = offset_x + ((bucket % maxcols) * bucketwidth) + (center_x * 0.5) + getInclusive(0, center_x);84 // Phaser.Math.Between(100, 700), Phaser.Math.Between(-600, 0),85 let coin = scene.matter.add.image( x, y,'coin');86 //ball.setCircle(10); overriding the default collision box87 coin.body.allowRotation = true;88 coin.body.angularDrag = 10;89 coin.setFriction(0.1);90 coin.setBounce(0.2);91 scene.matter.body.setAngularVelocity(coin.body, getInclusiveFloat(-0.3, 0.3));92 }93}94dictHasCollided = {};95function eventCollisionActive(data1, data2, data3, data4, data5, data6, data7) {96 console.log("collision active");97 let shouldPlay = false;...
shapeMeasurements.js
Source:shapeMeasurements.js
...30 const output = JSON.parse(JSON.stringify(placeToStoreValueTemporarily));31 placeToStoreValueTemporarily = null;32 return output;33}34export function getInclusive(measurements) {35 mockConsole.mock(callbacks);36 Perf.printInclusive(measurements);37 mockConsole.restore();38 const output = JSON.parse(JSON.stringify(placeToStoreValueTemporarily));39 placeToStoreValueTemporarily = null;40 return output;41}42export function getExclusive(measurements) {43 mockConsole.mock(callbacks);44 Perf.printExclusive(measurements);45 mockConsole.restore();46 const output = JSON.parse(JSON.stringify(placeToStoreValueTemporarily));47 placeToStoreValueTemporarily = null;48 return output;...
Using AI Code Generation
1const { getInclusive } = require('@playwright/test/lib/server/frames');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('#id');8 const element = await getInclusive(page, 'css=div');9 console.log(element);10 await browser.close();11})();12ElementHandle {13 _channel: ChannelOwner {14 _connection: Connection {15 _transport: WebSocketTransport {16 },17 _guidToSession: Map(1) { '1' => [Session] },18 _sessions: Map(1) { '1' => [Session] },19 _sessionsToDispose: Set(0) {},20 _browserContexts: Map(1) { '1' => [BrowserContext] },21 _pages: Map(1) { '1' => [Page] },22 _workers: Map(0) {},23 _downloads: Map(0) {},24 _consoleMessageTags: Map(0) {},25 _bindings: Map(0) {},26 _dialogs: Map(0) {},27 _fileChoosers: Map(0) {},28 _videos: Map(0) {},
Using AI Code Generation
1const { getInclusive } = require('playwright/lib/server/dom.js');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const element = await page.$('text=Get started');8 const inclusive = await getInclusive(element);9 console.log(inclusive);10 await browser.close();11})();12{13 attributes: {14 },15 {16 attributes: {17 },18 }19}20const { getBoundingBox } = require('playwright/lib/server/dom.js');21const { chromium } = require('playwright');22(async () => {23 const browser = await chromium.launch();24 const context = await browser.newContext();25 const page = await context.newPage();26 const element = await page.$('text=Get started');27 const boundingBox = await getBoundingBox(element);28 console.log(boundingBox);29 await browser.close();30})();31{32}
Using AI Code Generation
1const { getInclusive } = require('@playwright/test/lib/server/instrumentation');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 const element = await page.$('text=Learn');5 await getInclusive(element).scrollIntoViewIfNeeded();6});7import { PlaywrightTestConfig } from '@playwright/test';8const config: PlaywrightTestConfig = {9 use: {10 viewport: { width: 1280, height: 720 },11 },12 {13 use: {14 },15 },16 {17 use: {18 },19 },20 {21 use: {22 },23 },24};25export default config;
Using AI Code Generation
1const { getInclusive } = require('@playwright/test/lib/server/instrumentation');2const { Page } = require('@playwright/test/lib/server/page');3const { Frame } = require('@playwright/test/lib/server/frame');4const { getInclusive } = require('@playwright/test/lib/server/instrumentation');5const { Page } = require('@playwright/test/lib/server/page');6const { Frame } = require('@playwright/test/lib/server/frame');7const { getInclusive } = require('@playwright/test/lib/server/instrumentation');8const { Page } = require('@playwright/test/lib/server/page');9const { Frame } = require('@playwright/test/lib/server/frame');10const { getInclusive } = require('@playwright/test/lib/server/instrumentation');11const { Page } = require('@playwright/test/lib/server/page');12const { Frame } = require('@playwright/test/lib/server/frame');13const { getInclusive } = require('@playwright/test/lib/server/instrumentation');14const { Page } = require('@playwright/test/lib/server/page');15const { Frame } = require('@playwright/test/lib/server/frame');16const { getInclusive } = require('@playwright/test/lib/server/instrumentation');17const { Page } = require('@playwright/test/lib/server/page');18const { Frame } = require('@playwright/test/lib/server/frame');19const { getInclusive } = require('@playwright/test/lib/server/instrumentation');20const { Page } = require('@playwright/test/lib/server/page');21const { Frame } = require('@playwright/test/lib/server/frame');22const { getInclusive } = require('@playwright/test/lib/server/instrumentation');23const { Page } = require('@playwright/test/lib/server/page');24const { Frame } = require('@playwright/test/lib/server/frame');25const { getInclusive } = require('@playwright/test/lib/server/instrumentation
Using AI Code Generation
1const { getInclusive } = require('playwright/lib/server/injected/injectedScript');2const { getBoundingBox } = require('playwright/lib/server/injected/injectedScript');3const { getComputedStyle } = require('playwright/lib/server/injected/injectedScript');4const { getFullInnerText } = require('playwright/lib/server/injected/injectedScript');5const { getFullText } = require('playwright/lib/server/injected/injectedScript');6const { getInnerText } = require('playwright/lib/server/injected/injectedScript');7const { getText } = require('playwright/lib/server/injected/injectedScript');8const { isNodeVisible } = require('playwright/lib/server/injected/injectedScript');9const { querySelectorAll } = require('playwright/lib/server/injected/injectedScript');10const { querySelector } = require('playwright/lib/server/injected/injectedScript');11const { scrollIntoViewIfNeeded } = require('playwright/lib/server/injected/injectedScript');12const { scrollRectIntoViewIfNeeded } = require('playwright/lib/server/injected/injectedScript');13const { setFileInputFiles } = require('playwright/lib/server/injected/injectedScript');14const { setInputFiles } = require('playwright/lib/server/injected/injectedScript');15const { setInputValue } = require('playwright/lib/server/injected/injectedScript');16const { setInnerText } = require('playwright/lib/server/injected/injectedScript');17const { setTextContent } = require('playwright/lib/server/injected/injectedScript');18const { waitForDisplayedAtStablePosition } = require('playwright/lib/server/injected/injectedScript');19const { waitForFunction } = require('playwright/lib/server/injected/injectedScript');20const { waitForHidden } = require('playwright/lib/server/injected/injectedScript');21const { waitForSelectorInPage } = require('playwright/lib/server/injected/injectedScript');22const { waitForStablePosition } = require('playwright/lib/server/injected/injectedScript');23const { waitForVisible } = require('playwright/lib/server/injected/injectedScript');24const { chromium } = require('playwright');25const path = require('path');26const fs = require('fs');27(async () => {28 const browser = await chromium.launch({ headless: false });29 const context = await browser.newContext();30 const page = await context.newPage();31 await page.goto('
Using AI Code Generation
1const { getInclusive } = require('@playwright/test/lib/util');2const { expect } = require('@playwright/test');3test('get inclusive', async ({ page }) => {4 const element = await page.$('text=Learn More');5 const inclusiveElement = await getInclusive(element);6 expect(inclusiveElement).toBeTruthy();7});
Using AI Code Generation
1const { getInclusive } = require('@playwright/test/lib/server/frames');2const frame = await page.mainFrame();3const button = await getInclusive(frame, 'button', { text: 'Click me' });4await button.click();5const { getInclusive } = require('@playwright/test/lib/server/frames');6const frame = await page.mainFrame();7const button = await getInclusive(frame, 'button', { text: 'Click me' });8await button.click();9getInclusive(frame, selector[, options])10const { getInclusive } = require('@playwright/test/lib/server/frames');11const frame = await page.mainFrame();12const button = await getInclusive(frame, 'button', { text: 'Click me' });13await button.click();
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!