Skip to content

Commit

Permalink
tests: move to jest (#19)
Browse files Browse the repository at this point in the history
* tests: move to jest

- also fixes security deps
- replace eslint with standard

* fix: add engines

* chore: update keywords
  • Loading branch information
VikramTiwari authored Aug 15, 2019
1 parent 71c38d1 commit accc236
Show file tree
Hide file tree
Showing 7 changed files with 1,538 additions and 1,102 deletions.
13 changes: 0 additions & 13 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js:
- '8'
- '10'
- '12'
File renamed without changes.
15 changes: 13 additions & 2 deletions lib/haversine.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
// inspired from package haversine originally By Nick Justice (niix) at https://github.com/niix/haversine
function toRadian(num) {

/**
* converts a number to radian value
* @param {number} num a number
*/
function toRadian (num) {
return (num * Math.PI) / 180
}

function distance(start, end, options = {}) {
/**
* finds the distance between two lat-long values
* @param {object} start start lat-long
* @param {object} end end lat-long
* @param {object} options any options
*/
function distance (start, end, options = {}) {
// init constants
const km = 6371
const mile = 3960
Expand Down
6 changes: 3 additions & 3 deletions lib/reverse-geocode.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const haversine = require('./haversine')

/**
* iterates over locations to find closest location to given input lat-lon values
* iterates over locations to find closest location to given input lat-long values
* @param {Number} latitude latitude value
* @param {Number} longitude longitude value
* @param {String} countryCode Country Code. Should exist in /locations/{countryCode}.json
* @return {Object} city data in an object
*/
function lookup(latitude, longitude, countryCode) {
function lookup (latitude, longitude, countryCode) {
let minDistance = Infinity
let city = {}

Expand All @@ -17,7 +17,7 @@ function lookup(latitude, longitude, countryCode) {
// iterate through all locations
try {
const otherCountryOrigin = require(`../locations/${countryCode}.json`)
otherCountryOrigin.forEach((location) => {
otherCountryOrigin.forEach(location => {
const distance = haversine.distance(start, location)
if (distance < minDistance) {
city = location
Expand Down
Loading

0 comments on commit accc236

Please sign in to comment.