Skip to content

blobReadingMethods

Prefer direct Blob reading methods over wrapping in Response for simpler code.

✅ This rule is included in the node stylistic and stylisticStrict presets.

Direct Blob methods are simpler and more direct than wrapping the Blob in a Response object. The Response wrapper adds unnecessary complexity when the Blob already provides the needed methods.

const
const text: string
text
= await new
var Response: new (body?: BodyInit, init?: ResponseInit) => Response
Response
(
const blob: any
blob
).
BodyMixin.text: () => Promise<string>
text
();
const
const arrayBuffer: ArrayBuffer
arrayBuffer
= await new
var Response: new (body?: BodyInit, init?: ResponseInit) => Response
Response
(
const blob: any
blob
).
BodyMixin.arrayBuffer: () => Promise<ArrayBuffer>
arrayBuffer
();
const
const bytes: Uint8Array<ArrayBufferLike>
bytes
= await new
var Response: new (body?: BodyInit, init?: ResponseInit) => Response
Response
(
const blob: any
blob
).
BodyMixin.bytes: () => Promise<Uint8Array>
bytes
();

This rule is not configurable.

If you need to use Response-specific functionality while reading the Blob data, you might choose not to enable this rule.

Made with ❤️‍🔥 around the world by the Flint team and contributors.