66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
|
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);
|
||
|
|
||
|
// src/index.ts
|
||
|
var src_exports = {};
|
||
|
__export(src_exports, {
|
||
|
fromUtf8: () => fromUtf8,
|
||
|
toUint8Array: () => toUint8Array,
|
||
|
toUtf8: () => toUtf8
|
||
|
});
|
||
|
module.exports = __toCommonJS(src_exports);
|
||
|
|
||
|
// 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");
|
||
|
|
||
|
// 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");
|
||
|
|
||
|
// src/toUtf8.ts
|
||
|
|
||
|
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
|
||
|
});
|
||
|
|