New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@idearium/fetch

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idearium/fetch - npm Package Compare versions

Comparing version 3.0.0-beta.3 to 3.0.0-beta.4

37

index.js
'use strict';
const parseBody = async (response, opts) => {
const decoder = new TextDecoder('utf-8', { fatal: true });
const body = [];
const isObjectMode = opts?.objectMode || false;
const parseBody = async (response) => {
const decoder = new TextDecoderStream('utf-8', { fatal: true });
let body = '';
for await (const chunk of response.body) {
const value = decoder.decode(chunk);
if (value.match(/\n/)) {
body.push(...value.split('\n').filter((val) => val.length));
}
if (!value.match(/\n/)) {
body.push(value);
}
for await (const chunk of response.body.pipeThrough(decoder)) {
body += chunk;
}
if (isObjectMode) {
return body.length > 1
? body.map((chunk) => JSON.parse(chunk))
: JSON.parse(body[0]);
}
if (

@@ -30,9 +15,9 @@ response.headers.get('Content-Type').includes('application/json') &&

) {
return JSON.parse(body.join(''));
return JSON.parse(body);
}
return body.join('');
return body;
};
const parseResponse = async (response, opts) => {
const parseResponse = async (response) => {
if (

@@ -46,3 +31,3 @@ response.headers &&

) {
response.result = await parseBody(response, opts);
response.result = await parseBody(response);
}

@@ -53,3 +38,3 @@

const fetchApi = async (url, fetchOptions = {}, opts = {}) => {
const fetchApi = async (url, fetchOptions = {}) => {
const headers = {};

@@ -71,5 +56,5 @@

return await parseResponse(response, opts);
return await parseResponse(response);
};
module.exports = fetchApi;

@@ -19,3 +19,3 @@ {

},
"version": "3.0.0-beta.3"
"version": "3.0.0-beta.4"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc