You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@smithy/util-utf8

Package Overview
Dependencies
Maintainers
3
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/util-utf8 - npm Package Compare versions

Comparing version
4.1.0
to
4.2.0
+27
-60
dist-cjs/index.js

@@ -1,65 +0,32 @@

var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
'use strict';
// src/index.ts
var index_exports = {};
__export(index_exports, {
fromUtf8: () => fromUtf8,
toUint8Array: () => toUint8Array,
toUtf8: () => toUtf8
});
module.exports = __toCommonJS(index_exports);
var utilBufferFrom = require('@smithy/util-buffer-from');
// src/fromUtf8.ts
var import_util_buffer_from = require("@smithy/util-buffer-from");
var fromUtf8 = /* @__PURE__ */ __name((input) => {
const buf = (0, import_util_buffer_from.fromString)(input, "utf8");
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}, "fromUtf8");
const fromUtf8 = (input) => {
const buf = utilBufferFrom.fromString(input, "utf8");
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength / Uint8Array.BYTES_PER_ELEMENT);
};
// src/toUint8Array.ts
var toUint8Array = /* @__PURE__ */ __name((data) => {
if (typeof data === "string") {
return fromUtf8(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
}, "toUint8Array");
const toUint8Array = (data) => {
if (typeof data === "string") {
return fromUtf8(data);
}
if (ArrayBuffer.isView(data)) {
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
}
return new Uint8Array(data);
};
// src/toUtf8.ts
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 utilBufferFrom.fromArrayBuffer(input.buffer, input.byteOffset, input.byteLength).toString("utf8");
};
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:
0 && (module.exports = {
fromUtf8,
toUint8Array,
toUtf8
});
exports.fromUtf8 = fromUtf8;
exports.toUint8Array = toUint8Array;
exports.toUtf8 = toUtf8;
{
"name": "@smithy/util-utf8",
"version": "4.1.0",
"version": "4.2.0",
"description": "A UTF-8 string <-> UInt8Array converter",

@@ -27,3 +27,3 @@ "main": "./dist-cjs/index.js",

"dependencies": {
"@smithy/util-buffer-from": "^4.1.0",
"@smithy/util-buffer-from": "^4.2.0",
"tslib": "^2.6.2"

@@ -30,0 +30,0 @@ },

module.exports = require("./index.js");
module.exports = require("./index.js");
module.exports = require("./index.js");
module.exports = require("./index.js");
module.exports = require("./index.js");