@smithy/util-base64
Advanced tools
Comparing version 2.1.1 to 2.2.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toBase64 = void 0; | ||
const util_utf8_1 = require("@smithy/util-utf8"); | ||
const constants_browser_1 = require("./constants.browser"); | ||
function toBase64(input) { | ||
function toBase64(_input) { | ||
let input; | ||
if (typeof _input === "string") { | ||
input = (0, util_utf8_1.fromUtf8)(_input); | ||
} | ||
else { | ||
input = _input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
} | ||
let str = ""; | ||
@@ -7,0 +18,0 @@ for (let i = 0; i < input.length; i += 3) { |
@@ -5,3 +5,16 @@ "use strict"; | ||
const util_buffer_from_1 = require("@smithy/util-buffer-from"); | ||
const toBase64 = (input) => (0, util_buffer_from_1.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
const util_utf8_1 = require("@smithy/util-utf8"); | ||
const toBase64 = (_input) => { | ||
let input; | ||
if (typeof _input === "string") { | ||
input = (0, util_utf8_1.fromUtf8)(_input); | ||
} | ||
else { | ||
input = _input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
} | ||
return (0, util_buffer_from_1.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
}; | ||
exports.toBase64 = toBase64; |
@@ -0,3 +1,14 @@ | ||
import { fromUtf8 } from "@smithy/util-utf8"; | ||
import { alphabetByValue, bitsPerByte, bitsPerLetter, maxLetterValue } from "./constants.browser"; | ||
export function toBase64(input) { | ||
export function toBase64(_input) { | ||
let input; | ||
if (typeof _input === "string") { | ||
input = fromUtf8(_input); | ||
} | ||
else { | ||
input = _input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
} | ||
let str = ""; | ||
@@ -4,0 +15,0 @@ for (let i = 0; i < input.length; i += 3) { |
import { fromArrayBuffer } from "@smithy/util-buffer-from"; | ||
export const toBase64 = (input) => fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
import { fromUtf8 } from "@smithy/util-utf8"; | ||
export const toBase64 = (_input) => { | ||
let input; | ||
if (typeof _input === "string") { | ||
input = fromUtf8(_input); | ||
} | ||
else { | ||
input = _input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-base64: toBase64 encoder function only accepts string | Uint8Array."); | ||
} | ||
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("base64"); | ||
}; |
/** | ||
* Converts a Uint8Array of binary data to a base-64 encoded string. | ||
* Converts a Uint8Array of binary data or a utf-8 string to a base-64 encoded string. | ||
* | ||
* @param input The binary data to encode | ||
* @param _input - the binary data or string to encode. | ||
* @returns base64 string. | ||
* | ||
* @see https://tools.ietf.org/html/rfc4648#section-4 | ||
*/ | ||
export declare function toBase64(input: Uint8Array): string; | ||
export declare function toBase64(_input: Uint8Array | string): string; |
/** | ||
* Converts a Uint8Array of binary data to a base-64 encoded string using | ||
* Converts a Uint8Array of binary data or a utf-8 string to a base-64 encoded string using | ||
* Node.JS's `buffer` module. | ||
* | ||
* @param input The binary data to encode | ||
* @param _input - the binary data or string to encode. | ||
* @returns base64 string. | ||
*/ | ||
export declare const toBase64: (input: Uint8Array) => string; | ||
export declare const toBase64: (_input: Uint8Array | string) => string; |
/** | ||
* Converts a Uint8Array of binary data to a base-64 encoded string. | ||
* Converts a Uint8Array of binary data or a utf-8 string to a base-64 encoded string. | ||
* | ||
* @param input The binary data to encode | ||
* @param _input - the binary data or string to encode. | ||
* @returns base64 string. | ||
* | ||
* @see https://tools.ietf.org/html/rfc4648#section-4 | ||
*/ | ||
export declare function toBase64(input: Uint8Array): string; | ||
export declare function toBase64(_input: Uint8Array | string): string; |
/** | ||
* Converts a Uint8Array of binary data to a base-64 encoded string using | ||
* Converts a Uint8Array of binary data or a utf-8 string to a base-64 encoded string using | ||
* Node.JS's `buffer` module. | ||
* | ||
* @param input The binary data to encode | ||
* @param _input - the binary data or string to encode. | ||
* @returns base64 string. | ||
*/ | ||
export declare const toBase64: (input: Uint8Array) => string; | ||
export declare const toBase64: (_input: Uint8Array | string) => string; |
{ | ||
"name": "@smithy/util-base64", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "A Base64 <-> UInt8Array converter", | ||
@@ -26,2 +26,3 @@ "main": "./dist-cjs/index.js", | ||
"@smithy/util-buffer-from": "^2.1.1", | ||
"@smithy/util-utf8": "^2.2.0", | ||
"tslib": "^2.5.0" | ||
@@ -28,0 +29,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28835
373
3
+ Added@smithy/util-utf8@^2.2.0
+ Added@smithy/util-utf8@2.3.0(transitive)