@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.
- package/dist/buffer-to-string.cjs +4 -3
- package/dist/buffer-to-string.d.ts +1 -1
- package/dist/buffer-to-string.mjs +1 -1
- package/dist/string-to-buffer.cjs +10 -0
- package/dist/string-to-buffer.d.ts +20 -0
- package/dist/string-to-buffer.mjs +1 -0
- package/dist/utf8-array-to-string.d.ts +0 -3
- package/package.json +18 -4
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.bufferToString =
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
exports.bufferToString = bufferToString;
|
|
7
|
+
function bufferToString(r) {
|
|
8
|
+
return r.toString("utf8");
|
|
9
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export function bufferToString(r){return r.toString("utf8")}
|
|
@@ -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")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/convert",
|
|
3
|
-
"version": "0.
|
|
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.
|
|
16
|
-
"@stryke/types": "^0.8.
|
|
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": "
|
|
194
|
+
"gitHead": "366390ec25211fb6b36feed4bf0cffb7713253cb"
|
|
181
195
|
}
|