Skip to content

Commit 09056da

Browse files
committed
Deno: Buffer.prototype.base64Slice throws error when arguments are omitted
denoland/deno#34286
1 parent 0489081 commit 09056da

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export const _bytesToBase64: bytesToBase64Func = /*@__PURE__*/ (
2222
? (bytes, omitPadding) => Uint8Array.prototype.toBase64.call(bytes, { omitPadding })
2323
: typeof Buffer == 'function' && Buffer.prototype && typeof Buffer.prototype.base64Slice == 'function'
2424
? (bytes, omitPadding) => {
25-
const out = Buffer.prototype.base64Slice.call(bytes) as string // has padding
25+
// Deno: `Buffer.prototype.base64Slice` throws error when arguments are omitted
26+
// https://github.com/denoland/deno/issues/34286
27+
const out = Buffer.prototype.base64Slice.call(bytes, 0, bytes.length) as string // has padding
2628
return omitPadding && out.charCodeAt(out.length - 1) === 61
2729
//@ts-ignore
2830
? out.slice(0, -1 - (out.charCodeAt(out.length - 2) === 61))

0 commit comments

Comments
 (0)