@stryke/convert 0.4.0 → 0.6.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;
@@ -91,7 +102,7 @@ Object.keys(_uint8ArrayToStream).forEach(function (key) {
91
102
  }
92
103
  });
93
104
  });
94
- var _uint8ArrayToString = require("./uint8-array-to-string.cjs");
105
+ var _uint8ArrayToString = require("./uint8-array-to-string.node.cjs");
95
106
  Object.keys(_uint8ArrayToString).forEach(function (key) {
96
107
  if (key === "default" || key === "__esModule") return;
97
108
  if (key in exports && exports[key] === _uint8ArrayToString[key]) return;
package/dist/index.d.ts CHANGED
@@ -11,8 +11,9 @@ 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";
17
- export * from "./uint8-array-to-string";
18
+ export * from "./uint8-array-to-string.node";
18
19
  export * from "./utf8-array-to-string";
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.node";export*from"./utf8-array-to-string";
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _arrayBufferToString = require("./array-buffer-to-string.cjs");
7
+ Object.keys(_arrayBufferToString).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _arrayBufferToString[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _arrayBufferToString[key];
14
+ }
15
+ });
16
+ });
17
+ var _parseTypeDefinition = require("./parse-type-definition.cjs");
18
+ Object.keys(_parseTypeDefinition).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _parseTypeDefinition[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _parseTypeDefinition[key];
25
+ }
26
+ });
27
+ });
28
+ var _stringToUint8Array = require("./string-to-uint8-array.cjs");
29
+ Object.keys(_stringToUint8Array).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _stringToUint8Array[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _stringToUint8Array[key];
36
+ }
37
+ });
38
+ });
39
+ var _stringToUtf8Array = require("./string-to-utf8-array.cjs");
40
+ Object.keys(_stringToUtf8Array).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _stringToUtf8Array[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _stringToUtf8Array[key];
47
+ }
48
+ });
49
+ });
50
+ var _toArray = require("./to-array.cjs");
51
+ Object.keys(_toArray).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _toArray[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _toArray[key];
58
+ }
59
+ });
60
+ });
61
+ var _toStringKey = require("./to-string-key.cjs");
62
+ Object.keys(_toStringKey).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _toStringKey[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _toStringKey[key];
69
+ }
70
+ });
71
+ });
72
+ var _uint8ArrayToStream = require("./uint8-array-to-stream.cjs");
73
+ Object.keys(_uint8ArrayToStream).forEach(function (key) {
74
+ if (key === "default" || key === "__esModule") return;
75
+ if (key in exports && exports[key] === _uint8ArrayToStream[key]) return;
76
+ Object.defineProperty(exports, key, {
77
+ enumerable: true,
78
+ get: function () {
79
+ return _uint8ArrayToStream[key];
80
+ }
81
+ });
82
+ });
83
+ var _uint8ArrayToString = require("./uint8-array-to-string.cjs");
84
+ Object.keys(_uint8ArrayToString).forEach(function (key) {
85
+ if (key === "default" || key === "__esModule") return;
86
+ if (key in exports && exports[key] === _uint8ArrayToString[key]) return;
87
+ Object.defineProperty(exports, key, {
88
+ enumerable: true,
89
+ get: function () {
90
+ return _uint8ArrayToString[key];
91
+ }
92
+ });
93
+ });
94
+ var _utf8ArrayToString = require("./utf8-array-to-string.cjs");
95
+ Object.keys(_utf8ArrayToString).forEach(function (key) {
96
+ if (key === "default" || key === "__esModule") return;
97
+ if (key in exports && exports[key] === _utf8ArrayToString[key]) return;
98
+ Object.defineProperty(exports, key, {
99
+ enumerable: true,
100
+ get: function () {
101
+ return _utf8ArrayToString[key];
102
+ }
103
+ });
104
+ });
@@ -0,0 +1,9 @@
1
+ export * from "./array-buffer-to-string";
2
+ export * from "./parse-type-definition";
3
+ export * from "./string-to-uint8-array";
4
+ export * from "./string-to-utf8-array";
5
+ export * from "./to-array";
6
+ export * from "./to-string-key";
7
+ export * from "./uint8-array-to-stream";
8
+ export * from "./uint8-array-to-string";
9
+ export * from "./utf8-array-to-string";
@@ -0,0 +1 @@
1
+ export*from"./array-buffer-to-string";export*from"./parse-type-definition";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,12 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.base64Uint8ArrayToString = base64Uint8ArrayToString;
7
- exports.uint8ArrayToString = void 0;
8
- var _nodeBuffer = require("node:buffer");
9
- var _arrayBufferToString = require("./array-buffer-to-string.cjs");
10
- const uint8ArrayToString = r => decodeURIComponent(_nodeBuffer.Buffer.from(r).toString("utf8"));
11
6
  exports.uint8ArrayToString = uint8ArrayToString;
