From e59384e53b306127bca01aec3b00e90262f495c3 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 26 Apr 2017 23:39:02 +0200 Subject: [PATCH] request-promise -> node-fetch --- README.md | 2 +- package.json | 3 +-- src/TileSource.coffee | 8 +++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 85e0a20..53a8be8 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ If your terminal supports mouse events you can drag the map and use your scroll #### Handling the flow * [`bluebird`](https://github.com/petkaantonov/bluebird) for all the asynchronous [Promise](https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Promise) magic -* [`request-promise`](https://github.com/request/request-promise) for promisified HTTP request handling +* [`node-fetch`](https://github.com/bitinn/node-fetch) for HTTP requests * [`userhome`](https://github.com/shama/userhome) to determine where to persist downloaded tiles ### TODOs diff --git a/package.json b/package.json index e0d744a..50631d4 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,9 @@ "coffee-script": "^1.10.0", "earcut": "^2.1.1", "keypress": "^0.2.1", + "node-fetch": "^1.6.3", "pbf": "^3.0.0", "rbush": "^2.0.1", - "request": "^2.76.0", - "request-promise": "^4.1.1", "simplify-js": "^1.2.1", "term-mouse": "^0.1.1", "userhome": "^1.0.0", diff --git a/src/TileSource.coffee b/src/TileSource.coffee index 2233d71..b30485f 100644 --- a/src/TileSource.coffee +++ b/src/TileSource.coffee @@ -9,8 +9,7 @@ Promise = require 'bluebird' userhome = require 'userhome' -request = require 'request' -rp = require 'request-promise' +fetch = require 'node-fetch' fs = require 'fs' Tile = require './Tile' @@ -77,9 +76,8 @@ module.exports = class TileSource if config.persistDownloadedTiles and tile = @_getPersited z, x, y Promise.resolve tile else - rp - uri: @source+[z,x,y].join("/")+".pbf" - encoding: null + fetch @source+[z,x,y].join("/")+".pbf" + .then (res) => res.buffer() .then (buffer) => @_persistTile z, x, y, buffer if config.persistDownloadedTiles buffer