Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@informath/nominatim

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@informath/nominatim - npm Package Compare versions

Comparing version 5.5.0 to 6.0.0

62

lib/nominatim.js

@@ -1,34 +0,46 @@

const fetch = require('node-fetch'), // Forgot the "Usage Policy" part... NotLikeThis
TQueue = require('tqueue');
const fetch = require('node-fetch'); // Forgot the "Usage Policy" part... NotLikeThis
const Db = require('informa-db.js');
const { Db } = require('informa-db.js');
const queue = new TQueue({delay: 1000});
const queue = [];
const cache = new Db('cache.json');
const baseUrl = 'https://nominatim.openstreetmap.org/';
queue.on('pop', async (item) => {
cache[url] = await (await fetch(item.url)).json();
item.fn(cache[url]);
const NominatimNoAuth = new Proxy({}, {
get(obj, prop) {
return (prop == 'default' ? {
addressdetails: 1,
limit: 10,
format: 'json'
} : (options, overwriteDefault) => new Promise((res) => {
const url = `${baseUrl}${prop}?${
Object.entries({ ...(overwriteDefault ? {} : Nominatim.default), ...options })
.map(([i, v]) => `${i}=${v}`)
.join('&')
}`;
if (url in cache) res(cache[url]);
queue.push({
url,
fn: res,
uA: this.userAgent,
})
}))
}
});
const Nominatim = new Proxy({}, {
get: (obj, prop) => (prop == 'default' ? {
addressdetails: 1,
limit: 10,
format: 'json'
} : (options, overwriteDefault) => new Promise((res) => {
const url = `${baseUrl}${prop}?${
Object.entries({ ...(overwriteDefault ? {} : Nominatim.default), ...options })
.map(([i, v]) => `${i}=${v}`)
.join('&')
}`;
if (url in cache) res(cache[url]);
queue.push({
url,
fn: res,
})
}))
});
class Nominatim extends NominatimNoAuth {
constructor(userAgent) {
if (!userAgent) throw new Error('');
this.userAgent = `"${userAgent}" Cached 1sDelay ShouldBeCompliant`;
setInterval(async () => {
const item = queue.shift();
if (item) {
cache[url] = await (await fetch(item.url)).json();
item.fn(cache[url]);
}
}, 1000);
}
}
module.exports = Nominatim;

@@ -5,3 +5,3 @@ {

"description": "Completely rewritten version of David Howell's Nominatim",
"version": "5.5.0",
"version": "6.0.0",
"repository": {

@@ -13,7 +13,5 @@ "type": "git",

"dependencies": {
"node-fetch": "^2.6.1",
"tqueue": "^0.1.0"
},
"devDependencies": {},
"optionalDependencies": {}
"informa-db.js": "^5.5.0",
"node-fetch": "^2.6.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc