Best JavaScript code snippet using devicefarmer-stf
graph.js
Source:graph.js
...22 this.points.push(key); // å å
¥ç¹23 this.lines[key] = []; // é»è®¤è¾¹ä¸ºç©º24 }25 }26 addLine(start, end) {27 if (this.has(start) && this.has(end)) {28 this.lines[start].push(end);29 this.lines[end].push(start);30 }31 }32 // 广度ä¼å
éå33 breadthFirstIterator(cb) {34 if (this.points.length) {35 let done = [], // å·²éå36 ready = [this.points[0]]; // ä¸ä¸æ¥èµ·ç¹37 while (ready.length) {38 let nextReady = [];39 for (let i = 0; i < ready.length; i++) {40 let curr = ready[i];41 cb(curr);42 // readyç¹ä¾æ¬¡ç½®å
¥å·²å®æ43 done.push(curr);44 // æ¢ç´¢å½åç¹çç¸é»ç¹45 nextReady = nextReady.concat(46 // è¿æ»¤æ 以æ¢ç´¢ï¼ åå¤æ¢ç´¢ï¼ä¸æ¬¡åå¤æ¢ç´¢47 this.lines[curr].filter(48 (el) =>49 done.indexOf(el) === -1 &&50 ready.indexOf(el) === -1 &&51 nextReady.indexOf(el) === -152 )53 );54 }55 // æ´æ°åå¤æ¢ç´¢çç¹56 ready = nextReady;57 }58 }59 }60 // 广度ä¼å
ï¼ æçè·¯å¾61 breadthFirstGetShortestPath(start, end) {62 // æä¸ç¹ä¸å¹é
63 if (!this.has(start) || !this.has(end)) return null;64 // èµ·ç¹å³ç»ç¹65 if (start === end) return 0;66 let done = [start], // å·²éå67 ready = {}; // æ£å¨éå68 // è®°å½èç¹è·¯å¾69 this.lines[start].forEach((key) => (ready[key] = `${start} => ${key}`));70 while (Object.keys(ready).length) {71 let nextReady = {}; // ä¸ä¸è½®éå72 // console.log(ready);73 for (let curr of Object.keys(ready)) {74 if (curr === end) return ready[curr]; // å¹é
æåï¼ è¿å触åè·¯å¾75 done.push(curr); // å·²éå76 // è¿æ»¤è¿çº¿èç¹ä¸æªæ¢ç´¢è¿çç¹, 并åå
¥ä¸ä¸è½®éå77 this.lines[curr]78 .filter(79 (key) =>80 done.indexOf(key) === -1 && // å·²æ¢ç´¢81 !ready[key] && // æ£å¨éå82 !nextReady[key] // å·²å å
¥ä¸ä¸è½®éå83 )84 .forEach(85 (key) => (nextReady[key] = `${ready[curr]} => ${key}`) // æ´æ°è·¯å¾86 );87 }88 // æ´æ°ä¸ä¸è½®éåçç¹89 ready = nextReady;90 }91 }92 // 深度ä¼å
93 depthFirstIterator(cb) {}94 // 深度ä¼å
ï¼ æçè·¯å¾95 breadthFirstGetShortestPath(start, end) {}96}97let graph = new Graph();98// graph.addPoint("A");99// graph.addPoint("B");100// graph.addPoint("C");101// graph.addPoint("D");102// graph.addPoint("E");103// graph.addPoint("F");104// graph.addPoint("G");105// graph.addPoint("H");106// graph.addPoint("I");107// graph.addPoint("J");108// graph.addLine("A", "B");109// graph.addLine("A", "C");110// graph.addLine("B", "C");111// graph.addLine("B", "D");112// graph.addLine("B", "E");113// graph.addLine("C", "E");114// graph.addLine("C", "F");115// graph.addLine("D", "E");116// graph.addLine("D", "G");117// graph.addLine("D", "H");118// graph.addLine("E", "F");119// graph.addLine("E", "H");120// graph.addLine("E", "I");121// graph.addLine("F", "I");122// graph.addLine("F", "J");123// graph.addLine("G", "H");124// graph.addLine("H", "I");125// graph.addLine("I", "J");126// graph.print();127// console.log(graph.breadthFirstGetShortestPath("A", "I"));128// console.log(graph.minPath("A", "H"));129let graph1 = new Graph();130graph1.addPoint("A");131graph1.addPoint("B");132graph1.addPoint("C");133graph1.addPoint("D");134graph1.addPoint("E");135graph1.addPoint("F");136graph1.addPoint("G");137graph1.addPoint("H");138graph1.addPoint("I");139graph1.addPoint("J");140graph1.addPoint("K");141graph1.addPoint("L");142graph1.addPoint("M");143graph1.addPoint("N");144graph1.addPoint("O");145graph1.addPoint("P");146graph1.addPoint("Q");147graph1.addLine("A", "B");148graph1.addLine("B", "C");149graph1.addLine("B", "E");150graph1.addLine("C", "D");151graph1.addLine("D", "F");152graph1.addLine("F", "G");153graph1.addLine("G", "J");154graph1.addLine("J", "M");155graph1.addLine("M", "L");156graph1.addLine("L", "Q");157graph1.addLine("E", "I");158graph1.addLine("I", "H");159graph1.addLine("H", "K");160graph1.addLine("K", "N");161graph1.addLine("N", "O");162graph1.addLine("O", "P");163graph1.addLine("P", "Q");164// æ©å¤§å°å¾165graph1.addPoint("R");166graph1.addPoint("S");167graph1.addPoint("T");168graph1.addPoint("U");169graph1.addPoint("V");170graph1.addPoint("W");171graph1.addPoint("X");172graph1.addLine("R", "N");173graph1.addLine("R", "U");174graph1.addLine("U", "V");175graph1.addLine("V", "W");176graph1.addLine("W", "X");177graph1.addLine("S", "Q");178graph1.addLine("S", "T");179graph1.addLine("S", "X");180// graph1.print();...
CameraHelper.js
Source:CameraHelper.js
...27 var colorUp = new Color( 0x00aaff );28 var colorTarget = new Color( 0xffffff );29 var colorCross = new Color( 0x333333 );30 // near31 addLine( 'n1', 'n2', colorFrustum );32 addLine( 'n2', 'n4', colorFrustum );33 addLine( 'n4', 'n3', colorFrustum );34 addLine( 'n3', 'n1', colorFrustum );35 // far36 addLine( 'f1', 'f2', colorFrustum );37 addLine( 'f2', 'f4', colorFrustum );38 addLine( 'f4', 'f3', colorFrustum );39 addLine( 'f3', 'f1', colorFrustum );40 // sides41 addLine( 'n1', 'f1', colorFrustum );42 addLine( 'n2', 'f2', colorFrustum );43 addLine( 'n3', 'f3', colorFrustum );44 addLine( 'n4', 'f4', colorFrustum );45 // cone46 addLine( 'p', 'n1', colorCone );47 addLine( 'p', 'n2', colorCone );48 addLine( 'p', 'n3', colorCone );49 addLine( 'p', 'n4', colorCone );50 // up51 addLine( 'u1', 'u2', colorUp );52 addLine( 'u2', 'u3', colorUp );53 addLine( 'u3', 'u1', colorUp );54 // target55 addLine( 'c', 't', colorTarget );56 addLine( 'p', 'c', colorCross );57 // cross58 addLine( 'cn1', 'cn2', colorCross );59 addLine( 'cn3', 'cn4', colorCross );60 addLine( 'cf1', 'cf2', colorCross );61 addLine( 'cf3', 'cf4', colorCross );62 function addLine( a, b, color ) {63 addPoint( a, color );64 addPoint( b, color );65 }66 function addPoint( id, color ) {67 vertices.push( 0, 0, 0 );68 colors.push( color.r, color.g, color.b );69 if ( pointMap[ id ] === undefined ) {70 pointMap[ id ] = [];71 }72 pointMap[ id ].push( ( vertices.length / 3 ) - 1 );73 }74 geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );75 geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) );76 LineSegments.call( this, geometry, material );...
Using AI Code Generation
1var stf = require('devicefarmer-stf-client');2var stfDevice = new stf.Device(stfClient, 'deviceID');3stfDevice.addLine('This is a test');4var stf = require('devicefarmer-stf-client');5var stfDevice = new stf.Device(stfClient, 'deviceID');6stfDevice.addLine('This is a test');7var stf = require('devicefarmer-stf-client');8var stfDevice = new stf.Device(stfClient, 'deviceID');9stfDevice.addLine('This is a test');10var stf = require('devicefarmer-stf-client');11var stfDevice = new stf.Device(stfClient, 'deviceID');12stfDevice.addLine('This is a test');13var stf = require('devicefarmer-stf-client');14var stfDevice = new stf.Device(stfClient, 'deviceID');15stfDevice.addLine('This is a test');16var stf = require('devicefarmer-stf-client');
Using AI Code Generation
1var stf = require('devicefarmer-stf-client');2client.addLine('devicename', 'line1');3client.addLine('devicename', 'line2');4client.addLine('devicename', 'line3');5client.addLine('devicename', 'line4');6client.addLine('devicename', 'line5');7client.addLine('devicename', 'line6');8client.addLine('devicename', 'line7');9client.addLine('devicename', 'line8');10client.addLine('devicename', 'line9');11client.addLine('devicename', 'line10');12var stf = require('devicefarmer-stf-client');13client.addLine('devicename', 'line1');14client.addLine('devicename', 'line2');15client.addLine('devicename', 'line3');16client.addLine('devicename', 'line4');17client.addLine('devicename', 'line5');18client.addLine('devicename', 'line6');19client.addLine('devicename', 'line7');20client.addLine('devicename', 'line8');21client.addLine('devicename', 'line9');22client.addLine('devicename', 'line10');23client.addLine('devicename', 'line11');24client.addLine('devicename', 'line12');25client.addLine('devicename', 'line13');26client.addLine('devicename', 'line14');27client.addLine('devicename', 'line15');28client.addLine('devicename', 'line16');29client.addLine('devicename', 'line17');30client.addLine('devicename', 'line18');31client.addLine('devicename', 'line19');32client.addLine('devicename', 'line20');33client.addLine('devicename', 'line21');34client.addLine('devicename', 'line22');35client.addLine('devicename', 'line23');36client.addLine('devicename', 'line24');37client.addLine('devicename', 'line25');
Using AI Code Generation
1var stf = require('devicefarmer-stf');2stf.addLine('deviceID','text');3var stf = require('devicefarmer-stf');4stf.addLine('deviceID','text');5var stf = require('devicefarmer-stf');6stf.addLine('deviceID','text');7var stf = require('devicefarmer-stf');8stf.addLine('deviceID','text');9var stf = require('devicefarmer-stf');10stf.addLine('deviceID','text');11var stf = require('devicefarmer-stf');12stf.addLine('deviceID','text');13var stf = require('devicefarmer-stf');14stf.addLine('deviceID','text');15var stf = require('devicefarmer-stf');16stf.addLine('deviceID','text');17var stf = require('devicefarmer-stf');18stf.addLine('device
Using AI Code Generation
1var client = require('devicefarmer-stf-client');2device.addLine('Hello World');3connect(url)4addLine(line)5clearScreen()6disconnect()7onconnect()8ondisconnect()9onerror(error)10online(line)11onready()12onunready()13onupdate(data)
Using AI Code Generation
1var stf = require('devicefarmer-stf-client');2var client = new stf.Client();3 return client.addLine('a3a7c2f0', '1234567890');4}).then(function() {5 console.log('Line added successfully');6}).catch(function(err) {7 console.error(err);8});9var stf = require('devicefarmer-stf-client');10var client = new stf.Client();11 return client.removeLine('a3a7c2f0', '1234567890');12}).then(function() {13 console.log('Line removed successfully');14}).catch(function(err) {15 console.error(err);16});17var stf = require('devicefarmer-stf-client');18var client = new stf.Client();19 return client.clearLines('a3a7c2f0');20}).then(function() {21 console.log('Lines cleared successfully');22}).catch(function(err) {23 console.error(err);24});25var stf = require('devicefarmer-stf-client');26var client = new stf.Client();27 return client.call('a3a7c2f0', '1234567890');28}).then(function() {29 console.log('Call successfully');30}).catch(function(err) {31 console.error(err);32});33var stf = require('devicefarmer-stf-client');34var client = new stf.Client();35 return client.call('a3a7c2f0', '1234567890');36}).then(function() {37 console.log('Call successfully');38}).catch(function(err) {39 console.error(err);40});
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!!