Socket
Socket
Sign inDemoInstall

@smithy/util-base64

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/util-base64 - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

13

dist-cjs/toBase64.browser.js
"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");
};

7

dist-types/toBase64.browser.d.ts
/**
* 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 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc