Best JavaScript code snippet using devicefarmer-stf
shape.js
Source:shape.js
...25 angle: angle26 };27 this.vertices.push(vertex);28 }29 this.updateBounds();30 }31 updateBounds() {32 let x = [];33 let y = [];34 for (var i = 0; i < this.vertices.length; i++) {35 let vertex = this.vertices[i];36 x.push(vertex.x);37 y.push(vertex.y);38 }39 this.bounds = {40 min: {41 x: Math.min(...x),42 y: Math.min(...y)43 },44 max: {45 x: Math.max(...x),46 y: Math.max(...y)47 }48 }49 }50 setRadius(radius) {51 if (radius == this.radius) return;52 this.radius = radius;53 for (var i = 0; i < this.vertices.length; i++) {54 let vertex = this.vertices[i];55 vertex.x = this.position.x + Math.cos(vertex.angle + this.angle) * this.radius;56 vertex.y = this.position.y + Math.sin(vertex.angle + this.angle) * this.radius;57 }58 this.updateBounds();59 }60 scale(x, y) {61 if (x == this.size.x && y == this.size.y) return;62 let sizeDelta = {63 x: x - this.size.x,64 y: y - this.size.y65 }66 this.size.x = x;67 this.size.y = y;68 for (var i = 0; i < this.vertices.length; i++) {69 let vertex = this.vertices[i];70 let vertexDelta = {71 x: vertex.x - this.position.x,72 y: vertex.y - this.position.y73 };74 vertex.x = this.position.x + vertexDelta.x * (1 + sizeDelta.x);75 vertex.y = this.position.y + vertexDelta.y * (1 + sizeDelta.y);76 }77 this.updateBounds();78 }79 translate(x, y) {80 if (x == this.position.x && y == this.position.y) return;81 let delta = {82 x: x - this.position.x,83 y: y - this.position.y84 };85 this.position.x = x;86 this.position.y = y;87 for (var i = 0; i < this.vertices.length; i++) {88 let vertex = this.vertices[i];89 vertex.x += delta.x;90 vertex.y += delta.y;91 }92 this.updateBounds();93 }94 rotate(angle) {95 if (angle == this.angle) return;96 let delta = angle - this.angle;97 this.angle = angle;98 for (var i = 0; i < this.vertices.length; i++) {99 let vertex = this.vertices[i];100 let x = (vertex.x - this.position.x) * Math.cos(delta) - (vertex.y - this.position.y) * Math.sin(delta);101 let y = (vertex.x - this.position.x) * Math.sin(delta) + (vertex.y - this.position.y) * Math.cos(delta);102 vertex.x = this.position.x + x;103 vertex.y = this.position.y + y;104 }105 this.updateBounds();106 }107}108class Rectangle {109 constructor(x, y, width, height) {110 this.position = {111 x: x,112 y: y113 };114 this.size = {115 x: 1,116 y: 1117 };118 this.bounds = {};119 this.angle = 0;120 this.vertices = [];121 this.updateVertices(width, height);122 }123 updateVertices(width, height) {124 this.vertices = [{125 x: this.position.x - width * 0.5,126 y: this.position.y - height * 0.5127 }, {128 x: this.position.x + width * 0.5,129 y: this.position.y - height * 0.5130 }, {131 x: this.position.x + width * 0.5,132 y: this.position.y + height * 0.5133 }, {134 x: this.position.x - width * 0.5,135 y: this.position.y + height * 0.5136 }];137 this.updateBounds();138 }139 updateBounds() {140 let x = [];141 let y = [];142 for (var i = 0; i < this.vertices.length; i++) {143 let vertex = this.vertices[i];144 x.push(vertex.x);145 y.push(vertex.y);146 }147 this.bounds = {148 min: {149 x: Math.min(...x),150 y: Math.min(...y)151 },152 max: {153 x: Math.max(...x),154 y: Math.max(...y)155 }156 }157 }158 scale(x, y) {159 if (x == this.size.x && y == this.size.y) return;160 let sizeDelta = {161 x: x - this.size.x,162 y: y - this.size.y163 }164 this.size.x = x;165 this.size.y = y;166 for (var i = 0; i < this.vertices.length; i++) {167 let vertex = this.vertices[i];168 let vertexDelta = {169 x: vertex.x - this.position.x,170 y: vertex.y - this.position.y171 };172 vertex.x = this.position.x + vertexDelta.x * (1 + sizeDelta.x);173 vertex.y = this.position.y + vertexDelta.y * (1 + sizeDelta.y);174 }175 this.updateBounds();176 }177 translate(x, y) {178 if (x == this.position.x && y == this.position.y) return;179 let delta = {180 x: x - this.position.x,181 y: y - this.position.y182 };183 this.position.x = x;184 this.position.y = y;185 for (var i = 0; i < this.vertices.length; i++) {186 let vertex = this.vertices[i];187 vertex.x += delta.x;188 vertex.y += delta.y;189 }190 this.updateBounds();191 }192 rotate(angle) {193 if (angle == this.angle) return;194 let delta = angle - this.angle;195 this.angle = angle;196 for (var i = 0; i < this.vertices.length; i++) {197 let vertex = this.vertices[i];198 let x = (vertex.x - this.position.x) * Math.cos(delta) - (vertex.y - this.position.y) * Math.sin(delta);199 let y = (vertex.x - this.position.x) * Math.sin(delta) + (vertex.y - this.position.y) * Math.cos(delta);200 vertex.x = this.position.x + x;201 vertex.y = this.position.y + y;202 }203 this.updateBounds();204 }205}206class Polygon {207 constructor(x, y, radius, sides) {208 this.position = {209 x: x,210 y: y211 };212 this.size = {213 x: 1,214 y: 1215 };216 this.bounds = {};217 this.radius = radius;218 this.angle = 0;219 this.vertices = [];220 this.sides = sides;221 this.updateVertices();222 }223 updateVertices(sides) {224 this.sides = sides ? sides : this.sides;225 this.vertices = [];226 for (var angle = -Math.PI; angle < Math.PI; angle += (Math.PI * 2) / this.sides) {227 let vertex = {228 x: this.position.x + Math.cos(angle) * this.radius,229 y: this.position.y + Math.sin(angle) * this.radius,230 angle: angle231 };232 this.vertices.push(vertex);233 }234 this.updateBounds();235 }236 updateBounds() {237 let x = [];238 let y = [];239 for (var i = 0; i < this.vertices.length; i++) {240 let vertex = this.vertices[i];241 x.push(vertex.x);242 y.push(vertex.y);243 }244 this.bounds = {245 min: {246 x: Math.min(...x),247 y: Math.min(...y)248 },249 max: {250 x: Math.max(...x),251 y: Math.max(...y)252 }253 }254 }255 setRadius(radius) {256 if (radius == this.radius) return;257 this.radius = radius;258 for (var i = 0; i < this.vertices.length; i++) {259 let vertex = this.vertices[i];260 vertex.x = this.position.x + Math.cos(vertex.angle + this.angle) * this.radius;261 vertex.y = this.position.y + Math.sin(vertex.angle + this.angle) * this.radius;262 }263 this.updateBounds();264 }265 scale(x, y) {266 if (x == this.size.x && y == this.size.y) return;267 let sizeDelta = {268 x: x - this.size.x,269 y: y - this.size.y270 }271 this.size.x = x;272 this.size.y = y;273 for (var i = 0; i < this.vertices.length; i++) {274 let vertex = this.vertices[i];275 let vertexDelta = {276 x: vertex.x - this.position.x,277 y: vertex.y - this.position.y278 };279 vertex.x = this.position.x + vertexDelta.x * (1 + sizeDelta.x);280 vertex.y = this.position.y + vertexDelta.y * (1 + sizeDelta.y);281 }282 this.updateBounds();283 }284 translate(x, y) {285 if (x == this.position.x && y == this.position.y) return;286 let delta = {287 x: x - this.position.x,288 y: y - this.position.y289 };290 this.position.x = x;291 this.position.y = y;292 for (var i = 0; i < this.vertices.length; i++) {293 let vertex = this.vertices[i];294 vertex.x += delta.x;295 vertex.y += delta.y;296 }297 this.updateBounds();298 }299 rotate(angle) {300 if (angle == this.angle) return;301 let delta = angle - this.angle;302 this.angle = angle;303 for (var i = 0; i < this.vertices.length; i++) {304 let vertex = this.vertices[i];305 let x = (vertex.x - this.position.x) * Math.cos(delta) - (vertex.y - this.position.y) * Math.sin(delta);306 let y = (vertex.x - this.position.x) * Math.sin(delta) + (vertex.y - this.position.y) * Math.cos(delta);307 vertex.x = this.position.x + x;308 vertex.y = this.position.y + y;309 }310 this.updateBounds();311 }312}313module.exports = {314 circle: function(x, y, radius) {315 x = x || 0;316 y = y || 0;317 radius = radius || 0;318 return new Circle(x, y, radius)319 },320 rect: function(x, y, width, height) {321 x = x || 0;322 y = y || 0;323 width = width || 0;324 height = height || 0;...
AbstractRealMaskPoint.js
Source:AbstractRealMaskPoint.js
1(function(){var P$=Clazz.newPackage("net.imglib2.roi.util"),I$=[];2/*c*/var C$=Clazz.newClass(P$, "AbstractRealMaskPoint", null, 'net.imglib2.RealPoint', 'net.imglib2.roi.util.RealLocalizableRealPositionable');3C$.$clinit$=2;4Clazz.newMeth(C$, '$init$', function () {5}, 1);6Clazz.newMeth(C$, 'c$$I', function (n) {7;C$.superclazz.c$$I.apply(this,[n]);C$.$init$.apply(this);8}, 1);9Clazz.newMeth(C$, 'c$$DA', function (pos) {10;C$.superclazz.c$$DA$Z.apply(this,[pos, false]);C$.$init$.apply(this);11}, 1);12Clazz.newMeth(C$, 'c$$net_imglib2_RealLocalizable', function (pos) {13;C$.superclazz.c$$net_imglib2_RealLocalizable.apply(this,[pos]);C$.$init$.apply(this);14}, 1);15Clazz.newMeth(C$, 'move$F$I', function (distance, d) {16C$.superclazz.prototype.move$F$I.apply(this, [distance, d]);17this.updateBounds$();18});19Clazz.newMeth(C$, 'move$D$I', function (distance, d) {20C$.superclazz.prototype.move$D$I.apply(this, [distance, d]);21this.updateBounds$();22});23Clazz.newMeth(C$, 'move$net_imglib2_RealLocalizable', function (distance) {24C$.superclazz.prototype.move$net_imglib2_RealLocalizable.apply(this, [distance]);25this.updateBounds$();26});27Clazz.newMeth(C$, 'move$FA', function (distance) {28C$.superclazz.prototype.move$FA.apply(this, [distance]);29this.updateBounds$();30});31Clazz.newMeth(C$, 'move$DA', function (distance) {32C$.superclazz.prototype.move$DA.apply(this, [distance]);33this.updateBounds$();34});35Clazz.newMeth(C$, 'setPosition$net_imglib2_RealLocalizable', function (position) {36C$.superclazz.prototype.setPosition$net_imglib2_RealLocalizable.apply(this, [position]);37this.updateBounds$();38});39Clazz.newMeth(C$, 'setPosition$FA', function (position) {40C$.superclazz.prototype.setPosition$FA.apply(this, [position]);41this.updateBounds$();42});43Clazz.newMeth(C$, 'setPosition$DA', function (position) {44C$.superclazz.prototype.setPosition$DA.apply(this, [position]);45this.updateBounds$();46});47Clazz.newMeth(C$, 'setPosition$F$I', function (position, d) {48C$.superclazz.prototype.setPosition$F$I.apply(this, [position, d]);49this.updateBounds$();50});51Clazz.newMeth(C$, 'setPosition$D$I', function (position, d) {52C$.superclazz.prototype.setPosition$D$I.apply(this, [position, d]);53this.updateBounds$();54});55Clazz.newMeth(C$, 'fwd$I', function (d) {56C$.superclazz.prototype.fwd$I.apply(this, [d]);57this.updateBounds$();58});59Clazz.newMeth(C$, 'bck$I', function (d) {60C$.superclazz.prototype.bck$I.apply(this, [d]);61this.updateBounds$();62});63Clazz.newMeth(C$, 'move$I$I', function (distance, d) {64C$.superclazz.prototype.move$I$I.apply(this, [distance, d]);65this.updateBounds$();66});67Clazz.newMeth(C$, 'move$J$I', function (distance, d) {68C$.superclazz.prototype.move$J$I.apply(this, [distance, d]);69this.updateBounds$();70});71Clazz.newMeth(C$, 'move$net_imglib2_Localizable', function (localizable) {72C$.superclazz.prototype.move$net_imglib2_Localizable.apply(this, [localizable]);73this.updateBounds$();74});75Clazz.newMeth(C$, 'move$IA', function (distance) {76C$.superclazz.prototype.move$IA.apply(this, [distance]);77this.updateBounds$();78});79Clazz.newMeth(C$, 'move$JA', function (distance) {80C$.superclazz.prototype.move$JA.apply(this, [distance]);81this.updateBounds$();82});83Clazz.newMeth(C$, 'setPosition$net_imglib2_Localizable', function (localizable) {84C$.superclazz.prototype.setPosition$net_imglib2_Localizable.apply(this, [localizable]);85this.updateBounds$();86});87Clazz.newMeth(C$, 'setPosition$IA', function (position) {88C$.superclazz.prototype.setPosition$IA.apply(this, [position]);89this.updateBounds$();90});91Clazz.newMeth(C$, 'setPosition$JA', function (position) {92C$.superclazz.prototype.setPosition$JA.apply(this, [position]);93this.updateBounds$();94});95Clazz.newMeth(C$, 'setPosition$I$I', function (position, d) {96C$.superclazz.prototype.setPosition$I$I.apply(this, [position, d]);97this.updateBounds$();98});99Clazz.newMeth(C$, 'setPosition$J$I', function (position, d) {100C$.superclazz.prototype.setPosition$J$I.apply(this, [position, d]);101this.updateBounds$();102});103Clazz.newMeth(C$);104})();...
useResizeObserver.ts
Source:useResizeObserver.ts
...22 maxY: rect.top + rect.height,23 width: rect.width,24 height: rect.height,25 }26 app.viewport.updateBounds(bounds)27 onBoundsChange?.(bounds)28 }29 } else {30 // Skip the first mount31 rIsMounted.current = true32 }33 }, [app, ref, onBoundsChange])34 React.useEffect(() => {35 window.addEventListener('scroll', updateBounds)36 window.addEventListener('resize', updateBounds)37 return () => {38 window.removeEventListener('scroll', updateBounds)39 window.removeEventListener('resize', updateBounds)40 }41 }, [])42 React.useLayoutEffect(() => {43 const resizeObserver = new ResizeObserver((entries) => {44 if (entries[0].contentRect) {45 updateBounds()46 }47 })48 if (ref.current) {49 resizeObserver.observe(ref.current)50 }51 return () => {52 resizeObserver.disconnect()53 }54 }, [ref])55 React.useLayoutEffect(() => {56 updateBounds()57 }, [ref])...
Using AI Code Generation
1var stf = require('devicefarmer-stf-client');2var options = {3};4var client = stf.createClient(options);5device.updateBounds(0, 0, 320, 480);6{7 "dependencies": {8 }9}10var stf = require('devicefarmer-stf-client');11var options = {12};13var client = stf.createClient(options);14device.updateBounds(0, 0, 320, 480);15{16 "dependencies": {17 }18}19var stf = require('devicefarmer-stf-client');20var options = {21};22var client = stf.createClient(options);23device.updateBounds(0, 0, 320, 480);24{25 "dependencies": {26 }27}28var stf = require('devicefar
Using AI Code Generation
1var stf = require('devicefarmer-stf-client');2var util = require('util');3var path = require('path');4var fs = require('fs');5var os = require('os');6var adb = require('adbkit');7var Promise = require('bluebird');8var client = adb.createClient();9var device = new stf.Device(client, 'R9K7N14CZ4J');10var bounds = {11};12device.updateBounds(bounds).then(function() {13 console.log('bounds updated');14}).catch(function(err) {15 console.error('Something went wrong:', err.stack);16});17Starting: Intent { cmp=com.android.settings/.Settings }18 at ChildProcess.exithandler (child_process.js:204:12)19 at emitTwo (events.js:92:20)20 at ChildProcess.emit (events.js:172:7)21 at maybeClose (internal/child_process.js:818:16)22 at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)23var stf = require('devicefarmer-stf-client');24var util = require('util');25var path = require('path');26var fs = require('fs');27var os = require('os');28var adb = require('adbkit');29var Promise = require('bluebird');30var client = adb.createClient();31var device = new stf.Device(client, 'R9K7N14CZ4J');32device.connect().then(function() {33 console.log('connected');34}).catch(function(err) {35 console.error('Something went wrong:', err.stack);36});
Using AI Code Generation
1var DeviceFarmClient = require('devicefarmer-stf-client');2client.updateBounds('test', 0, 0, 100, 100);3var DeviceFarmClient = require('devicefarmer-stf-client');4client.updateRotation('test', 90);5var DeviceFarmClient = require('devicefarmer-stf-client');6client.updateGeoLocation('test', 37.7749295, -122.4194155);7var DeviceFarmClient = require('devicefarmer-stf-client');8client.updateNetworkSpeed('test', 100);9var DeviceFarmClient = require('devicefarmer-stf-client');10client.updateNetworkLatency('test', 100);11var DeviceFarmClient = require('devicefarmer-stf-client');12client.updateNetworkState('test', 'wifi');13var DeviceFarmClient = require('devicefarmer-stf-client');14client.updateBattery('test', 100);15var DeviceFarmClient = require('devicefarmer-stf-client');16client.updateAirplaneMode('test', true);
Using AI Code Generation
1var updateBounds = require('../lib/adb').updateBounds2var device = {3}4var bounds = {5}6updateBounds(device, bounds, function(err, data) {7 console.log('err', err)8 console.log('data', data)9})
Using AI Code Generation
1var deviceFarmer = require('devicefarmer-stf');2stf.updateBounds('0c2a2b8e', 0, 0, 500, 500, function(err, data){3 if(err){4 console.log('error: ', err);5 }else{6 console.log('data: ', data);7 }8});9var deviceFarmer = require('devicefarmer-stf');10stf.updateRotation('0c2a2b8e', 90, function(err, data){11 if(err){12 console.log('error: ', err);13 }else{14 console.log('data: ', data);15 }16});17var deviceFarmer = require('devicefarmer-stf');18stf.updateNetworkSpeed('0c2a2b8e', 'gsm', function(err, data){19 if(err){20 console.log('error: ', err);21 }else{22 console.log('data: ', data);23 }24});25var deviceFarmer = require('devicefarmer-stf');26stf.updateBattery('0c2a2b8e', 50, function(err, data){27 if(err){28 console.log('error: ', err);29 }else{30 console.log('data: ', data);31 }32});33var deviceFarmer = require('devicefarmer-stf');
Using AI Code Generation
1var stf = require('devicefarmer-stf-client');2var device = new stf.Device(client, "6a8b6a25");3device.updateBounds({x: 0, y: 0, width: 100, height: 100}, function(err){4 if(err) throw err;5 console.log("bounds updated");6});7at Device.updateBounds (C:\Users\abc\Desktop\stf8at tryCatcher (C:\Users\abc\Desktop\stf9at Promise._settlePromiseFromHandler (C:\Users\abc\Desktop\stf10at Promise._settlePromise (C:\Users\abc\Desktop\stf11at Promise._settlePromiseCtx (C:\Users\abc\Desktop\stf12at Async._drainQueue (C:\Users\abc\Desktop\stf13at Async._drainQueues (C:\Users\abc\Desktop\stf14at Immediate.Async.drainQueues (C:\Users\abc\Desktop\stf15at runCallback (timers.js:672:20)16at tryOnImmediate (timers.js:645:5)17at processImmediate [as _immediateCallback] (timers.js:617:5)
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!!