12
- function base64Uint8ArrayToString(r) {
7
+ var _arrayBufferToString = require("./array-buffer-to-string.cjs");
8
+ function uint8ArrayToString(r) {
13
9
  return btoa((0, _arrayBufferToString.arrayBufferToString)(r));
14
10
  }
@@ -1,17 +1,7 @@
1
- /**
2
- * Convert a Uint8Array array to string
3
- *
4
- * @see https://stackoverflow.com/a/41798356/1465919
5
- * @see https://stackoverflow.com/a/36949791/1465919
6
- *
7
- * @param arr - Uint8Array to convert
8
- * @returns The converted string
9
- */
10
- export declare const uint8ArrayToString: (arr: Uint8Array) => string;
11
1
  /**
12
2
  * Convert a Uint8Array to a base64 string
13
3
  *
14
4
  * @param buffer - The Uint8Array to convert
15
5
  * @returns The converted base64 string
16
6
  */
17
- export declare function base64Uint8ArrayToString(buffer: Uint8Array): string;
7
+ export declare function uint8ArrayToString(buffer: Uint8Array): string;
@@ -1 +1 @@
1
- import{Buffer as t}from"node:buffer";import{arrayBufferToString as o}from"./array-buffer-to-string";export const uint8ArrayToString=r=>decodeURIComponent(t.from(r).toString("utf8"));export function base64Uint8ArrayToString(r){return btoa(o(r))}
1
+ import{arrayBufferToString as t}from"./array-buffer-to-string";export function uint8ArrayToString(r){return btoa(t(r))}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.uint8ArrayToString = void 0;
7
+ var _nodeBuffer = require("node:buffer");
8
+ const uint8ArrayToString = r => decodeURIComponent(_nodeBuffer.Buffer.from(r).toString("utf8"));
9
+ exports.uint8ArrayToString = uint8ArrayToString;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Convert a Uint8Array array to string
3
+ *
4
+ * @see https://stackoverflow.com/a/41798356/1465919
5
+ * @see https://stackoverflow.com/a/36949791/1465919
6
+ *
7
+ * @param arr - Uint8Array to convert
8
+ * @returns The converted string
9
+ */
10
+ export declare const uint8ArrayToString: (arr: Uint8Array) => string;
@@ -0,0 +1 @@
1
+ import{Buffer as t}from"node:buffer";export const uint8ArrayToString=r=>decodeURIComponent(t.from(r).toString("utf8"));
@@ -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 e = new TextDecoder();
8
+ function utf8ArrayToString(r) {
9
+ return e.decode(r);
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: NodeJS.ArrayBufferView | ArrayBuffer): string;
@@ -1 +1 @@
1
- export const utf8ArrayToString=r=>new TextDecoder().decode(r);
1
+ const e=new TextDecoder;export function utf8ArrayToString(r){return e.decode(r)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/convert",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "A utility package that helps convert between different data types.",
6
6
  "repository": {
@@ -13,7 +13,7 @@
13
13
  "publishConfig": { "access": "public" },
14
14
  "dependencies": {
15
15
  "@stryke/type-checks": "^0.3.9",
16
- "@stryke/types": "^0.8.9"
16
+ "@stryke/types": "^0.9.0"
17
17
  },
18
18
  "sideEffects": false,
19
19
  "files": ["dist/**/*"],
@@ -86,6 +86,20 @@
86
86
  "default": "./dist/uint8-array-to-string.mjs"
87
87
  }
88
88
  },
89
+ "./uint8-array-to-string.node": {
90
+ "import": {
91
+ "types": "./dist/uint8-array-to-string.node.d.ts",
92
+ "default": "./dist/uint8-array-to-string.node.mjs"
93
+ },
94
+ "require": {
95
+ "types": "./dist/uint8-array-to-string.node.d.ts",
96
+ "default": "./dist/uint8-array-to-string.node.cjs"
97
+ },
98
+ "default": {
99
+ "types": "./dist/uint8-array-to-string.node.d.ts",
100
+ "default": "./dist/uint8-array-to-string.node.mjs"
101
+ }
102
+ },
89
103
  "./uint8-array-to-stream": {
90
104
  "import": {
91
105
  "types": "./dist/uint8-array-to-stream.d.ts",
@@ -128,6 +142,20 @@
128
142
  "default": "./dist/to-array.mjs"
129
143
  }
130
144
  },
145
+ "./string-to-utf8-array": {
146
+ "import": {
147
+ "types": "./dist/string-to-utf8-array.d.ts",
148
+ "default": "./dist/string-to-utf8-array.mjs"
149
+ },
150
+ "require": {
151
+ "types": "./dist/string-to-utf8-array.d.ts",
152
+ "default": "./dist/string-to-utf8-array.cjs"
153
+ },
154
+ "default": {
155
+ "types": "./dist/string-to-utf8-array.d.ts",
156
+ "default": "./dist/string-to-utf8-array.mjs"
157
+ }
158
+ },
131
159
  "./string-to-uint8-array": {
132
160
  "import": {
133
161
  "types": "./dist/string-to-uint8-array.d.ts",
@@ -170,6 +198,20 @@
170
198
  "default": "./dist/parse-type-definition.mjs"
171
199
  }
172
200
  },
201
+ "./neutral": {
202
+ "import": {
203
+ "types": "./dist/neutral.d.ts",
204
+ "default": "./dist/neutral.mjs"
205
+ },
206
+ "require": {
207
+ "types": "./dist/neutral.d.ts",
208
+ "default": "./dist/neutral.cjs"
209
+ },
210
+ "default": {
211
+ "types": "./dist/neutral.d.ts",
212
+ "default": "./dist/neutral.mjs"
213
+ }
214
+ },
173
215
  "./index": {
174
216
  "import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
175
217
  "require": {
@@ -219,5 +261,5 @@
219
261
  "main": "./dist/index.cjs",
220
262
  "module": "./dist/index.mjs",
221
263
  "types": "./dist/index.d.ts",
222
- "gitHead": "fdcb844c7710325be3bd12a6eca54556dca05268"
264
+ "gitHead": "73e8ba817597f78f119c7924d64e609e72f158c4"
223
265
  }