Skip to content

Commit

Permalink
Minor tweaks for ESM strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 20, 2022
1 parent 73501b6 commit 6c7ebab
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions benchmark/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {URL} from 'node:url';
import https from 'node:https';
import axios from 'axios';
/// import axios from 'axios';
import Benchmark from 'benchmark';
import fetch from 'node-fetch';
import request from 'request';
Expand Down Expand Up @@ -41,18 +41,18 @@ const fetchOptions = {
agent: httpsAgent,
};

const axiosOptions = {
url: urlString,
httpsAgent,
https: {
rejectUnauthorized: false,
},
};
/// const axiosOptions = {
// url: urlString,
// httpsAgent,
// https: {
// rejectUnauthorized: false,
// },
// };

const axiosStreamOptions: typeof axiosOptions & {responseType: 'stream'} = {
...axiosOptions,
responseType: 'stream',
};
// const axiosStreamOptions: typeof axiosOptions & {responseType: 'stream'} = {
// ...axiosOptions,
// responseType: 'stream',
// };

const httpsOptions = {
https: {
Expand Down Expand Up @@ -136,19 +136,23 @@ suite.add('got - promise', {
}).add('axios - promise', {
defer: true,
async fn(deferred: {resolve: () => void}) {
await axios.request(axiosOptions);
// Disabled until it has correct types.
// await axios.request(axiosOptions);
deferred.resolve();
},
}).add('axios - stream', {
defer: true,
async fn(deferred: {resolve: () => void}) {
const result = await axios.request(axiosStreamOptions);
const {data}: any = result;
// Disabled until it has correct types.
// const result = await axios.request(axiosStreamOptions);
// const {data}: any = result;

data.resume();
data.once('end', () => {
deferred.resolve();
});
// data.resume();
// data.once('end', () => {
// deferred.resolve();
// });

deferred.resolve();
},
}).add('https - stream', {
defer: true,
Expand Down

0 comments on commit 6c7ebab

Please sign in to comment.