@bbn/bbn 1.0.324 → 1.0.326
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/dist/fn/ajax/stream.js
CHANGED
|
@@ -36,6 +36,7 @@ export default function stream(url, success, data, failure, abort) {
|
|
|
36
36
|
}
|
|
37
37
|
var aborter = new AbortController();
|
|
38
38
|
var json = '';
|
|
39
|
+
var chrono = bbn.fn.startChrono();
|
|
39
40
|
var loader = fetch(url, {
|
|
40
41
|
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
|
41
42
|
mode: 'cors', // no-cors, *cors, same-origin
|
|
@@ -51,6 +52,7 @@ export default function stream(url, success, data, failure, abort) {
|
|
|
51
52
|
body: JSON.stringify(data || {}) // body data type must match "Content-Type" header
|
|
52
53
|
})
|
|
53
54
|
.then(function (response) {
|
|
55
|
+
bbn.fn.log("RESPONSE IN " + bbn.fn.stopChrono(chrono) + " SECS");
|
|
54
56
|
if (response.body) {
|
|
55
57
|
var reader_1 = response.body.getReader();
|
|
56
58
|
var isFn_1 = isFunction(success);
|
|
@@ -61,6 +63,9 @@ export default function stream(url, success, data, failure, abort) {
|
|
|
61
63
|
// Do something with last chunk of data then exit reader
|
|
62
64
|
_deleteLoader(requestId, data);
|
|
63
65
|
defaultEndLoadingFunction(url, tst, data);
|
|
66
|
+
if (json) {
|
|
67
|
+
throw new Error('Stream ended with data: ' + json);
|
|
68
|
+
}
|
|
64
69
|
return;
|
|
65
70
|
}
|
|
66
71
|
bbn.fn.log(["STREAM SUCCESS IS FN: " + isFn_1]);
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
export default function startChrono(name) {
|
|
12
|
+
if (!name) {
|
|
13
|
+
name = bbn.fn.randomString(20);
|
|
14
|
+
}
|
|
12
15
|
var now = bbn.fn.microtimestamp();
|
|
13
16
|
if (!this.constructor.chronos) {
|
|
14
17
|
Object.defineProperty(this.constructor, 'chronos', {
|
|
@@ -18,5 +21,6 @@ export default function startChrono(name) {
|
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
23
|
this.constructor.chronos[name || 'default'] = now;
|
|
24
|
+
return name;
|
|
21
25
|
}
|
|
22
26
|
;
|