@peculiar/utils
Advanced tools
@@ -31,2 +31,5 @@ "use strict"; | ||
| } | ||
| function normalizeEncodingName(encoding) { | ||
| return encoding.toLowerCase(); | ||
| } | ||
| exports.convert = { | ||
@@ -51,2 +54,5 @@ encode, | ||
| fromString(text, encoding = "utf8") { | ||
| if (normalizeEncodingName(encoding) === "hex") { | ||
| return (0, index_js_1.toArrayBuffer)(index_js_2.hex.decode(text, { allowOddLength: true })); | ||
| } | ||
| return (0, index_js_1.toArrayBuffer)(decode(encoding, text)); | ||
@@ -53,0 +59,0 @@ }, |
@@ -28,2 +28,5 @@ import { toArrayBuffer } from "../bytes/index.js"; | ||
| } | ||
| function normalizeEncodingName(encoding) { | ||
| return encoding.toLowerCase(); | ||
| } | ||
| export const convert = { | ||
@@ -48,2 +51,5 @@ encode, | ||
| fromString(text, encoding = "utf8") { | ||
| if (normalizeEncodingName(encoding) === "hex") { | ||
| return toArrayBuffer(hex.decode(text, { allowOddLength: true })); | ||
| } | ||
| return toArrayBuffer(decode(encoding, text)); | ||
@@ -50,0 +56,0 @@ }, |
+1
-1
| { | ||
| "name": "@peculiar/utils", | ||
| "version": "2.0.2", | ||
| "version": "2.0.3", | ||
| "description": "Modern byte, encoding, converter registry, and PEM utilities for TypeScript projects.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
146759
0.33%3355
0.36%