blobReadingMethods
Prefer direct Blob reading methods over wrapping in Response for simpler code.
✅ This rule is included in the nodestylisticandstylisticStrictpresets.
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.
Examples
Section titled “Examples”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();const const text: any
text = await const blob: any
blob.any
text();
const const arrayBuffer: any
arrayBuffer = await const blob: any
blob.any
arrayBuffer();
const const bytes: any
bytes = await const blob: any
blob.any
bytes();Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If you need to use Response-specific functionality while reading the Blob data, you might choose not to enable this rule.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 around the world by
the Flint team and contributors.