Skip to content

Commit

Permalink
Allow web workers to stream fetching in several formats (#26)
Browse files Browse the repository at this point in the history
* Allow web workers to stream fetching in several formats

* Fix package-lock.json
  • Loading branch information
josemestebandevo committed Oct 10, 2022
1 parent cd40882 commit ee6a2d3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Change log.

## 3.0.5

Make streamFetch available to web workers (since they are not considered as a browser, they have no window object)
Allowed to set output format in stream calls.

## 3.0.4

Fix(node-fetch): wd 11834 fix node fetch vulnerability
Expand Down
8 changes: 5 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ class Client {
* - abort: Function to call when query is aborted
*/
streamFetch(options, callbacks) {
const opc = this._config.parseQuery(options, 'json/simple/compact');
const opc = this._config.parseQuery(options,
options.format || 'json/simple/compact');
const validOpc = validateOpc(opc, callbacks);
return validOpc === true ? streamFetch.create(options).stream(opc, callbacks) : validOpc;
return validOpc === true ?
streamFetch.create(options).stream(opc, callbacks) : validOpc;
}

/**
Expand Down Expand Up @@ -170,4 +172,4 @@ const validateOpc = (opc, callbacks) => {
}
}
return true;
};
};
3 changes: 3 additions & 0 deletions lib/fetchStreamReadable/polyfills/fetchPolyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function getFetchMethod() {
}
return window.fetch.bind(window);
}
if (typeof fetch === 'function') {
return fetch;
}
}

function isNativeStreamFetchSupported() {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devoinc/browser-sdk",
"version": "3.0.4",
"version": "3.0.5",
"description": "Devo browser SDK",
"author": "Devo Dev Team",
"eslintConfig": {
Expand Down

0 comments on commit ee6a2d3

Please sign in to comment.