@bbn/bbn 1.0.326 → 1.0.328

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.
@@ -8,7 +8,8 @@
8
8
  * @param {Object} data The data to send through POST
9
9
  * @param {Function} failure The function to execute if the request goes bad
10
10
  * @param {Function} abort The function to execute if the request is aborted
11
+ * @param {Function} done The function to execute if the request is finished
11
12
  *
12
13
  * @returns {Promise} The Promise created by the generated XHR.
13
14
  */
14
- export default function stream(url: any, success: any, data: any, failure: any, abort: any): any;
15
+ export default function stream(url: any, success: any, data: any, failure: any, abort: any, finished: any): any;
@@ -18,10 +18,11 @@ import arrayBuffer2String from '../convert/arrayBuffer2String.js';
18
18
  * @param {Object} data The data to send through POST
19
19
  * @param {Function} failure The function to execute if the request goes bad
20
20
  * @param {Function} abort The function to execute if the request is aborted
21
+ * @param {Function} done The function to execute if the request is finished
21
22
  *
22
23
  * @returns {Promise} The Promise created by the generated XHR.
23
24
  */
24
- export default function stream(url, success, data, failure, abort) {
25
+ export default function stream(url, success, data, failure, abort, finished) {
25
26
  var requestId = getRequestId(url, data, 'json');
26
27
  var loaderObj = getLoader(requestId);
27
28
  //log("IN AJAX", loaderObj? loaderObj.loader : "NO LOADER")
@@ -52,20 +53,21 @@ export default function stream(url, success, data, failure, abort) {
52
53
  body: JSON.stringify(data || {}) // body data type must match "Content-Type" header
53
54
  })
54
55
  .then(function (response) {
55
- bbn.fn.log("RESPONSE IN " + bbn.fn.stopChrono(chrono) + " SECS");
56
+ bbn.fn.log("RESPONSE IN " + bbn.fn.stopChrono(chrono, true) + " SECS");
56
57
  if (response.body) {
57
58
  var reader_1 = response.body.getReader();
58
59
  var isFn_1 = isFunction(success);
59
60
  reader_1.read().then(function pump(_a) {
60
61
  var done = _a.done, value = _a.value;
61
62
  if (done) {
62
- bbn.fn.log(["STREAM DONE", value, data]);
63
63
  // Do something with last chunk of data then exit reader
64
64
  _deleteLoader(requestId, data);
65
- defaultEndLoadingFunction(url, tst, data);
66
65
  if (json) {
67
66
  throw new Error('Stream ended with data: ' + json);
68
67
  }
68
+ if (finished) {
69
+ finished();
70
+ }
69
71
  return;
70
72
  }
71
73
  bbn.fn.log(["STREAM SUCCESS IS FN: " + isFn_1]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.326",
3
+ "version": "1.0.328",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",