Skip to content

Commit

Permalink
Use es6 defaults when possible
Browse files Browse the repository at this point in the history
Change-type: squash
Signed-off-by: Thodoris Greasidis <[email protected]>
  • Loading branch information
thgreasi committed Feb 9, 2021
1 parent ab6cca9 commit 57e35be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 1 addition & 5 deletions lib/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,12 @@ export interface BalenaRequestPassThroughStream extends Stream.PassThrough {
* console.log(state)
*/
export function estimate(
requestAsync?: ReturnType<typeof getRequestAsync>,
requestAsync: ReturnType<typeof getRequestAsync> = utils.getRequestAsync(),
isBrowser?: boolean,
) {
return async function (
options: BalenaRequestOptions,
): Promise<BalenaRequestPassThroughStream> {
if (requestAsync == null) {
requestAsync = utils.getRequestAsync();
}

options.gzip = false;
options.headers!['Accept-Encoding'] = 'gzip, deflate';

Expand Down
8 changes: 3 additions & 5 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,9 @@ const processRequestOptions = function (options: BalenaRequestOptions) {
url += (url.indexOf('?') >= 0 ? '&' : '?') + params;
}

let { body, headers } = options;
if (headers == null) {
headers = {} as Record<string, string>;
}
if (options.json && body) {
let { body } = options;
const { headers = {}, json } = options;
if (json && body) {
body = JSON.stringify(body);
headers['Content-Type'] = 'application/json';
}
Expand Down

0 comments on commit 57e35be

Please sign in to comment.