Skip to content

Commit 8d57666

Browse files
committed
code style 👕
1 parent b3d940b commit 8d57666

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

example.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
const queryOverpass = require('.')
44

5-
queryOverpass(`\
6-
[out:json][timeout:25];
7-
node(3378340880);
8-
out body;`)
5+
queryOverpass(`
6+
[out:json][timeout:25];
7+
node(3378340880);
8+
out body;
9+
`)
910
.then(console.log)
1011
.catch(console.error)

index.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict'
22

33
const retry = require('p-retry')
4-
const {fetch} = require('fetch-ponyfill')({Promise: require('pinkie-promise')})
4+
const Promise = require('pinkie-promise')
5+
const {fetch} = require('fetch-ponyfill')({Promise})
56
const {stringify} = require('query-string')
67

78
const endpoint = 'https://overpass-api.de/api/interpreter'
89

910
const queryOverpass = (query) => {
10-
return retry(() => {
11+
const attempt = () => {
1112
return fetch(endpoint + '?' + stringify({data: query}), {
1213
// todo: decide on this
1314
// yields isomorphic code, but slower due to preflight request?
@@ -32,7 +33,9 @@ const queryOverpass = (query) => {
3233
}
3334
return data.elements
3435
})
35-
}, {minTimeout: 500})
36+
}
37+
38+
return retry(attempt, {minTimeout: 500})
3639
}
3740

3841
module.exports = queryOverpass

license.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2017, Jannis R
1+
Copyright (c) 2018, Jannis R
22

33
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
44

readme.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ Pass in a string of [Overpass QL](http://wiki.openstreetmap.org/wiki/Overpass_AP
3131
```js
3232
const queryOverpass = require('query-overpass')
3333

34-
queryOverpass(`\
35-
[out:json][timeout:25];
36-
node(3378340880);
37-
out body;`)
34+
queryOverpass(`
35+
[out:json][timeout:25];
36+
node(3378340880);
37+
out body;
38+
`)
3839
.then(console.log)
3940
.catch(console.error)
4041
```

test.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ const west = 13.35
99
const north = 52.5
1010
const east = 13.4
1111
const bbox = [south, west, north, east].join(',')
12-
const query = `\
13-
[out:json][timeout:25];
14-
node["railway"="subway_entrance"](${bbox});
15-
out body;`
12+
const query = `
13+
[out:json][timeout:25];
14+
node["railway"="subway_entrance"](${bbox});
15+
out body;
16+
`
1617

1718
test('queryOverpass', (t) => {
1819
queryOverpass(query)

0 commit comments

Comments
 (0)