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 6.0.0 to 7.0.0

.vscode/settings.json

70

lib/nominatim.js

@@ -5,32 +5,13 @@ const fetch = require('node-fetch'); // Forgot the "Usage Policy" part... NotLikeThis

const queue = [];
const cache = new Db('cache.json');
const cache = new Db('cache.json', {
saveSpace: true,
});
const baseUrl = 'https://nominatim.openstreetmap.org/';
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,
})
}))
}
});
class Nominatim extends NominatimNoAuth {
class Nominatim {
constructor(userAgent) {
if (!userAgent) throw new Error('');
this.userAgent = `"${userAgent}" Cached 1sDelay ShouldBeCompliant`;
if (!userAgent) throw new Error('Please invoke me with an user agent');
if (!userAgent.includes('@')) throw new Error('Please include contact info in user agent in case your app goes out of control');
userAgent = `"${userAgent}" Cached 1sDelay ShouldBeCompliant https://www.npmjs.com/package/@informath/nominatim`;
const queue = [];

@@ -40,6 +21,37 @@ setInterval(async () => {

if (item) {
cache[url] = await (await fetch(item.url)).json();
item.fn(cache[url]);
console.log(item);
cache[item.url] = await (await fetch(item.url, {
headers: {
'User-Agent': userAgent,
}
})).json();
item.fn(cache[item.url]);
}
}, 1000);
return new Proxy({
default: {
addressdetails: 1,
limit: 10,
format: 'json',
},
}, {
get(obj, prop) {
return (prop === 'default' ? obj.default : ((options, overwriteDefault) => new Promise((res) => {
const url = `${baseUrl}${prop}?${
Object.entries({ ...(overwriteDefault ? {} : obj.default), ...options })
.map(([i, v]) => `${i}=${encodeURIComponent(v)}`)
.join('&')
}`;
if (url in cache) res(cache[url]);
queue.push({
url,
fn: res,
uA: userAgent,
})
})))
},
set(obj, prop, value) {
if (prop === 'default') obj[prop] = value;
}
});
}

@@ -46,0 +58,0 @@ }

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

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

@@ -8,0 +8,0 @@ "type": "git",

@@ -7,4 +7,4 @@ var nominatim = require('..');

nominatim.reverse({ lat: item.lat, lon: item.lon }).then((resultsRev) => {
console.log(resultsRev);
console.log(resultsRev);
});
});

@@ -1,4 +0,5 @@

var nominatim = require('..');
const Nominatim = require('..');
const Client = new Nominatim('Test for https://www.npmjs.com/package/@informath/nominatim <informathemusic@gmail.com>');
nominatim.search({ q: 'Adelaide, 5000, South Australia, Australia'}, true)
Client.search({ q: 'Adelaide, 5000, South Australia, Australia'})
.then((v) => console.log(v));
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