@stryke/convert 0.2.4 → 0.3.1

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.
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.bufferToString = void 0;
7
- const bufferToString = f => f.toString("utf8");
8
- exports.bufferToString = bufferToString;
6
+ exports.bufferToString = bufferToString;
7
+ function bufferToString(r) {
8
+ return r.toString("utf8");
9
+ }
@@ -5,4 +5,4 @@ import type { Buffer } from "node:buffer";
5
5
  * @param buf - The buffer to convert.
6
6
  * @returns The converted string.
7
7
  */
8
- export declare const bufferToString: (buf: Buffer) => string;
8
+ export declare function bufferToString(buf: Buffer | string): string;
@@ -1 +1 @@
1
- export const bufferToString=f=>f.toString("utf8");
1
+ export function bufferToString(r){return r.toString("utf8")}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stringToBuffer = stringToBuffer;
7
+ var _nodeBuffer = require("node:buffer");
8
+ function stringToBuffer(r) {
9
+ return _nodeBuffer.Buffer.from(r, "utf8");
10
+ }
@@ -0,0 +1,20 @@
1
+ import { Buffer } from "node:buffer";
2
+ /**
3
+ * Converts a string to a Buffer.
4
+ *
5
+ * @param str - The string to convert.
6
+ * @returns The converted Buffer.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { stringToBuffer } from "@stryke/convert";
11
+ *
12
+ * const buffer = stringToBuffer("Hello, world!");
13
+ * console.log(buffer); // <Buffer 48 65 6c 6c 6f 2c 20 77 6f 72 6c 64 21>
14
+ * ```
15
+ * @see https://nodejs.org/api/buffer.html#buffer_class_buffer
16
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Buffer
17
+ * @see https://stackoverflow.com/a/41798356/1465919
18
+ *
19
+ */
20
+ export declare function stringToBuffer(str: string): Buffer;
@@ -0,0 +1 @@
1
+ import{Buffer as f}from"node:buffer";export function stringToBuffer(r){return f.from(r,"utf8")}
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * Convert a utf8 array to string
3
3
  *
4
- * @remarks
5
- * This method is part of the {@linkcode Convert} namespace.
6
- *
7
4
  * @credits https://stackoverflow.com/a/41798356/1465919
8
5
  * @credits https://stackoverflow.com/a/36949791/1465919
9
6
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/convert",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "A utility package that helps convert between different data types.",
6
6
  "repository": {
@@ -12,8 +12,8 @@
12
12
  "devDependencies": { "@types/node": "^22.14.0" },
13
13
  "publishConfig": { "access": "public" },
14
14
  "dependencies": {
15
- "@stryke/type-checks": "^0.3.5",
16
- "@stryke/types": "^0.8.5"
15
+ "@stryke/type-checks": "^0.3.6",
16
+ "@stryke/types": "^0.8.6"
17
17
  },
18
18
  "sideEffects": false,
19
19
  "files": ["dist/**/*"],
@@ -128,6 +128,20 @@
128
128
  "default": "./dist/string-to-uint8-array.mjs"
129
129
  }
130
130
  },
131
+ "./string-to-buffer": {
132
+ "import": {
133
+ "types": "./dist/string-to-buffer.d.ts",
134
+ "default": "./dist/string-to-buffer.mjs"
135
+ },
136
+ "require": {
137
+ "types": "./dist/string-to-buffer.d.ts",
138
+ "default": "./dist/string-to-buffer.cjs"
139
+ },
140
+ "default": {
141
+ "types": "./dist/string-to-buffer.d.ts",
142
+ "default": "./dist/string-to-buffer.mjs"
143
+ }
144
+ },
131
145
  "./parse-type-definition": {
132
146
  "import": {
133
147
  "types": "./dist/parse-type-definition.d.ts",
@@ -177,5 +191,5 @@
177
191
  "main": "./dist/index.cjs",
178
192
  "module": "./dist/index.mjs",
179
193
  "types": "./dist/index.d.ts",
180
- "gitHead": "108abe84f9ba3d55f19cc68b8cc5fe52d90b5183"
194
+ "gitHead": "366390ec25211fb6b36feed4bf0cffb7713253cb"
181
195
  }