diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-11 19:30:43 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-11 19:50:09 +0300 |
commit | 0b0a8ac278fe3e06f939e0e8052be1ec9ccc050b (patch) | |
tree | b6a769529f3370a5bea5ce35a5af8932adacedc6 | |
parent | 236ddf564fd9f890e558a72010c175996499279d (diff) | |
download | qtlocation-mapboxgl-0b0a8ac278fe3e06f939e0e8052be1ec9ccc050b.tar.gz |
[node] Remove the JavaScript shim
This was need because of a hack on how network requests
were replied.
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | platform/node/index.js | 31 | ||||
-rw-r--r-- | platform/node/test/benchmark.js | 2 | ||||
-rw-r--r-- | platform/node/test/js/map.test.js | 6 | ||||
-rw-r--r-- | platform/node/test/memory.test.js | 2 | ||||
-rw-r--r-- | platform/node/test/suite_implementation.js | 2 |
6 files changed, 6 insertions, 39 deletions
diff --git a/package.json b/package.json index e428a0db43..219ccabe01 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "mapbox", "gl" ], - "main": "platform/node/index.js", + "main": "lib/mapbox_gl_native.node", "repository": { "type": "git", "url": "git://github.com/mapbox/mapbox-gl-native.git" diff --git a/platform/node/index.js b/platform/node/index.js deleted file mode 100644 index 54ba5c0dc6..0000000000 --- a/platform/node/index.js +++ /dev/null @@ -1,31 +0,0 @@ -"use strict"; - -// Shim to wrap req.respond while preserving callback-passing API - -var mbgl = require('../../lib/mapbox_gl_native.node'); -var constructor = mbgl.Map.prototype.constructor; - -var Map = function(options) { - if (!(options instanceof Object)) { - throw TypeError("Requires an options object as first argument"); - } - - if (!options.hasOwnProperty('request') || !(options.request instanceof Function)) { - throw TypeError("Options object must have a 'request' method"); - } - - var request = options.request; - - return new constructor(Object.assign(options, { - request: function(req) { - request(req, function() { - req.respond.apply(req, arguments); - }); - } - })); -}; - -Map.prototype = mbgl.Map.prototype; -Map.prototype.constructor = Map; - -module.exports = Object.assign(mbgl, { Map: Map }); diff --git a/platform/node/test/benchmark.js b/platform/node/test/benchmark.js index 50f6353bca..223ac4f7b7 100644 --- a/platform/node/test/benchmark.js +++ b/platform/node/test/benchmark.js @@ -1,7 +1,7 @@ 'use strict'; var mockfs = require('./mockfs'); -var mbgl = require('../index'); +var mbgl = require('../../../lib/mapbox_gl_native'); var test = require('tape'); var firstRequest = "mapbox://sprites/mapbox/streets-v9@2x.json"; diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js index 04d02d0558..286b0bd01e 100644 --- a/platform/node/test/js/map.test.js +++ b/platform/node/test/js/map.test.js @@ -1,15 +1,13 @@ 'use strict'; var test = require('tape'); -var mbgl = require('../../index'); +var mbgl = require('../../../../lib/mapbox_gl_native'); var fs = require('fs'); var path = require('path'); var style = require('../fixtures/style.json'); test('Map', function(t) { - // This test is skipped because of the req.respond shim in index.js - // which will always call new mbgl.Map() - t.skip('must be constructed with new', function(t) { + t.test('must be constructed with new', function(t) { t.throws(function() { mbgl.Map(); }, /Use the new operator to create new Map objects/); diff --git a/platform/node/test/memory.test.js b/platform/node/test/memory.test.js index 997ccdbbe1..717ac2c5cb 100644 --- a/platform/node/test/memory.test.js +++ b/platform/node/test/memory.test.js @@ -1,7 +1,7 @@ 'use strict'; var mockfs = require('./mockfs'); -var mbgl = require('../index'); +var mbgl = require('../../../lib/mapbox_gl_native'); var test = require('tape'); var testParams = { diff --git a/platform/node/test/suite_implementation.js b/platform/node/test/suite_implementation.js index b717ecd2b2..14d2e8a6e9 100644 --- a/platform/node/test/suite_implementation.js +++ b/platform/node/test/suite_implementation.js @@ -1,6 +1,6 @@ 'use strict'; -var mbgl = require('../index'); +var mbgl = require('../../../lib/mapbox_gl_native'); var request = require('request'); var PNG = require('pngjs').PNG; var fs = require('fs'); |