@informath/nominatim
Advanced tools
Comparing version 2.0.0 to 3.0.0
@@ -1,26 +0,26 @@ | ||
const fetch = require('node-fetch'); | ||
const fetch = require('node-fetch'), // Forgot the "Usage Policy" part... NotLikeThis | ||
TQueue = require('tqueue'); | ||
const defaults = { | ||
addressdetails: 1, | ||
limit: , | ||
format: 'json' | ||
}; | ||
const baseUrl = 'https://nominatim.openstreetmap.org/' | ||
const queue = new TQueue({delay: 1000}); | ||
const baseUrl = 'https://nominatim.openstreetmap.org/'; | ||
queue.on('pop', async (item) => { | ||
item.fn(await (await fetch(item.url)).json()); | ||
}); | ||
const Nominatim = Proxy({}, { | ||
get: (obj, prop) => (prop == 'default' ? { | ||
addressdetails: 1, | ||
limit: 3, | ||
limit: 10, | ||
format: 'json' | ||
} : async (options, overwriteDefault) => await ( | ||
await fetch( | ||
`${baseUrl}${prop}?${ | ||
Object.entries({ ...(overwriteDefault ? {} : Nominatim.default, ...options }) | ||
.map(([i, v]) => `${i}=${v}`) | ||
.join('&') | ||
}` | ||
) | ||
).json()) | ||
} : (options, overwriteDefault) => return new Promise((res) => queue.push({ | ||
url: `${baseUrl}${prop}?${ | ||
Object.entries({ ...(overwriteDefault ? {} : Nominatim.default, ...options }) | ||
.map(([i, v]) => `${i}=${v}`) | ||
.join('&') | ||
}`, | ||
fn: res, | ||
})) | ||
}); | ||
module.exports = Nominatim; |
@@ -5,3 +5,3 @@ { | ||
"description": "Completely rewritten version of David Howell's Nominatim", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
2582
33