opengate-js 10.5.1 → 10.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opengate-js",
3
- "version": "10.5.1",
3
+ "version": "10.5.2",
4
4
  "description": "",
5
5
  "main": "dist/opengate-api-npm.js",
6
6
  "repository": {
@@ -103,12 +103,12 @@ export default class NorthAmpliaREST {
103
103
  * @param {number} timeout - timeout in milliseconds
104
104
  * @param {object} headers - headers of request
105
105
  * @param {object} parameters - parameters of request
106
- * @param {boolean} asBuffer - response body as buffer (Uint8Array)
106
+ * @param {boolean} asBlob - response body as Blob
107
107
  * @return {Promise}
108
108
  */
109
- get(url, timeout, headers, parameters, asBuffer) {
109
+ get(url, timeout, headers, parameters, asBlob) {
110
110
  var req = request.get(this._createUrl(url, parameters));
111
- return this._createPromiseRequest(req, null, timeout, headers, asBuffer);
111
+ return this._createPromiseRequest(req, null, timeout, headers, asBlob);
112
112
  }
113
113
 
114
114
  /**
@@ -259,7 +259,7 @@ export default class NorthAmpliaREST {
259
259
  return returnUrl;
260
260
  }
261
261
 
262
- _createPromiseRequest(req, events, timeout, headers, asBuffer) {
262
+ _createPromiseRequest(req, events, timeout, headers, asBlob) {
263
263
  let _timeout = timeout;
264
264
  if (typeof _timeout === "undefined" || _timeout === null) {
265
265
  _timeout = this._options.timeout;
@@ -287,6 +287,9 @@ export default class NorthAmpliaREST {
287
287
  _req = _req.on(event, events[event]);
288
288
  }
289
289
  }
290
+ if(asBlob){
291
+ req.responseType('blob')
292
+ }
290
293
  _req = _req.end(function(err, res) {
291
294
  if (err !== null) {
292
295
  let data;
@@ -315,29 +318,7 @@ export default class NorthAmpliaREST {
315
318
  'data': data
316
319
  });
317
320
  } else {
318
- if(asBuffer){
319
- var chunks = []
320
- res.on("data", function (chunk) {
321
- chunks.push(chunk);
322
- });
323
-
324
- res.on("end", function (chunk) {
325
- let length = 0
326
-
327
- for(let i = 0; i < chunks.length; i++){
328
- length += chunks[i].length
329
- }
330
- const resultArray = new Uint8Array(length)
331
- let offset = 0
332
-
333
- for(let i = 0; i < chunks.length; i++){
334
- const c = chunks[i]
335
- resultArray.set(c, offset)
336
- offset += c.length
337
- }
338
- res.body = resultArray
339
- });
340
- }
321
+
341
322
  defered.resolve(res);
342
323
  }
343
324
  });
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"mappings":"","sources":["opengate-api-bower.js"],"file":"opengate-api-bower-10.5.1.js","sourceRoot":".."}