From 664ab251643b49e57ebb6fd895df26c568d33334 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Fri, 9 Aug 2013 18:37:11 -0400 Subject: [PATCH] added ignoreErrors option --- README.md | 1 + index.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e10917..9caa18b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ Create a readable stream that emits nearby places. Possible options are: * `timeout (Number)`: Give up finding the current position after x miliseconds +* `ignoreErrors (Boolean)`: If true, when a geolocation error happens, an empty position will be used. * plus all the options from [places#createReadStream](https://github.com/Wayla/level-places#placescreatereadstream-latitude-longitude--options) * plus all the options from [trie#createSearchStream](https://github.com/juliangruber/level-trie#triecreatesearchstreamstring-options) diff --git a/index.js b/index.js index 527c554..00cda6b 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,8 @@ function createNearbyStream (places, opts) { var tmp = tmpStream(); getPosition(opts, function (err, pos) { - if (err) return tmp.emit('error', err); + if (err && !opts.ignoreErrors) return tmp.emit('error', err); + if (!pos) pos = {}; tmp.emit('position', pos); var nearby = places.createReadStream(pos, opts);