@smithy/util-utf8
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -49,3 +49,11 @@ var __defProp = Object.defineProperty; | ||
var toUtf8 = /* @__PURE__ */ __name((input) => (0, import_util_buffer_from.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("utf8"), "toUtf8"); | ||
var toUtf8 = /* @__PURE__ */ __name((input) => { | ||
if (typeof input === "string") { | ||
return input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
} | ||
return (0, import_util_buffer_from.fromArrayBuffer)(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
}, "toUtf8"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -52,0 +60,0 @@ |
@@ -1,1 +0,9 @@ | ||
export const toUtf8 = (input) => new TextDecoder("utf-8").decode(input); | ||
export const toUtf8 = (input) => { | ||
if (typeof input === "string") { | ||
return input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
} | ||
return new TextDecoder("utf-8").decode(input); | ||
}; |
import { fromArrayBuffer } from "@smithy/util-buffer-from"; | ||
export const toUtf8 = (input) => fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
export const toUtf8 = (input) => { | ||
if (typeof input === "string") { | ||
return input; | ||
} | ||
if (typeof input !== "object" || typeof input.byteOffset !== "number" || typeof input.byteLength !== "number") { | ||
throw new Error("@smithy/util-utf8: toUtf8 encoder function only accepts string | Uint8Array."); | ||
} | ||
return fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8"); | ||
}; |
@@ -1,1 +0,7 @@ | ||
export declare const toUtf8: (input: Uint8Array) => string; | ||
/** | ||
* | ||
* This does not convert non-utf8 strings to utf8, it only passes through strings if | ||
* a string is received instead of a Uint8Array. | ||
* | ||
*/ | ||
export declare const toUtf8: (input: Uint8Array | string) => string; |
@@ -1,1 +0,7 @@ | ||
export declare const toUtf8: (input: Uint8Array) => string; | ||
/** | ||
* | ||
* This does not convert non-utf8 strings to utf8, it only passes through strings if | ||
* a string is received instead of a Uint8Array. | ||
* | ||
*/ | ||
export declare const toUtf8: (input: Uint8Array | string) => string; |
@@ -1,1 +0,7 @@ | ||
export declare const toUtf8: (input: Uint8Array) => string; | ||
/** | ||
* | ||
* This does not convert non-utf8 strings to utf8, it only passes through strings if | ||
* a string is received instead of a Uint8Array. | ||
* | ||
*/ | ||
export declare const toUtf8: (input: Uint8Array | string) => string; |
@@ -1,1 +0,7 @@ | ||
export declare const toUtf8: (input: Uint8Array) => string; | ||
/** | ||
* | ||
* This does not convert non-utf8 strings to utf8, it only passes through strings if | ||
* a string is received instead of a Uint8Array. | ||
* | ||
*/ | ||
export declare const toUtf8: (input: Uint8Array | string) => string; |
{ | ||
"name": "@smithy/util-utf8", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "A UTF-8 string <-> UInt8Array converter", | ||
@@ -5,0 +5,0 @@ "main": "./dist-cjs/index.js", |
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
19355
136