How to use existenceMap method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

index.js

Source:index.js Github

copy

Full Screen

1function isInteger(n) {2 return typeof n === 'number' && (n | 0) === n;3}4function isPositiveInteger(n) {5 return isInteger(n) && n > 0;6}7function isNonNegativeInteger(n) {8 return isInteger(n) && n >= 0;9}10function reduceToSum(a, b) {11 return a + b;12}13function toNumber(a) {14 return +a;15}16function fillSequentialArray(n) {17 if (!isNonNegativeInteger(n)) {18 throw Error(`Invalid argument: n must be a non-negative integer, ${n} was provided.`);19 }20 return [...Array(n)].map((_, i) => i);21}22function generateRandomIntegerBetween(n, m) {23 if (!isNonNegativeInteger(n)) {24 throw Error(`Invalid argument: n must be a non-negative integer, ${n} was provided.`);25 }26 if (!isNonNegativeInteger(m)) {27 throw Error(`Invalid argument: m must be a non-negative integer, ${m} was provided.`);28 }29 if (n === m) {30 throw Error(`Invalid argument: n and m cannot be equal, ${n} and ${m} were provided.`);31 }32 return Math.floor(Math.random() * m) + n;33}34function generateRandomPermutation(n) {35 if (!isNonNegativeInteger(n)) {36 throw Error(`Invalid argument: n must be a non-negative integer, ${n} was provided.`);37 }38 const numbers = fillSequentialArray(n);39 const permutation = [];40 for (let i = numbers.length - 1; i >= 0; --i) {41 const randomNumber = generateRandomIntegerBetween(0, n);42 permutation.push(numbers[randomNumber]);43 numbers.splice(randomNumber, 1);44 }45 return permutation;46}47const generateNextPermutationInvalidArgumentPreText = 'Invalid argument: permutation must be an array of non-negative, non gapping, sequential integers beginning from 0,';48const cachedPermutations = {};49function verifyPermutation(permutation) {50 if (!Array.isArray(permutation)) {51 throw Error(`${generateNextPermutationInvalidArgumentPreText} value of type: ${typeof permutation} was provided.`);52 }53 const existenceMap = {};54 for (let i = 0; i < permutation.length; ++i) {55 if (!isNonNegativeInteger(permutation[i])) {56 throw Error(`${generateNextPermutationInvalidArgumentPreText} index at ${i} has value ${permutation[i]}.`);57 }58 if (existenceMap[permutation[i]] === undefined) {59 existenceMap[permutation[i]] = i;60 } else {61 throw Error(`${generateNextPermutationInvalidArgumentPreText} duplicate value of ${permutation[i]} found at indices ${existenceMap[permutation[i]]} and ${i}.`);62 }63 }64 for (let i = 0; i < permutation.length; ++i) {65 if (existenceMap[i] === undefined) {66 throw Error(`${generateNextPermutationInvalidArgumentPreText} missing value: ${i}.`);67 }68 }69}70function generateNextPermutation(permutation, skipVerification = false) {71 if (!skipVerification) {72 verifyPermutation(permutation);73 }74 75 const base = permutation.length - 1;76 if (base === -1 || base === 0) {77 return undefined;78 }79 if (permutation[base] === base) {80 return permutation.slice(0, base - 1).concat([permutation[base], permutation[base - 1]]);81 }82 for (let i = base; i > 0; --i) {83 const currentDigit = permutation[i];84 const nextDigit = permutation[i - 1];85 if (currentDigit < nextDigit) {86 continue;87 }88 89 const precedingDigits = permutation.slice(0, i - 1);90 let newDigit = nextDigit + 1;91 while (precedingDigits.indexOf(newDigit) > -1) {92 ++newDigit;93 };94 let followingDigit = 0;95 const digitMap = {};96 const nextPermutation = precedingDigits.concat([newDigit]);97 nextPermutation.forEach((d) => digitMap[d] = true);98 while (followingDigit <= base) {99 if (!digitMap[followingDigit]) {100 digitMap[followingDigit] = true;101 nextPermutation.push(followingDigit);102 }103 ++followingDigit;104 }105 return nextPermutation;106 }107 return undefined;108}109function generatePermutations(n) {110 if (!isNonNegativeInteger(n)) {111 throw Error(`Invalid argument: n must be a non-negative integer, ${n} was provided.`);112 }113 const startingPermutation = fillSequentialArray(n);114 const permutations = [startingPermutation];115 let nextPermutation = generateNextPermutation(startingPermutation, true);116 while (nextPermutation) {117 permutations.push(nextPermutation);118 nextPermutation = generateNextPermutation(nextPermutation, true);119 }120 return permutations;121}122function generatePermutationsUpTo(n) {123 if (!isNonNegativeInteger(n)) {124 throw Error(`Invalid argument: n must be a non-negative integer, ${n} was provided.`);125 }126 const permutations = [];127 for (let i = 0; i < n; ++i) {128 permutations.push(generatePermutations(i));129 }130 return permutations;131}132const applyPermutationInvalidArgumentPreText = 'Invalid argument: alphabet must be an array of uniquely serializeable values,';133function verifyAlphabet(alphabet, allowDuplicates = false) {134 if (!Array.isArray(alphabet)) {135 throw Error(`${refactorIntegerInvalidArgumentPreText} alue of type: ${typeof alphabet} was provided.`);136 }137 const existenceMap = {};138 alphabet.forEach((letter, i) => {139 try {140 const serializedLetter = JSON.stringify(letter);141 if (!allowDuplicates && typeof existenceMap[serializedLetter] === 'number') {142 throw Error(`${refactorIntegerInvalidArgumentPreText} duplicate value of ${letter} serialized to ${serializedLetter} found at indices ${existenceMap[serializedLetter]} and ${i}.`);143 } else {144 existenceMap[serializedLetter] = i;145 }146 } catch {147 throw Error(`${refactorIntegerInvalidArgumentPreText} value at index ${i} can not be serialized.`);148 }149 });150}151function applyPermutationToAlphabet(permutation, alphabet, allowDuplicates = false, skipVerification = false) {152 if (!skipVerification) {153 verifyPermutation(permutation);154 verifyAlphabet(alphabet, allowDuplicates);155 }156 157 return permutation.map((p) => alphabet[p]);158}159function factorInteger(n, includeOne = false) {160 if (typeof n !== 'number' || (n | 0) !== n || n < 1) {161 throw Error(`Invalid argument: n must be a positive integer, ${n} was provided.`);162 }163 const upperBound = Math.ceil(Math.sqrt(n));164 const factors = [];165 let remainder = n;166 if (includeOne) {167 factors.push(1);168 }169 for (let i = 2; i < upperBound; ++i) {170 while (remainder > 0 && (remainder % i === 0)) {171 remainder /= i;172 factors.push(i);173 }174 }175 if (remainder > 0) {176 factors.push(remainder);177 }178 if (179 (factors.length === 0 && !includeOne) ||180 (factors.length === 1 && includeOne)181 ) {182 factors.push(n);183 }184 return factors;185}186const refactorIntegerInvalidArgumentPreText = 'Invalid argument: factors must be an array of positive integers,';187function verifyIntegerFactors(n, factors) {188 if (!Array.isArray(factors)) {189 throw Error(`${refactorIntegerInvalidArgumentPreText} value of type: ${typeof factors} was provided.`);190 }191 let product = 1;192 for(let i = 0; i < factors.length; ++i) {193 const factor = factors[i];194 if (!isPositiveInteger(factor)) {195 throw Error(`${refactorIntegerInvalidArgumentPreText} value of ${factor} at index ${i} with type ${typeof factor} was provided.`);196 }197 product *= factor;198 }199 if (product !== n) {200 throw Error(`${refactorIntegerInvalidArgumentPreText} factors provided [${factors.join(',')}] do not multiply to produce ${n}.`);201 }202 return factors;203}204function generateUniqueIntegerDigitPermutations(n) {205 if (!isPositiveInteger(n)) {206 throw Error(`Invalid argument: n must be a positive integer, ${n} was provided.`);207 }208 const digits = String(n).split('').map(toNumber);209 if (!cachedPermutations[digits.length]) {210 cachedPermutations[digits.length] = generatePermutations(digits.length);211 }212 const uniqueDigitPermutations = {};213 const digitPermutations = cachedPermutations[digits.length].map((p) => applyPermutationToAlphabet(p, digits, true, true));214 for (let i = 0; i < digitPermutations.length; ++i) {215 const integer = +digitPermutations[i].join('');216 if (uniqueDigitPermutations[integer]) {217 continue;218 }219 uniqueDigitPermutations[integer] = true;220 }221 return Object.keys(uniqueDigitPermutations).map(toNumber);222}223function updateAbacusBeadPosition(abacus, beadPosition) {224 for (let i = 0; i < beadPosition.length; ++i) {225 if (beadPosition[i] + 1 < abacus[i].length) {226 ++beadPosition[i];227 return;228 } else if (beadPosition[i] + 1 === abacus[i].length) {229 beadPosition[i] = 0;230 }231 }232}233function refactorInteger(n, factors = undefined, skipVerification = false) {234 if (!isPositiveInteger(n)) {235 throw Error(`Invalid argument: n must be a positive integer, ${n} was provided.`);236 }237 if (!skipVerification) {238 verifyIntegerFactors(n, factors);239 }240 const integerFactors = !Array.isArray(factors) ? factorInteger(n) : factors;241 if (n < 10 || integerFactors.length === 1) {242 return [n];243 }244 const refactors = {};245 const factorPermutations = {};246 for (let i = 0; i < integerFactors.length; ++i) {247 if (factorPermutations[integerFactors[i]]) {248 continue;249 }250 251 factorPermutations[integerFactors[i]] = integerFactors[i] < 10252 ? [integerFactors[i]]253 : generateUniqueIntegerDigitPermutations(integerFactors[i]);254 }255 const abacus = Object.values(factorPermutations);256 const beadPosition = abacus.map(() => 0);257 let refactor = 1;258 do {259 refactor = 1;260 for (let i = 0; i < beadPosition.length; ++i) {261 refactor *= abacus[i][beadPosition[i]];262 }263 updateAbacusBeadPosition(abacus, beadPosition);264 refactors[refactor] = true;265 } while (beadPosition.reduce(reduceToSum, 0) > 0);266 return Object.keys(refactors).map(toNumber);267}268function aggregateInteger(n) {269 if (!isNonNegativeInteger(n)) {270 throw Error(`Invalid argument: n must be a non-negative integer, ${n} was provided.`);271 }272 let aggregate = n;273 while (aggregate >= 10) {274 aggregate = String(aggregate).split('').map(toNumber).reduce(reduceToSum, 0);275 }276 return aggregate;277}278function verifyRefactorAggregates(refactorAggregates, aggregate, refactors, n) {279 refactorAggregates.forEach((r, i) => {280 if (r !== aggregate) {281 throw Error(`Refactored integer aggregate of ${r} for refactor ${refactors[i]} does not equal provided integer aggregate of ${aggregate} for ${n}`);282 }283 });284}285function aggregateIntegerRefactors(n, skipVerification = false) {286 if (!isPositiveInteger(n)) {287 throw Error(`Invalid argument: n must be a positive integer, ${n} was provided.`);288 }289 const aggregate = aggregateInteger(n);290 const refactors = refactorInteger(n, factorInteger(n), true);291 const refactorAggregates = refactors.map((r) => aggregateInteger(r));292 if (!skipVerification) {293 verifyRefactorAggregates(refactorAggregates, aggregate, refactors, n);294 }295 296 return {297 integer: n,298 refactors,299 aggregate,300 refactorAggregates301 };302}303function aggregateRandomIntegerRefactors(n, m, skipVerification = false) {304 return aggregateIntegerRefactors(generateRandomIntegerBetween(n, m), skipVerification);...

Full Screen

Full Screen

project-upgrades.ts

Source:project-upgrades.ts Github

copy

Full Screen

1/*2 * This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.3 * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details4 */5/*6Functions for determining various things about applying upgrades to a project.7WARNING: This should stay as simple typescript with no crazy dependencies for easy node.js unit testing.8*/9import * as misc from "smc-util/misc";10import { ProjectMap } from "../projects/store";11interface ExistenceMap {12 [keys: string]: boolean;13}14export function available_upgrades(opts: {15 account_id: string; // id of a user16 purchased_upgrades: object; // map of the total upgrades purchased by account_id17 project_map: ProjectMap; // immutable.js map of data about projects18 student_project_ids: ExistenceMap; // map project_id:true with keys *all* student19 // projects in course, including deleted20}) {21 /*22 Return the total upgrades that the user with given account_id has to apply23 toward this course. This is all upgrades they have purchased minus24 upgrades they have applied to projects that aren't student projects in25 this course. Thus this is what they have available to distribute to26 their students in this course.27 This is a map {quota0:x, quota1:y, ...}28 */29 let available = misc.copy(opts.purchased_upgrades);30 opts.project_map.forEach(function (project, project_id) {31 if (opts.student_project_ids[project_id]) {32 // do not count projects in course33 return;34 }35 const upgrades = project.getIn(["users", opts.account_id, "upgrades"]);36 if (upgrades != null) {37 available = misc.map_diff(available, upgrades.toJS());38 }39 });40 return available;41}42export function current_student_project_upgrades(opts: {43 account_id: string; // id of a user44 project_map: ProjectMap; // immutable.js map of data about projects45 student_project_ids: ExistenceMap; // map project_id:true with keys *all* student46}) {47 /*48 Return the total upgrades currently applied to each student project from49 everybody else except the user with given account_id.50 This output is a map {project_id:{quota0:x, quota1:y, ...}, ...}; only projects with51 actual upgrades are included.52 */53 const other = {};54 for (const project_id in opts.student_project_ids) {55 const users = opts.project_map.getIn([project_id, "users"]);56 if (users == null) {57 continue;58 }59 var x = undefined;60 users.forEach(function (info, user_id) {61 if (user_id === opts.account_id) {62 return;63 }64 const upgrades = info.get("upgrades");65 if (upgrades == null) {66 return;67 }68 x = misc.map_sum(upgrades.toJS(), x != null ? x : {});69 });70 if (x != null) {71 other[project_id] = x;72 }73 }74 return other;75}76export function upgrade_plan(opts: {77 account_id: string; // id of a user78 purchased_upgrades: object; // map of the total upgrades purchased by account_id79 project_map: ProjectMap; // immutable.js map of data about projects80 student_project_ids: ExistenceMap; // map project_id:true with keys *all* student81 // projects in course, including deleted82 deleted_project_ids: ExistenceMap; // map project_id:true just for projects where83 // student is considered deleted from class84 upgrade_goal: object; // [quota0:x, quota1:y]85}) {86 /*87 Determine what upgrades should be applied by this user to get88 the student projects to the given upgrade goal. Preference89 is by project_id in order (arbitrary, but stable).90 The output is a map {student_project_id:{quota0:x, quota1:y, ...}, ...}, where the quota0:x means91 that account_id will apply x amount of quota0 total. Thus to actually *do* the upgrading,92 this user (account_id) would go through the project map and set their upgrade contribution93 for the student projects in this course to exactly what is specified by this function.94 Note that no upgrade quota will be deducted from projects outside this course to satisfy95 the upgrade_goal.96 If a student_project_id is missing from the output the contribution is 0; if a quota is97 missing, the contribution is 0.98 The keys of the output map are **exactly** the ids of the projects where the current99 allocation should be *changed*. That said, we only consider quotas explicitly given100 in the upgrade_goal map.101 */102 // upgrades, etc., that student projects already have (which account_id did not provide)103 const cur = exports.current_student_project_upgrades({104 account_id: opts.account_id,105 project_map: opts.project_map,106 student_project_ids: opts.student_project_ids,107 });108 // upgrades we have that have not been allocated to our course109 const available = exports.available_upgrades({110 account_id: opts.account_id,111 purchased_upgrades: opts.purchased_upgrades,112 project_map: opts.project_map,113 student_project_ids: opts.student_project_ids,114 });115 const ids = misc.keys(opts.student_project_ids);116 ids.sort();117 const plan = {};118 for (const project_id of ids) {119 if (opts.deleted_project_ids[project_id]) {120 // give this project NOTHING121 continue;122 }123 plan[project_id] = {};124 // we only care about quotas in the upgrade_goal125 for (var quota in opts.upgrade_goal) {126 const val = opts.upgrade_goal[quota];127 const need =128 val -129 ((cur[project_id] != null ? cur[project_id][quota] : undefined) != null130 ? cur[project_id] != null131 ? cur[project_id][quota]132 : undefined133 : 0);134 if (need > 0) {135 const have = Math.min(need, available[quota]);136 plan[project_id][quota] = have;137 available[quota] -= have;138 }139 }140 // is there an actual allocation change? if not, we do not include this key.141 const upgrades = opts.project_map.getIn([142 project_id,143 "users",144 opts.account_id,145 "upgrades",146 ]);147 const alloc = upgrades != null ? upgrades.toJS() : {};148 let change = false;149 for (quota in opts.upgrade_goal) {150 if (151 (alloc[quota] != null ? alloc[quota] : 0) !==152 (plan[project_id][quota] != null ? plan[project_id][quota] : 0)153 ) {154 change = true;155 break;156 }157 }158 if (!change) {159 delete plan[project_id];160 }161 }162 return plan;...

Full Screen

Full Screen

twoSum.js

Source:twoSum.js Github

copy

Full Screen

1// Write a function that takes in a non-empty array of distinct integers and an2// integer representing a target sum. If any two numbers in the input array sum3// up to the target sum, the function should return them in an array, in any4// order. If no two numbers sum up to the target sum, the function should return5// an empty array.6// Note that the target sum has to be obtained by summing two different integers7// in the array; you can't add a single integer to itself in order to obtain the8// target sum.9// You can assume that there will be at most one pair of numbers summing up to10// the target sum.11// array = = [3, 5, -4, 8, 11, 1, -1, 6]12// targetSum = 1013// output = [-1, 11]14//sol15//brute force method 16function twoNumberSum(array, targetSum) {17 if(!array.length) {18 return19 }20 // Write your code here.21 for(let i=0; i<array.length; i++) {22 for(let j =1; j<array.length && i !== j; j++) {23 if(array[i] + array[j] === targetSum) {24 return [array[i], array[j]]25 }26 }27 }28 return []29}30//using sort and pointers 31function twoNumberSum(array, targetSum) {32 // Write your code here.33 //sort the array 34 array.sort((a,b) => (a-b))35 //initialize left and right pointers 36 let l =0;37 let r = array.length - 1;38 // compare elements at left and right indices 39 while(l < r) {40 const currentSum = array[l] + array[r]41 if(currentSum < targetSum) {42 l++43 }else if(currentSum > targetSum) {44 r--45 }else if(currentSum === targetSum) {46 return [array[l], array[r]]47 }48 }49 return []50}51// Hint : x + y = target52// y = target - x53// using exitence map 54function twoNumberSum(array, targetSum) {55 // Write your code here.56 if(!array.length) {57 return58 }59 const existenceMap = {}60 for(let i=0; i<array.length; i++) {61 const val = targetSum - array[i]62 console.log('val ',val)63 if(existenceMap.hasOwnProperty(array[i])) {64 return [array[i], val]65 }else {66 existenceMap[val] = true67 }68 }69 return []70}71function twoNumberSum(array, targetSum) {72 // Write your code here.73 if (!array.length) {74 return;75 }76 let map = arrayMap(array);77 for (let i = 0; i < array.length; i++) {78 const val = targetSum - array[i];79 if (map[val] && i !== map[val]) {80 console.log([array[i], array[map[val]]]);81 return [array[i], array[map[val]]];82 }83 }84 return [];85}86function arrayMap(arr) {87 let map = {};88 for (let i = 0; i < arr.length; i++) {89 map[arr[i]] = i;90 }91 return map;92}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var client = new stf.Client();3client.connect(function(err) {4 if (err) {5 throw err;6 }7 client.existenceMap(function(err, map) {8 if (err) {9 throw err;10 }11 console.log(map);12 client.disconnect();13 });14});15{ '2b2d8b91': true, '2b2d8b92': false }16var stf = require('devicefarmer-stf-client');17var client = new stf.Client();18client.connect(function(err) {19 if (err) {20 throw err;21 }22 client.existenceMap(function(err, map) {23 if (err) {24 throw err;25 }26 var serials = Object.keys(map);27 var connectedSerials = serials.filter(function(serial) {28 return map[serial];29 });30 console.log(connectedSerials);31 client.disconnect();32 });33});34var stf = require('devicefarmer-stf-client');35var client = new stf.Client();36client.connect(function(err) {37 if (err) {38 throw err;39 }40 client.existenceMap(function(err, map) {41 if (err) {42 throw err;43 }44 var serials = Object.keys(map);45 var disconnectedSerials = serials.filter(function(serial) {46 return !map[serial];47 });48 console.log(disconnectedSerials);49 client.disconnect();50 });51});

Full Screen

Using AI Code Generation

copy

Full Screen

1var deviceUtil = require('devicefarmer-stf-device-util');2var device = {3 "display": {4 },5 "phone": {6 },7 "provider": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var existenceMap = client.existenceMap();3existenceMap.on('add', function (serial) {4console.log('device added', serial);5});6existenceMap.on('remove', function (serial) {7console.log('device removed', serial);8});9existenceMap.on('change', function (serial, present) {10console.log('device ' + (present ? 'added' : 'removed'), serial);11});12var client = require('devicefarmer-stf-client-nodejs-wrapper');13client.existenceMap().then(function (existenceMap) {14existenceMap.on('add', function (serial) {15console.log('device added', serial);16});17existenceMap.on('remove', function (serial) {18console.log('device removed', serial);19});20existenceMap.on('change', function (serial, present) {21console.log('device ' + (present ? 'added' : 'removed'), serial);22});23});24import com.devicefarmer.stf.client.Client;25import com.devicefarmer.stf.client.ExistenceMap;26import com.devicefarmer.stf.client.ExistenceMapListener;27public class Test {

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2stf.getDeviceList(function(err, devices) {3 if (err) {4 console.log(err);5 } else {6 var existenceMap = stf.existenceMap(devices);7 console.log(existenceMap);8 }9});10{ '1d7b6e0e': true,11 'f3b6e2b6': true }12* `getDeviceList(callback)`: returns the list of devices currently connected to the STF server13* `getDevice(serial, callback)`: returns the device with the given serial number14* `getDevicesByOwner(owner, callback)`: returns the list of devices currently owned by the given owner15* `getDevicesByGroup(group, callback)`: returns the list of devices currently owned by the given group16* `getDevicesByGroupAndOwner(group, owner, callback)`: returns the list of devices currently owned by the given group and owner17* `getDevicesByGroupOrOwner(group, owner, callback)`: returns the list of devices currently owned by the given group or owner18* `getDevicesByGroupAndNotOwner(group, owner, callback)`: returns the list of devices currently owned by the given group and not by the given owner19* `getDevicesByGroupOrNotOwner(group, owner, callback)`: returns the list of devices currently owned by the given group or not by the given owner20* `getDevicesByNotGroupAndOwner(group, owner, callback)`: returns the list of devices currently not owned by the given group and owned by the given owner

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2test.existenceMap('device1').then(function(result) {3 console.log(result);4});5var stf = require('devicefarmer-stf-client');6test.getDevice('device1').then(function(result) {7 console.log(result);8});9var stf = require('devicefarmer-stf-client');10test.getDevices().then(function(result) {11 console.log(result);12});13var stf = require('devicefarmer-stf-client');14test.getDevices().then(function(result) {15 console.log(result);16});17var stf = require('devicefarmer-stf-client');18test.getDevices().then(function(result) {19 console.log(result);20});21var stf = require('devicefarmer-stf-client');22test.getDevices().then(function(result) {23 console.log(result);24});25var stf = require('devicefarmer-stf-client');26test.getDevices().then(function(result) {27 console.log(result);28});29var stf = require('devicefarmer-stf-client');30test.getDevices().then(function(result) {31 console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var device = new stf.Device();3var deviceSerial = 'ABC123456789';4device.existenceMap(deviceSerial).then(function (existenceMap) {5 console.log(existenceMap);6});7{8}9var stf = require('devicefarmer-stf');10var device = new stf.Device();11device.getDevices().then(function (devices) {12 console.log(devices);13});14 {15 "battery": {16 },17 "display": {18 },19 "phone": {20 "android": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var DeviceFarmer = require('devicefarmer-stf-client');2var df = new DeviceFarmer({3});4df.connect('test', 'test').then(function() {5 df.getDevices().then(function(devices) {6 devices.forEach(function(device) {7 console.log(device.serial + ": " + device.existenceMap);8 });9 });10});

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var serial = 'a4a4a4a4';3stfClient.existenceMap(serial, function(err, result) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log(result);8 }9});10{ serial: 'a4a4a4a4', exists: true }11{ serial: 'a4a4a4a4', exists: false }12var client = require('devicefarmer-stf-client');13var serial = 'a4a4a4a4';14stfClient.availabilityMap(serial, function(err, result) {15 if (err) {16 console.log('Error: ' + err);17 } else {18 console.log(result);19 }20});21{ serial: 'a4a4a4a4', available: true }22{ serial: 'a4a4a4a4', available: false }23var client = require('devicefarmer-stf-client');24var serial = 'a4a4a4a4';25stfClient.usageMap(serial, function(err, result) {26 if (err) {27 console.log('

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful