diff options
author | Samrith Shankar <samrith-s@users.noreply.github.com> | 2020-03-20 14:38:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-20 09:38:34 -0400 |
commit | 798904b0f2ed0c7284b67bba2f125f406b5850de (patch) | |
tree | 5aba8d35aa8984aa778c894258bcaed56f1ce17c /cli/js/web/body.ts | |
parent | 35f6e2e45ddb96524a6bdf54b0a6155caa88d5e0 (diff) |
Add require-await lint rule (#4401)
Diffstat (limited to 'cli/js/web/body.ts')
-rw-r--r-- | cli/js/web/body.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cli/js/web/body.ts b/cli/js/web/body.ts index ed21fa0ec..03c35848a 100644 --- a/cli/js/web/body.ts +++ b/cli/js/web/body.ts @@ -306,7 +306,7 @@ export class Body implements domTypes.Body { return JSON.parse(raw); } - public async arrayBuffer(): Promise<ArrayBuffer> { + public arrayBuffer(): Promise<ArrayBuffer> { if ( this._bodySource instanceof Int8Array || this._bodySource instanceof Int16Array || @@ -318,20 +318,24 @@ export class Body implements domTypes.Body { this._bodySource instanceof Float32Array || this._bodySource instanceof Float64Array ) { - return this._bodySource.buffer as ArrayBuffer; + return Promise.resolve(this._bodySource.buffer as ArrayBuffer); } else if (this._bodySource instanceof ArrayBuffer) { - return this._bodySource; + return Promise.resolve(this._bodySource); } else if (typeof this._bodySource === "string") { const enc = new TextEncoder(); - return enc.encode(this._bodySource).buffer as ArrayBuffer; + return Promise.resolve( + enc.encode(this._bodySource).buffer as ArrayBuffer + ); } else if (this._bodySource instanceof ReadableStream) { // @ts-ignore return bufferFromStream(this._bodySource.getReader()); } else if (this._bodySource instanceof FormData) { const enc = new TextEncoder(); - return enc.encode(this._bodySource.toString()).buffer as ArrayBuffer; + return Promise.resolve( + enc.encode(this._bodySource.toString()).buffer as ArrayBuffer + ); } else if (!this._bodySource) { - return new ArrayBuffer(0); + return Promise.resolve(new ArrayBuffer(0)); } throw new Error( `Body type not yet implemented: ${this._bodySource.constructor.name}` |