Best JavaScript code snippet using puppeteer
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
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await page.screenshot({path: 'google.png'});6 console.log("Is browser connected: " + browser.isConnected());7 await browser.close();8})();9Recommended Posts: Puppeteer | browser.isConnected()10Puppeteer | browser.pages()11Puppeteer | browser.userAgent()12Puppeteer | browser.version()13Puppeteer | browser.process()14Puppeteer | browser.close()15Puppeteer | browser.disconnect()16Puppeteer | browser.createIncognitoBrowserContext()17Puppeteer | browser.newPage()18Puppeteer | browser.target()19Puppeteer | browser.targets()20Puppeteer | browser.defaultBrowserContext()21Puppeteer | browser.newBrowserCDPSession()22Puppeteer | browser.waitForTarget()23Puppeteer | browser.wsEndpoint()24Puppeteer | browser.isConnected() Method25Puppeteer | browser.pages() Method26Puppeteer | browser.userAgent() Method27Puppeteer | browser.version() Method28Puppeteer | browser.process() Method29Puppeteer | browser.close() Method30Puppeteer | browser.disconnect() Method31Puppeteer | browser.createIncognitoBrowserContext() Method32Puppeteer | browser.newPage() Method33Puppeteer | browser.target() Method34Puppeteer | browser.targets() Method35Puppeteer | browser.defaultBrowserContext() Method36Puppeteer | browser.newBrowserCDPSession() Method37Puppeteer | browser.waitForTarget() Method38Puppeteer | browser.wsEndpoint() Method
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({headless: false});4 const page = await browser.newPage();5 await page.screenshot({path: 'google.png'});6 await browser.close();7})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 console.log(await page.browser().isConnected());6 await browser.close();7 console.log(await page.browser().isConnected());8})();9const puppeteer = require('puppeteer');10(async () => {11 const browser = await puppeteer.launch();12 const page = await browser.newPage();13 console.log(await page.browser().isConnected());14 console.log(await page.browser().isClosed());15 await browser.close();16 console.log(await page.browser().isConnected());17 console.log(await page.browser().isClosed());18})();19const puppeteer = require('puppeteer');20(async () => {21 const browser = await puppeteer.launch();22 const page = await browser.newPage();23 await browser.close();24})();25const puppeteer = require('puppeteer');26(async () => {27 const browser = await puppeteer.launch();28 const page = await browser.newPage();29 const pages = await browser.pages();30 console.log(pages.length);31 await browser.close();32})();33const puppeteer = require('puppeteer');34(async () => {35 const browser = await puppeteer.launch();36 const page = await browser.newPage();37 console.log(await page.browser().userAgent());
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 console.log(await page.browser().isConnected());6 await browser.close();7})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2const devices = require('puppeteer/DeviceDescriptors');3const iPhone = devices['iPhone 6'];4(async () => {5 const browser = await puppeteer.launch({6 });7 const page = await browser.newPage();8 await page.emulate(iPhone);9 await page.screenshot({path: 'google.png'});10 console.log('isConnected', page.browser().wsEndpoint());11 await browser.close();12})();
Using AI Code Generation
1(async () => {2 const browser = await puppeteer.launch();3 const page = await browser.newPage();4 const isConnected = await page.target().createCDPSession().then(5 session => session.send('Network.enable').then(() => true),6 () => false7 );8 console.log(isConnected);9 await browser.close();10})();
Using AI Code Generation
1(async () => {2const browser = await puppeteer.launch({ headless: false });3const page = await browser.newPage();4const isConnected = await page.browser().isConnected();5console.log(isConnected);6await browser.close();7})();8(async () => {9const browser = await puppeteer.launch({ headless: false });10const page = await browser.newPage();11const isConnected = await page.browser().isConnected();12console.log(isConnected);13await browser.close();14})();15(async () => {16const browser = await puppeteer.launch({ headless: false });17const page = await browser.newPage();18const isConnected = await page.browser().isConnected();19console.log(isConnected);20await browser.close();21})();22(async () => {23const browser = await puppeteer.launch({ headless: false });24const page = await browser.newPage();25const isConnected = await page.browser().isConnected();26console.log(isConnected);27await browser.close();28})();29(async () => {30const browser = await puppeteer.launch({ headless: false });31const page = await browser.newPage();32const isConnected = await page.browser().isConnected();33console.log(isConnected);34await browser.close();35})();36(async () => {37const browser = await puppeteer.launch({ headless: false });38const page = await browser.newPage();39const isConnected = await page.browser().isConnected();40console.log(isConnected);41await browser.close();42})();43(async () => {44const browser = await puppeteer.launch({ headless: false });45const page = await browser.newPage();46const isConnected = await page.browser().isConnected();47console.log(isConnected);48await browser.close();49})();50(async () => {51const browser = await puppeteer.launch({ headless: false });52const page = await browser.newPage();53const isConnected = await page.browser().isConnected
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch({4 });5 const page = await browser.newPage();6 console.log(await page.browser().isConnected());7 await browser.close();8 console.log(await page.browser().isConnected());9})();10const puppeteer = require('puppeteer');11(async () => {12 const browser = await puppeteer.launch({13 });14 const page = await browser.newPage();15 console.log(await page.browser().isConnected());16 await browser.close();17 console.log(await page.browser().isConnected());18})();19const puppeteer = require('puppeteer');20(async () => {21 const browser = await puppeteer.launch({22 });23 const page = await browser.newPage();24 console.log(await
Using AI Code Generation
1const puppeteer = require('puppeteer');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 var isConnected = browser.isConnected();6 console.log('isConnected: ' + isConnected);7 await browser.close();8})();
Using AI Code Generation
1const puppeteer = require('puppeteer');2const browser = await puppeteer.launch({headless: false});3const page = await browser.newPage();4await page.waitFor(5000);5const isConnected = await page.browser().isConnected();6await browser.close();7#### browser.close()8#### browser.pages()9#### browser.isConnected()10#### browser.userAgent()11#### browser.version()12#### browser.process()13#### browser.defaultBrowserContext()14#### browser.browserContexts()15#### browser.newPage()16#### browser.createIncognitoBrowserContext()17#### browser.browserContext()18#### browser.disconnect()19#### browser.target()20#### browser.waitForTarget(predicate, options)21#### browser.targets()22#### page.browser()23#### page.close()24#### page.content()25#### page.screenshot(options)26#### page.pdf(options)27#### page.title()28#### page.url()29#### page.waitForNavigation(options)30#### page.waitForRequest(urlOrPredicate, options)31#### page.waitForResponse(urlOrPredicate, options)32#### page.waitForSelector(selector, options)33#### page.waitForXPath(xpath, options)34#### page.waitForFunction(pageFunction, options, ...args)35#### page.waitFor(timeout)
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!!