Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bare-fetch

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bare-fetch - npm Package Compare versions

Comparing version 2.1.0 to 2.1.1

16

lib/body.js

@@ -1,2 +0,2 @@

const { ReadableStream } = require('bare-stream/web')
const { ReadableStream, isReadableStreamDisturbed } = require('bare-stream/web')
const errors = require('./errors')

@@ -8,3 +8,2 @@

this.body = null
this.bodyUsed = false

@@ -25,9 +24,16 @@ if (typeof body === 'string') body = Buffer.from(body)

// https://fetch.spec.whatwg.org/#dom-body-bodyused
get bodyUsed() {
return this.body !== null && isReadableStreamDisturbed(this.body)
}
async buffer() {
if (this.body === null) {
throw errors.BODY_UNUSABLE('Body is unset')
}
if (this.bodyUsed) {
throw errors.BODY_ALREADY_CONSUMED('Body has already been consumed')
throw errors.BODY_UNUSABLE('Body has already been consumed')
}
this.bodyUsed = true
const chunks = []

@@ -34,0 +40,0 @@ let length = 0

@@ -35,9 +35,5 @@ module.exports = class FetchError extends Error {

static BODY_ALREADY_CONSUMED(msg) {
return new FetchError(
msg,
'BODY_ALREADY_CONSUMED',
FetchError.BODY_ALREADY_CONSUMED
)
static BODY_UNUSABLE(msg) {
return new FetchError(msg, 'BODY_UNUSABLE', FetchError.BODY_UNUSABLE)
}
}
{
"name": "bare-fetch",
"version": "2.1.0",
"version": "2.1.1",
"description": "WHATWG Fetch implementation for Bare",

@@ -5,0 +5,0 @@ "exports": {

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