Comparing version 2.0.0 to 2.0.1
@@ -33,11 +33,16 @@ 'use strict'; | ||
} | ||
for (const item of data) { | ||
data.forEach(item => { | ||
let g; | ||
if (opts.hash) { | ||
g = get(item, opts.hash); | ||
} | ||
g = g || geohash.encode_int(get(item, opts.lat), get(item, opts.lon)); | ||
geo.push({ | ||
i: get(item, opts.id), | ||
g: get(item, opts.hash) || geohash.encode_int(get(item, opts.lat), get(item, opts.lon)) | ||
g | ||
}); | ||
} | ||
}); | ||
} else if (isGeoJSON(data)) { | ||
const features = getFeatureCollection(data); | ||
for (const feature of features) { | ||
features.forEach(feature => { | ||
const geometry = feature.geometry; | ||
@@ -52,3 +57,3 @@ const coords = getCoords(geometry); | ||
} | ||
} | ||
}); | ||
} else { | ||
@@ -132,9 +137,10 @@ throw new TypeError('data must be correct JSON or GeoJSON'); | ||
for (const item of data) { | ||
const value = item[hash]; | ||
if (value >= min && value <= max) { | ||
// eslint-disable-next-line no-var, vars-on-top | ||
for (var i = 0; i < length; i++) { // Low performance when use "let" in "for" loop - https://bugs.chromium.org/p/v8/issues/detail?id=4762 | ||
const value = data[i]; | ||
if (value[hash] >= min && value[hash] <= max) { | ||
if (limit && result.length >= limit) { | ||
return result; | ||
} | ||
result.push(item); | ||
result.push(value); | ||
} | ||
@@ -148,4 +154,4 @@ } | ||
let replies = []; | ||
for (const range of ranges) { | ||
for (let i = 0; i < ranges.length; i++) { | ||
const range = ranges[i]; | ||
const replie = searchBetween(data, range.lower, range.upper, limit); | ||
@@ -152,0 +158,0 @@ if (replie.length) { |
@@ -79,4 +79,5 @@ 'use strict'; | ||
if (isArray(path)) { | ||
for (const value of path) { | ||
object = object[value]; | ||
// eslint-disable-next-line no-var, vars-on-top | ||
for (var i = 0; i < path.length; i++) { // Low performance when use "let" in "for" loop - https://bugs.chromium.org/p/v8/issues/detail?id=4762 | ||
object = object[path[i]]; | ||
} | ||
@@ -94,3 +95,4 @@ | ||
for (const value of rangeIndex) { | ||
for (let i = 0; i < rangeIndex.length; i++) { | ||
const value = rangeIndex[i]; | ||
if (value >= min && value < max) { | ||
@@ -97,0 +99,0 @@ result.push(value); |
{ | ||
"name": "geo-nearby", | ||
"author": "Alexey Bystrov <strikeentco@gmail.com>", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Uber fast nearby locations search by coordinates. Supports GeoJSON.", | ||
@@ -49,9 +49,9 @@ "engines": { | ||
"eslint-config-airbnb": "^9.0.1", | ||
"eslint-plugin-import": "^1.11.0", | ||
"eslint-plugin-import": "^1.13.0", | ||
"eslint-plugin-jsx-a11y": "^1.2.0", | ||
"eslint-plugin-react": "^5.1.1", | ||
"mocha": "^2.5.3", | ||
"should": "^10.0.0" | ||
"mocha": "^3.0.2", | ||
"should": "^11.0.0" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -1,2 +0,2 @@ | ||
geo-nearby [![License](https://img.shields.io/github/license/strikeentco/geo-nearby.svg)](https://github.com/strikeentco/geo-nearby/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/geo-nearby.svg)](https://www.npmjs.com/package/geo-nearby) | ||
geo-nearby [![License](https://img.shields.io/npm/l/geo-nearby.svg)](https://github.com/strikeentco/geo-nearby/blob/master/LICENSE) [![npm](https://img.shields.io/npm/v/geo-nearby.svg)](https://www.npmjs.com/package/geo-nearby) | ||
========== | ||
@@ -241,3 +241,3 @@ [![Build Status](https://travis-ci.org/strikeentco/geo-nearby.svg)](https://travis-ci.org/strikeentco/geo-nearby) [![node](https://img.shields.io/node/v/geo-nearby.svg)](https://www.npmjs.com/package/geo-nearby) [![Test Coverage](https://codeclimate.com/github/strikeentco/geo-nearby/badges/coverage.svg)](https://codeclimate.com/github/strikeentco/geo-nearby/coverage) [![bitHound Score](https://www.bithound.io/github/strikeentco/geo-nearby/badges/score.svg)](https://www.bithound.io/github/strikeentco/geo-nearby) | ||
* **setOptions** (*Object*) - Options from [createCompactSet](#createcompactsetdataset-options): | ||
* **hash** (*String|Array*) - Key (name|path) (by default = 'g') | ||
* **hash** (*String|Array*) - Key (name|path) (by default inherits `hash` from above) | ||
* **id** (*String|Array*) - Key (name|path) (by default = 2) | ||
@@ -290,3 +290,3 @@ * **lat** (*String|Array*) - Key (name|path) (by default = 0) | ||
* **[options]** (*Object*) - Options: | ||
* **hash** (*String|Array*) - Key (name|path) (by default = 'g') | ||
* **hash** (*String|Array*) - Key (name|path) | ||
* **id** (*String|Array*) - Key (name|path) (by default = 2) | ||
@@ -293,0 +293,0 @@ * **lat** (*String|Array*) - Key (name|path) (by default = 0) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23672
411
0