Skip to content

Commit

Permalink
Make prettier JS snippets (#377)
Browse files Browse the repository at this point in the history
* Make prettier JS snippets

* Conform to CS (about curly brace)

* Apply feedback
  • Loading branch information
brikou authored and ebidel committed Aug 18, 2017
1 parent ae3fedf commit 8f43bef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -42,7 +42,6 @@ of `Browser`, open pages, and then manipulate them with [Puppeteer's API](https:
const puppeteer = require('puppeteer');

(async () => {

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
Expand All @@ -60,7 +59,6 @@ Puppeteer sets an initial page size to 800px x 600px, which defines the screensh
const puppeteer = require('puppeteer');

(async () => {

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://news.ycombinator.com', {waitUntil: 'networkidle'});
Expand Down
18 changes: 12 additions & 6 deletions docs/api.md
Expand Up @@ -221,7 +221,7 @@ The arguments passed into `console.log` appear as arguments on the event handler
An example of handling `console` event:
```js
page.on('console', (...args) => {
for (let i =0; i < args.length; ++i)
for (let i = 0; i < args.length; ++i)
console.log(`${i}: ${args[i]}`);
});
page.evaluate(() => console.log(5, 'hello', {foo: 'bar'}));
Expand Down Expand Up @@ -406,7 +406,9 @@ const crypto = require('crypto');
puppeteer.launch().then(async browser => {
let page = await browser.newPage();
page.on('console', console.log);
await page.exposeFunction('md5', text => crypto.createHash('md5').update(text).digest('hex'));
await page.exposeFunction('md5', text =>
crypto.createHash('md5').update(text).digest('hex')
);
await page.evaluate(async () => {
// use window.md5 to compute hashes
let myString = 'PUPPETEER';
Expand Down Expand Up @@ -761,7 +763,9 @@ const puppeteer = require('puppeteer');
puppeteer.launch().then(async browser => {
let page = await browser.newPage();
let currentURL;
page.waitForSelector('img').then(() => console.log('First URL with image: ' + currentURL));
page
.waitForSelector('img')
.then(() => console.log('First URL with image: ' + currentURL));
for (currentURL of ['https://example.com', 'https://google.com', 'https://bbc.com'])
await page.goto(currentURL);
browser.close();
Expand Down Expand Up @@ -1065,7 +1069,9 @@ const puppeteer = require('puppeteer');
puppeteer.launch().then(async browser => {
let page = await browser.newPage();
let currentURL;
page.waitForSelector('img').then(() => console.log('First URL with image: ' + currentURL));
page
.waitForSelector('img')
.then(() => console.log('First URL with image: ' + currentURL));
for (currentURL of ['https://example.com', 'https://google.com', 'https://bbc.com'])
await page.goto(currentURL);
browser.close();
Expand All @@ -1083,7 +1089,7 @@ puppeteer.launch().then(async browser => {
await page.goto('https://google.com');
let inputElement = await page.$('input[type=submit]');
await inputElement.click();
...
// ...
});
```

Expand Down Expand Up @@ -1235,4 +1241,4 @@ Contains the URL of the response.
[Tracing]: #class-tracing "Tracing"
[ElementHandle]: #class-elementhandle "ElementHandle"
[UIEvent.detail]: https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail "UIEvent.detail"
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"
[Serializable]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#Description "Serializable"

0 comments on commit 8f43bef

Please sign in to comment.