@stryke/convert 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -58,6 +58,17 @@ Object.keys(_stringToUint8Array).forEach(function (key) {
58
58
  }
59
59
  });
60
60
  });
61
+ var _stringToUtf8Array = require("./string-to-utf8-array.cjs");
62
+ Object.keys(_stringToUtf8Array).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _stringToUtf8Array[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _stringToUtf8Array[key];
69
+ }
70
+ });
71
+ });
61
72
  var _toArray = require("./to-array.cjs");
62
73
  Object.keys(_toArray).forEach(function (key) {
63
74
  if (key === "default" || key === "__esModule") return;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from "./buffer-to-string";
11
11
  export * from "./parse-type-definition";
12
12
  export * from "./string-to-buffer";
13
13
  export * from "./string-to-uint8-array";
14
+ export * from "./string-to-utf8-array";
14
15
  export * from "./to-array";
15
16
  export * from "./to-string-key";
16
17
  export * from "./uint8-array-to-stream";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export*from"./array-buffer-to-string";export*from"./buffer-to-string";export*from"./parse-type-definition";export*from"./string-to-buffer";export*from"./string-to-uint8-array";export*from"./to-array";export*from"./to-string-key";export*from"./uint8-array-to-stream";export*from"./uint8-array-to-string";export*from"./utf8-array-to-string";
1
+ export*from"./array-buffer-to-string";export*from"./buffer-to-string";export*from"./parse-type-definition";export*from"./string-to-buffer";export*from"./string-to-uint8-array";export*from"./string-to-utf8-array";export*from"./to-array";export*from"./to-string-key";export*from"./uint8-array-to-stream";export*from"./uint8-array-to-string";export*from"./utf8-array-to-string";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stringToUtf8Array = stringToUtf8Array;
7
+ const r = new TextEncoder();
8
+ function stringToUtf8Array(n) {
9
+ return r.encode(n);
10
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Convert a string to a utf-8 array
3
+ *
4
+ * @param input - The string to convert
5
+ * @returns The converted utf-8 array
6
+ */
7
+ export declare function stringToUtf8Array(input: string): Uint8Array;
@@ -0,0 +1 @@
1
+ const r=new TextEncoder;export function stringToUtf8Array(n){return r.encode(n)}
@@ -3,6 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.utf8ArrayToString = void 0;
7
- const utf8ArrayToString = r => new TextDecoder().decode(r);
8
- exports.utf8ArrayToString = utf8ArrayToString;
6
+ exports.utf8ArrayToString = utf8ArrayToString;
7
+ const r = new TextDecoder();
8
+ function utf8ArrayToString(e) {
9
+ return r.decode(e);
10
+ }
@@ -1,10 +1,7 @@
1
1
  /**
2
- * Convert a utf8 array to string
2
+ * Convert a utf-8 array to string
3
3
  *
4
- * @credits https://stackoverflow.com/a/41798356/1465919
5
- * @credits https://stackoverflow.com/a/36949791/1465919
6
- *
7
- * @param arr - Utf-8 Array
4
+ * @param input - Utf-8 Array
8
5
  * @returns The converted string
9
6
  */
10
- export declare const utf8ArrayToString: (arr: Uint8Array) => string;
7
+ export declare function utf8ArrayToString(input: AllowSharedBufferSource): string;
@@ -1 +1 @@
1
- export const utf8ArrayToString=r=>new TextDecoder().decode(r);
1
+ const r=new TextDecoder;export function utf8ArrayToString(e){return r.decode(e)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/convert",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "A utility package that helps convert between different data types.",
6
6
  "repository": {
@@ -128,6 +128,20 @@
128
128
  "default": "./dist/to-array.mjs"
129
129
  }
130
130
  },
131
+ "./string-to-utf8-array": {
132
+ "import": {
133
+ "types": "./dist/string-to-utf8-array.d.ts",
134
+ "default": "./dist/string-to-utf8-array.mjs"
135
+ },
136
+ "require": {
137
+ "types": "./dist/string-to-utf8-array.d.ts",
138
+ "default": "./dist/string-to-utf8-array.cjs"
139
+ },
140
+ "default": {
141
+ "types": "./dist/string-to-utf8-array.d.ts",
142
+ "default": "./dist/string-to-utf8-array.mjs"
143
+ }
144
+ },
131
145
  "./string-to-uint8-array": {
132
146
  "import": {
133
147
  "types": "./dist/string-to-uint8-array.d.ts",
@@ -219,5 +233,5 @@
219
233
  "main": "./dist/index.cjs",
220
234
  "module": "./dist/index.mjs",
221
235
  "types": "./dist/index.d.ts",
222
- "gitHead": "fdcb844c7710325be3bd12a6eca54556dca05268"
236
+ "gitHead": "7331a32032c42269626a48f5011938b82dc80c45"
223
237
  }