Created
December 26, 2017 20:49
-
-
Save aynik/6052d753b30760fc466884ead2752271 to your computer and use it in GitHub Desktop.
Nearest city
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const stdin = require('/usr/local/lib/node_modules/get-stdin') | |
const { parseDms } = require('/usr/local/lib/node_modules/dms-conversion') | |
const nearbyCities = require('/usr/local/lib/node_modules/aynik-nearby-cities') | |
const { NEAREST_CITY_DEBUG } = process.env | |
const getNearestCity = (latitude, longitude) => ( | |
((data) => ( | |
NEAREST_CITY_DEBUG | |
? JSON.stringify(data, null, 4) | |
: `${data.name}, ${data.country}` | |
))(nearbyCities({ latitude, longitude })[0]) | |
) | |
stdin().then((str) => process.stdout.write(getNearestCity.apply(null, str.split(',').map(parseDms)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment