UNPKG

@aws-amplify/storage

Version:

Storage category of aws-amplify

20 lines (18 loc) 676 B
'use strict'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 Object.defineProperty(exports, "__esModule", { value: true }); exports.toBase64 = void 0; /** * Client-side `toBase64` implementation for browsers: uses `btoa` + * `TextEncoder`. */ const toBase64 = input => { const bytes = typeof input === 'string' ? new TextEncoder().encode(input) : new Uint8Array(input.buffer, input.byteOffset, input.byteLength); const base64Str = Array.from(bytes, x => String.fromCodePoint(x)).join(''); return btoa(base64Str); }; exports.toBase64 = toBase64; //# sourceMappingURL=toBase64.js.map