Best JavaScript code snippet using root
SpinnerProvider.js
Source:SpinnerProvider.js
1import React, { Component } from 'react';2import { View } from 'react-native';3import SpinnerModal from './SpinnerModal';4export default class SpinnerProvider extends Component {5 componentWillMount () {6 // console.log('Spinner props mount: ', this.props);7 }8 // componentWillReceiveProps (nextProps) {9 // // console.log('Spinner props this props: ', this.props);10 // // console.log('Spinner props nextProps: ', nextProps);11 // }12 render () {13 console.log('Spinner render: ');14 // console.log('Spinner render: ', this.props);15 const {16 isReceivingFeed,17 isFetchingFeed,18 isConnected,19 eventCodeError,20 isFetchingBranch,21 saveEventStatus,22 isFetchingEvent,23 isFetchingCreate,24 isConfirmingEvent,25 isEventConfirmed,26 isFinishedUpdatingRsvp,27 finalChoices,28 goBack } = this.props;29 const isLoading = isFetchingBranch || isReceivingFeed || isFetchingFeed || isFetchingEvent || isFetchingCreate;30 const isErrorModalVisible = () => {31 if (!eventCodeError) {32 return false;33 }34 return true;35 };36 const errorModalVisible = isErrorModalVisible();37 console.log('errorModalVisible', errorModalVisible);38 console.log('isLoading:', isLoading);39 // console.log('this.props.children:', this.props.children);40 return (41 <View style={{ flex: 1, borderColor: 'pink', borderWidth: 0 }}>42 {43 (isConfirmingEvent) &&44 <View style={{ borderColor: 'purple', borderWidth: 2 }}>45 <SpinnerModal46 visible={isConfirmingEvent}47 type="confirming_event"48 isConnected={isConnected}49 onClose={ () => { }}50 // additionalInfo={ `SP share_invite --- isFetchingBranch:${isFetchingBranch}, isReceivingFeed:${isReceivingFeed}, isFetchingFeed:${isFetchingFeed}, isFetchingEvent:${isFetchingEvent}, isLoading:${isLoading}, isConnected:${isConnected}, saveEventStatus:${saveEventStatus}`} // eslint-disable-line max-len51 />52 </View>53 }54 {55 (isEventConfirmed) &&56 <View style={{ borderColor: 'blue', borderWidth: 2 }}>57 <SpinnerModal58 visible={isEventConfirmed}59 type="event_confirmed"60 isConnected={isConnected}61 goBack={goBack}62 onClose={ () => { }}63 additionalInfo={ finalChoices } // eslint-disable-line max-len64 />65 </View>66 }67 {68 (isFinishedUpdatingRsvp) &&69 <View style={{ borderColor: 'lightblue', borderWidth: 2 }}>70 <SpinnerModal71 visible={isFinishedUpdatingRsvp}72 type="rsvp_finished"73 isConnected={isConnected}74 goBack={goBack}75 onClose={ () => { }}76 // additionalInfo={ } // eslint-disable-line max-len77 />78 </View>79 }80 {81 (saveEventStatus === 'Started') &&82 <View style={{ borderColor: 'orange', borderWidth: 2 }}>83 <SpinnerModal84 visible={isLoading}85 type="share_invite"86 isConnected={isConnected}87 onClose={ () => { }}88 // additionalInfo={ `SP share_invite --- isFetchingBranch:${isFetchingBranch}, isReceivingFeed:${isReceivingFeed}, isFetchingFeed:${isFetchingFeed}, isFetchingEvent:${isFetchingEvent}, isLoading:${isLoading}, isConnected:${isConnected}, saveEventStatus:${saveEventStatus}`} // eslint-disable-line max-len89 />90 </View>91 }92 {93 (isLoading) &&94 <View style={{ borderColor: 'blue', borderWidth: 2 }}>95 <SpinnerModal96 visible={isLoading}97 type="loading"98 isConnected={isConnected}99 onClose={ () => { }}100 // additionalInfo={ `SP isLoading --- isFetchingBranch:${isFetchingBranch}, isReceivingFeed:${isReceivingFeed}, isFetchingFeed:${isFetchingFeed}, isFetchingEvent:${isFetchingEvent}, isLoading:${isLoading}, isConnected:${isConnected}, saveEventStatus:${saveEventStatus}`} // eslint-disable-line max-len101 />102 </View>103 }104 {105 (eventCodeError) &&106 <View style={{ borderColor: 'yellow', borderWidth: 2 }}>107 <SpinnerModal108 visible={errorModalVisible}109 type="event_code_error"110 isConnected={isConnected}111 onClose={ () => { }}112 eventCodeError={eventCodeError}113 // additionalInfo={ `SP eventCodeError --- isFetchingBranch:${isFetchingBranch}, isReceivingFeed:${isReceivingFeed}, isFetchingFeed:${isFetchingFeed}, isFetchingEvent:${isFetchingEvent}, isLoading:${isLoading}, isConnected:${isConnected}, saveEventStatus:${saveEventStatus}`} // eslint-disable-line max-len114 />115 </View>116 }117 {React.Children.only(this.props.children)}118 </View>119 );120 }...
test_slice_util.js
Source:test_slice_util.js
...9 });10 it('test slice_util#isConnected should return true', function() {11 let source = testslice.resources.sensor;12 let destination = testslice.resources.broker;13 let isConnected = util.isConnected(testslice, source, destination);14 assert.equal(isConnected, true);15 });16 it('test slice_util#isConnected should return false', function() {17 let source = testslice.resources.broker;18 let destination = testslice.resources.sensor;19 let isConnected = util.isConnected(testslice, source, destination);20 assert.equal(isConnected, false);21 });22 it('test slice_util#contains should return true', function() {23 let resource = testslice.resources.analytics.name;24 let contains = util.contains(testslice, resource);25 assert.equal(contains, true);26 });27 it('test slice_util#contains should return false', function() {28 let resource = "new resource not in testslice";29 let contains = util.contains(testslice, resource);30 assert.equal(contains, false);31 });32 it('test slice_util#sliceConnect should connect resources in slice', function() {33 let source = {name:"source", source:[], target:[]};34 let dest = {name:"dest", source:[], target:[]};35 let slice = {resources:{sourceId:source, dest:dest}, connectivities:{}};36 let isConnected = util.isConnected(slice,source,dest);37 assert.equal(isConnected, false);38 util.sliceConnect(slice,source,dest,"connectionname");39 isConnected = util.isConnected(slice,source,dest);40 assert.equal(isConnected, true);41 let wrongDirectionConnected = util.isConnected(slice,dest,source);42 assert.equal(wrongDirectionConnected, false);43 });44 it('test slice_util#sliceDisConnect should connect resources in slice', function() {45 let source = {name:"source", source:[], target:[]};46 let dest = {name:"dest", source:[], target:[]};47 let slice = {resources:{source:source, dest:dest}, connectivities:{}};48 let isConnected = util.isConnected(slice,source,dest);49 assert.equal(isConnected, false);50 util.sliceConnect(slice,source,dest,"connectionname");51 isConnected = util.isConnected(slice,source,dest);52 assert.equal(isConnected, true);53 let wrongDirectionConnected = util.isConnected(slice,dest,source);54 assert.equal(wrongDirectionConnected, false);55 util.sliceDisConnect(slice,source,dest);56 isConnected = util.isConnected(slice,source,dest);57 assert.equal(isConnected, false);58 assert.equal(slice.connectivities["connectionname"], undefined);59 assert.equal(slice.resources.source.target.indexOf("connectionname")>-1, false);60 assert.equal(slice.resources.dest.source.indexOf("connectionname")>-1, false);61 });62 it('test slice_util#sliceAddResource should add resources with new name', function() {63 let source = {name: "source", source: [], target: []};64 let dest = {name: "dest", source: [], target: []};65 let slice = {resources: {source: source, dest: dest}, connectivities: {}};66 let extraSource = {name: "extraSource", source: [], target: []};67 let resourceId = util.sliceAddResource(slice, extraSource, "source");68 assert.equal(resourceId, "source_1");69 assert.equal(slice.resources["source_1"], extraSource);70 });71 it('test slice_util#substituteResource should correctly substitute resources', function() {72 let slice = basic_slices.test_0_10_indirect_mismatch_mn();73 let oldbroker = util.deepcopy(slice.resources.broker);74 let substitutionBroker = {name: "substitutionBroker", metadata:{test:"test"}, source: [], target: []};75 util.substituteResource(slice, "broker", substitutionBroker);76 //let resourceId = util.sliceAddResource(slice, extraSource, "source");77 assert.notDeepEqual(slice.resources.broker, oldbroker, "oldbroker should not be part of the slice anymore");78 assert.equal(slice.resources.broker.name, substitutionBroker.name);79 assert.deepEqual(slice.resources.broker.metadata, substitutionBroker.metadata);80 assert.equal(util.isConnected(slice,slice.resources.source1,slice.resources.broker), true);81 assert.equal(util.isConnected(slice,slice.resources.source2,slice.resources.broker), true);82 assert.equal(util.isConnected(slice,slice.resources.broker, slice.resources.dest1), true);83 assert.equal(util.isConnected(slice,slice.resources.broker, slice.resources.dest2), true);84 });...
12.js
Source:12.js
...28 const key = parseInt(parts[0]);29 const pipes = parts[1].split(', ').map(x => parseInt(x));30 return new Node(key, pipes);31});32function isConnected(data, indexToCheck, checkedAlready = []) {33 checkedAlready.push(indexToCheck);34 for (let i = 0; i < data[indexToCheck].pipes.length; i++) {35 const currentPipeIndex = data[indexToCheck].pipes[i];36 if (data[currentPipeIndex].isConnected) {37 return true;38 }39 if (checkedAlready.indexOf(currentPipeIndex) === -1) {40 if (isConnected(data, currentPipeIndex, [...checkedAlready])) {41 return true;42 }43 }44 }45 return false;46}47let tryAgainKid;48do {49 tryAgainKid = false;50 for (let i = 1; i < data.length; i++) {51 // If the room is not connected, look for an escape52 if (!data[i].isConnected) {53 if (isConnected(data, i)) {54 tryAgainKid = true;55 data[i].isConnected = true;56 data[i].display = data[i].toString();57 }58 }59 console.log(`Pass complete (try again: ${tryAgainKid}), Total connected nodes: ${data.reduce((sum, node) => sum + (node.isConnected ? 1 : 0), 0)}`);60 }61} while (tryAgainKid);62console.log(data.map(x => x.display).join('\n') + '\n\nTotal connected nodes: ' + data.reduce((sum, node) => sum + (node.isConnected ? 1 : 0), 0));63})();64// Part 265(() => {66class Node {67 constructor(key, pipes) {68 // Display this property first69 this.display = '';70 this.key = key;71 this.pipes = [...pipes];72 this.isConnected = false;73 this.display = this.toString();74 }75}76Node.prototype.toString = function() {77 return `[${this.isConnected ? 'X' : ' '}] ${this.pipes.join(',')}`;78}79// const data = `0 <-> 280// 1 <-> 181// 2 <-> 0, 3, 482// 3 <-> 2, 483// 4 <-> 2, 3, 684// 5 <-> 685// 6 <-> 4, 5` // 6: (0, 2, 3, 4, 5, 6) & (1) = 286const data = window.localStorage.input87.split('\n').map(x => {88 const parts = x.split(' <-> ');89 const key = parseInt(parts[0]);90 const pipes = parts[1].split(', ').map(x => parseInt(x));91 return new Node(key, pipes);92});93// See if a node is connected94function isConnected(data, indexToCheck, checkedAlready = []) {95 checkedAlready.push(indexToCheck);96 for (let i = 0; i < data[indexToCheck].pipes.length; i++) {97 const currentPipeIndex = data[indexToCheck].pipes[i];98 if (data[currentPipeIndex].isConnected) {99 return true;100 }101 if (checkedAlready.indexOf(currentPipeIndex) === -1) {102 if (isConnected(data, currentPipeIndex, [...checkedAlready])) {103 return true;104 }105 }106 }107 return false;108}109// Reduce the group by removing all connected nodes110function removeGroup(data) {111 for (let i = 0; i < data.length; i++) {112 if (data[i].isConnected) {113 data.splice(i, 1);114 for (let j = 0; j < data.length; j++) {115 if (!data[j].isConnected) {116 data[j].pipes = data[j].pipes.map(x => x > i ? x - 1 : x);117 data[j].display = data[j].toString();118 }119 }120 i--;121 }122 }123}124let groupCount = 0;125do {126 let tryAgainKid;127 data[0].isConnected = true;128 do {129 tryAgainKid = false;130 for (let i = 1; i < data.length; i++) {131 // If the room is not connected, look for an escape132 if (!data[i].isConnected) {133 if (isConnected(data, i)) {134 tryAgainKid = true;135 data[i].isConnected = true;136 data[i].display = data[i].toString();137 }138 }139 console.log(`Pass complete (try again: ${tryAgainKid}), Total connected nodes: ${data.reduce((sum, node) => sum + (node.isConnected ? 1 : 0), 0)}`);140 }141 } while (tryAgainKid);142 removeGroup(data);143 groupCount++;144 // Take care of scenario where it's the last node145 if (data.length === 1) {146 data.pop();147 groupCount++;...
NetInfoExample.ios.js
Source:NetInfoExample.ios.js
1/**2 * The examples provided by Facebook are for non-commercial testing and3 * evaluation purposes only.4 *5 * Facebook reserves all rights not expressly granted.6 *7 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS8 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,9 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL10 * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN11 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN12 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.13 *14 * @flow15 */16'use strict';17var React = require('react-native');18var {19 NetInfo,20 Text,21 View22} = React;23var ReachabilitySubscription = React.createClass({24 getInitialState() {25 return {26 reachabilityHistory: [],27 };28 },29 componentDidMount: function() {30 NetInfo.addEventListener(31 'change',32 this._handleReachabilityChange33 );34 },35 componentWillUnmount: function() {36 NetInfo.removeEventListener(37 'change',38 this._handleReachabilityChange39 );40 },41 _handleReachabilityChange: function(reachability) {42 var reachabilityHistory = this.state.reachabilityHistory.slice();43 reachabilityHistory.push(reachability);44 this.setState({45 reachabilityHistory,46 });47 },48 render() {49 return (50 <View>51 <Text>{JSON.stringify(this.state.reachabilityHistory)}</Text>52 </View>53 );54 }55});56var ReachabilityCurrent = React.createClass({57 getInitialState() {58 return {59 reachability: null,60 };61 },62 componentDidMount: function() {63 NetInfo.addEventListener(64 'change',65 this._handleReachabilityChange66 );67 NetInfo.fetch().done(68 (reachability) => { this.setState({reachability}); }69 );70 },71 componentWillUnmount: function() {72 NetInfo.removeEventListener(73 'change',74 this._handleReachabilityChange75 );76 },77 _handleReachabilityChange: function(reachability) {78 this.setState({79 reachability,80 });81 },82 render() {83 return (84 <View>85 <Text>{this.state.reachability}</Text>86 </View>87 );88 }89});90var IsConnected = React.createClass({91 getInitialState() {92 return {93 isConnected: null,94 };95 },96 componentDidMount: function() {97 NetInfo.isConnected.addEventListener(98 'change',99 this._handleConnectivityChange100 );101 NetInfo.isConnected.fetch().done(102 (isConnected) => { this.setState({isConnected}); }103 );104 },105 componentWillUnmount: function() {106 NetInfo.isConnected.removeEventListener(107 'change',108 this._handleConnectivityChange109 );110 },111 _handleConnectivityChange: function(isConnected) {112 this.setState({113 isConnected,114 });115 },116 render() {117 return (118 <View>119 <Text>{this.state.isConnected ? 'Online' : 'Offline'}</Text>120 </View>121 );122 }123});124exports.title = 'NetInfo';125exports.description = 'Monitor network status';126exports.examples = [127 {128 title: 'NetInfo.isConnected',129 description: 'Asynchronously load and observe connectivity',130 render(): ReactElement { return <IsConnected />; }131 },132 {133 title: 'NetInfo.reachabilityIOS',134 description: 'Asynchronously load and observe iOS reachability',135 render(): ReactElement { return <ReachabilityCurrent />; }136 },137 {138 title: 'NetInfo.reachabilityIOS',139 description: 'Observed updates to iOS reachability',140 render(): ReactElement { return <ReachabilitySubscription />; }141 },...
547.js
Source:547.js
1/** union find ver.2 * @param {number[][]} isConnected3 * @return {number}4 union find5 ëí´í¸ 3ìì ë©ì´ë¦¬ê° ë ìë¡ -16 ë¶ëª¨ë ì기ìì ì¼ë¡ ëí´í¸ ì
í
.7 ìµì¢
ë¶ëª¨ê° ë¤ë¥´ë©´ ë ì¤ì ì¸ë±ì¤ê° ìì쪽ì¼ë¡ í©ì¹ê³ ,ìµì¢
ë¶ëª¨ ì
ë°ì´í¸íê³ ì ëµ-18 9 time O(N^2 * Nì¸ë° ê²½ë¡ìì¶í´ì ë ì¤ì´ë¬?), space O(N)10 */11var findCircleNum = function (isConnected) {12 let ans = isConnected.length;13 const parent = [...Array(isConnected.length)].map((x, i) => i);14 // ê²½ë¡ ìì¶15 const findParent = (index) => {16 if (index === parent[index]) return index;17 return (parent[index] = findParent(parent[index]));18 };19 //isConnected ëê°ì ì ë°ì ìí20 for (let i = 0; i < isConnected.length; i++) {21 for (let j = i + 1; j < isConnected[0].length; j++) {22 if (isConnected[i][j] === 0) continue;23 const p1 = findParent(i);24 const p2 = findParent(j);25 if (p1 === p2) continue;26 // ì¸ë±ì¤ê° í° ìª½ì ë¶ëª¨ë¥¼ ìì ì¸ë±ì¤ì ë¶ëª¨ë¡ êµì²´íê³ ans--;27 const p = Math.min(p1, p2);28 parent[p1] = p;29 parent[p2] = p;30 ans--;31 }32 }33 return ans;34};35/** dfs ver.36 * @param {number[][]} isConnected37 * @return {number}38 39 ì¼ë¨ 0ì²ë¦¬40 0-7ì°ê²°ì´ë©´ 41 7ì²ë¦¬íê³ 42 7ë¼ì¸ì¼ë¡ ì¬ê·.43 44 dfsë íë² ë°©ë¬¸íë rowë¡ ë ë¤ì´ê°ì§ ìëë¤.45 time O(N^2), space O(N) for visited array46 47 */48var findCircleNum = function (isConnected) {49 let ans = isConnected.length;50 const v = Array(isConnected.length).fill(0);51 const dfs = (index) => {52 v[index] = 1;53 for (let i = 0; i < isConnected[index].length; i++) {54 if (isConnected[index][i] && v[i] === 0) {55 ans--;56 dfs(i);57 }58 }59 };60 for (let i = 0; i < isConnected.length; i++) {61 if (v[i] === 0) dfs(i);62 }63 return ans;64};65/*66ìë¹67[i][j]=1 ì´ë©´ ië²ì§¸ ëìë jë²ì§¸ ëìë ì°ê²°ëìë¤ë ë».680,0 1,1 2,2 ... ë 무조건 169ex. 700,1,2 방문ì¬ë¶ íì¸í visited=[t,t,f]71fë©´ dfsíì¸í´ë³¸ë¤. 72-> ì´ íì¸. ê°ì´ 1ì´ë©´ dfsëí¨.73time: O(N^2)74space: O(N) for visited75*/76var findCircleNum = function(isConnected) {77 let result = 0;78 let visited = new Array(isConnected.length).fill(false);79 for(let i=0; i<isConnected.length; i++){80 if(!visited[i]){81 dfs(isConnected, i);82 result++;83 }84 }85 86 function dfs(isConnected, i){87 // ì´ íì¸88 for(let j=0; j<isConnected[i].length; j++){89 // 1ì´ê³ jê° ë°©ë¬¸ ìí ëìë©´90 if(isConnected[i][j]===1 && !visited[j]){91 visited[j]=true;92 dfs(isConnected, j);93 }94 }95 }96 97 return result;...
0547-number-of-provinces.js
Source:0547-number-of-provinces.js
1// 547. Number of Provinces2// Difficulty: Medium34/* Description */5// There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city c, then city a is connected indirectly with city c.67// A province is a group of directly or indirectly connected cities and no other cities outside of the group.89// You are given an n x n matrix isConnected where isConnected[i][j] = 1 if the ith city and the jth city are directly connected, and isConnected[i][j] = 0 otherwise.1011// Return the total number of provinces.1213/* Constraints */14// 1 <= n <= 20015// n == isConnected.length16// n == isConnected[i].length17// isConnected[i][j] is 1 or 0.18// isConnected[i][i] == 119// isConnected[i][j] == isConnected[j][i]2021/**22 * @param {number[][]} isConnected23 * @return {number}24 */25var findCircleNum = function (isConnected) {26 let visited = new Array(isConnected.length).fill(0);27 let count = 0;2829 function dfs(idx) {30 for (let i = 0; i < isConnected.length; i++) {31 if (isConnected[idx][i] === 1 && visited[i] === 0) {32 visited[i] = 1;33 dfs(i);34 }35 }36 }3738 for (let i = 0; i < isConnected.length; i++) {39 if (!visited[i]) {40 dfs(i);41 count++;42 }43 }4445 return count;46};4748/**49 * @param {number[][]} isConnected50 * @return {number}51 */52var findCircleNum = function (M) {53 class UnionFind {54 constructor(n) {55 this.graph = [...Array(n)].map((_, i) => i);56 this.groups = n;57 }5859 find(id) {60 if (this.graph[id] === id) return id;61 this.graph[id] = this.find(this.graph[id]);62 return this.graph[id];63 }6465 union(x, y) {66 const rootX = this.find(x);67 const rootY = this.find(y);68 if (rootX !== rootY) {69 this.graph[rootY] = rootX;70 this.groups--;71 }72 }73 }7475 const N = M.length,76 unionfind = new UnionFind(N);7778 for (let r = 0; r < N; r++) {79 for (let c = 0; c < N; c++) {80 if (M[r][c]) unionfind.union(r, c);81 }82 }83 return unionfind.groups;
...
547-省份数量.js
Source:547-省份数量.js
1// æ n 个åå¸ï¼å
¶ä¸ä¸äºå½¼æ¤ç¸è¿ï¼å¦ä¸äºæ²¡æç¸è¿ãå¦æåå¸ a ä¸åå¸ b ç´æ¥ç¸è¿ï¼ä¸åå¸ b ä¸åå¸ c ç´æ¥ç¸è¿ï¼é£ä¹åå¸ a ä¸åå¸ c é´æ¥ç¸è¿ã2// ç份 æ¯ä¸ç»ç´æ¥æé´æ¥ç¸è¿çåå¸ï¼ç»å
ä¸å«å
¶ä»æ²¡æç¸è¿çåå¸ã3// ç»ä½ ä¸ä¸ª n x n çç©éµ isConnected ï¼å
¶ä¸ isConnected[i][j] = 1 表示第 i 个åå¸å第 j 个åå¸ç´æ¥ç¸è¿ï¼è isConnected[i][j] = 0 表示äºè
ä¸ç´æ¥ç¸è¿ã4// è¿åç©éµä¸ ç份 çæ°éã5//  6// ç¤ºä¾ 1ï¼7// è¾å
¥ï¼isConnected = [[1,1,0],[1,1,0],[0,0,1]]8// è¾åºï¼29// ç¤ºä¾ 2ï¼10// è¾å
¥ï¼isConnected = [[1,0,0],[0,1,0],[0,0,1]]11// è¾åºï¼312//  13// æ示ï¼14// 1 <= n <= 20015// n == isConnected.length16// n == isConnected[i].length17// isConnected[i][j] 为 1 æ 018// isConnected[i][i] == 119// isConnected[i][j] == isConnected[j][i]20/**21 * @param {number[][]} isConnected22 * @return {number}23 */24 var findCircleNum = function(isConnected) {25 let m = isConnected.length26 const visited = Array(m).fill(false)27 let res = 028 for(let i = 0; i < m; i ++) {29 if(!visited[i]) {30 dfs(isConnected, visited, i) 31 res ++32 }33 }34 return res35};36function dfs(isConnected, visited, i) {37 for(let j = 0; j < isConnected.length; j++) {38 if(isConnected[i][j] === 1 && !visited[j]) {39 visited[j] = true40 dfs(isConnected, visited, j)41 }42 }...
houses.js
Source:houses.js
1export default [2 { isConnected: true, label: '1', id: 117327 },3 { isConnected: false, label: '10', id: 6828 },4 { isConnected: false, label: '100', id: 439345 },5 { isConnected: false, label: '101', id: 344856 },6 { isConnected: false, label: '106', id: 431709 },7 { isConnected: false, label: '10к1', id: 348517 },8 { isConnected: false, label: '11', id: 372412 },9 { isConnected: false, label: '110', id: 372650 },10 { isConnected: false, label: '111к11', id: 306289 },11 { isConnected: false, label: '12', id: 49422 },12 { isConnected: false, label: '123к3', id: 380380 },13 { isConnected: false, label: '127', id: 101668 },14 { isConnected: false, label: '12к1', id: 487235 },15 { isConnected: false, label: '12к4', id: 448254 },16 { isConnected: false, label: '13', id: 451362 },17 { isConnected: false, label: '135', id: 450002 },18 { isConnected: false, label: '13к1', id: 81076 },19 { isConnected: false, label: '13к3', id: 477681 },20 { isConnected: false, label: '14', id: 29021 },21 { isConnected: false, label: '14к1', id: 436148 },22 { isConnected: false, label: '14к2', id: 345907 },23 { isConnected: false, label: '15', id: 90559 },24 { isConnected: false, label: '15к1', id: 326405 },25 { isConnected: false, label: '15к2', id: 516799 },26 { isConnected: false, label: '16', id: 211499 },...
Using AI Code Generation
1var root = app.root;2var isConnected = root.isConnected();3console.log(isConnected);4var root = app.root;5var isConnected = root.isConnected();6console.log(isConnected);7I am trying to create a simple app that uses the isConnected() method but I am getting the error "root.isConnected is not a function". I am using the following code:My package.json file is:My app.js file is:My test.js file is:Thanks in advance for any help!8Thanks for your reply. I am using the latest version of the SDK (3.0.0). I am using the following command to install the SDK: npm install -g @adobe/aio-cli Is there another way to install the latest version of the SDK?
Using AI Code Generation
1var root = document.documentElement;2if (root.isConnected) {3 console.log('root is connected');4} else {5 console.log('root is not connected');6}7var root = document.documentElement;8if (root.isConnected) {9 console.log('root is connected');10} else {11 console.log('root is not connected');12}13var root = document.documentElement;14if (root.isConnected) {15 console.log('root is connected');16} else {17 console.log('root is not connected');18}19var root = document.documentElement;20if (root.isConnected) {21 console.log('root is connected');22} else {23 console.log('root is not connected');24}
Using AI Code Generation
1var root = require("modules/meta");2var isConnected = root.isConnected;3console.log("isConnected: " + isConnected);4var module = require("modules/module");5var isConnected = module.isConnected;6console.log("isConnected: " + isConnected);7var isConnected = require("modules/meta").isConnected;8console.log("isConnected: " + isConnected);9module.exports = {10};11var isConnected = true;12module.exports = {13};14var connectivity = require("connectivity");15function checkConnection() {16 var connectionType = connectivity.getConnectionType();17 if (connectionType === connectivity.connectionType.none) {18 alert("No connection!");19 } else {20 alert("Connection type: " + connectionType);21 }22}23checkConnection();24var application = require("application");25var activity = application.android.foregroundActivity;26var application = require("application");27var activity = application.android.foregroundActivity;
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!!