@kikiutils/shared 10.4.0 → 11.0.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/README.md +1 -1
- package/dist/buffer.cjs.map +1 -1
- package/dist/buffer.d.ts +2 -1
- package/dist/buffer.d.ts.map +1 -1
- package/dist/buffer.mjs.map +1 -1
- package/package.json +3 -3
- package/src/buffer.ts +5 -1
package/README.md
CHANGED
package/dist/buffer.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.cjs","sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: Blob | Buffer | File) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"names":["Buffer"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"buffer.cjs","sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport type {\n Blob as NodeBlob,\n File as NodeFile,\n} from 'node:buffer';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"names":["Buffer"],"mappings":";;;;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,QAAQ,CAAC,KAAiD,EAAA;AAC5E,IAAA,IAAIA,kBAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;IACxC,OAAOA,kBAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;AACjD;;;;"}
|
package/dist/buffer.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
|
+
import type { Blob as NodeBlob, File as NodeFile } from 'node:buffer';
|
|
2
3
|
/**
|
|
3
4
|
* Converts a Blob, Buffer, or File to a Buffer.
|
|
4
5
|
*
|
|
@@ -30,5 +31,5 @@ import { Buffer } from 'node:buffer';
|
|
|
30
31
|
* console.log(result3.toString()); // 'File content'
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
|
-
export declare function toBuffer(input: Blob | Buffer | File): Promise<Buffer<ArrayBufferLike>>;
|
|
34
|
+
export declare function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile): Promise<Buffer<ArrayBufferLike>>;
|
|
34
35
|
//# sourceMappingURL=buffer.d.ts.map
|
package/dist/buffer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EACR,IAAI,IAAI,QAAQ,EAChB,IAAI,IAAI,QAAQ,EACnB,MAAM,aAAa,CAAC;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,QAAQ,oCAG/E"}
|
package/dist/buffer.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer.mjs","sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: Blob | Buffer | File) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"buffer.mjs","sources":["../src/buffer.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport type {\n Blob as NodeBlob,\n File as NodeFile,\n} from 'node:buffer';\n\n/**\n * Converts a Blob, Buffer, or File to a Buffer.\n *\n * This function provides a unified way to convert various binary data types\n * to Node.js Buffer. If the input is already a Buffer, it returns it as-is.\n * For Blob or File inputs, it converts them to Buffer via ArrayBuffer.\n *\n * @param {Blob | Buffer | File} input - The input to convert to Buffer\n *\n * @returns {Promise<Buffer>} A Promise that resolves to a Buffer\n *\n * @example\n * ```typescript\n * import { toBuffer } from '@kikiutils/shared/general';\n *\n * // Convert a Buffer (returns as-is)\n * const buffer = Buffer.from('Hello World');\n * const result1 = await toBuffer(buffer);\n * console.log(result1); // <Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>\n *\n * // Convert a Blob\n * const blob = new Blob(['Hello from Blob'], { type: 'text/plain' });\n * const result2 = await toBuffer(blob);\n * console.log(result2.toString()); // 'Hello from Blob'\n *\n * // Convert a File\n * const file = new File(['File content'], 'test.txt', { type: 'text/plain' });\n * const result3 = await toBuffer(file);\n * console.log(result3.toString()); // 'File content'\n * ```\n */\nexport async function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile) {\n if (Buffer.isBuffer(input)) return input;\n return Buffer.from(await input.arrayBuffer());\n}\n"],"names":[],"mappings":";;AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BG;AACI,eAAe,QAAQ,CAAC,KAAiD,EAAA;AAC5E,IAAA,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;AAAE,QAAA,OAAO,KAAK;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,WAAW,EAAE,CAAC;AACjD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "A lightweight and modular utility library for modern JavaScript and TypeScript — includes secure hashing, flexible logging, datetime tools, Vue/web helpers, storage abstraction, and more.",
|
|
5
5
|
"author": "kiki-kanri",
|
|
6
6
|
"license": "MIT",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"./src"
|
|
54
54
|
],
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": ">=20.0.0"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "ts-project-builder './src/**/*.ts' --clean --preserve-modules --sourcemaps",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"unused-exports": "ts-unused-exports ./tsconfig.json"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@kikiutils/changelogen": "^0.8.
|
|
72
|
+
"@kikiutils/changelogen": "^0.8.1",
|
|
73
73
|
"@kikiutils/eslint-config": "^1.2.7",
|
|
74
74
|
"@kikiutils/tsconfigs": "^5.0.4",
|
|
75
75
|
"@noble/hashes": "^1.8.0",
|
package/src/buffer.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
|
+
import type {
|
|
3
|
+
Blob as NodeBlob,
|
|
4
|
+
File as NodeFile,
|
|
5
|
+
} from 'node:buffer';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Converts a Blob, Buffer, or File to a Buffer.
|
|
@@ -31,7 +35,7 @@ import { Buffer } from 'node:buffer';
|
|
|
31
35
|
* console.log(result3.toString()); // 'File content'
|
|
32
36
|
* ```
|
|
33
37
|
*/
|
|
34
|
-
export async function toBuffer(input: Blob | Buffer | File) {
|
|
38
|
+
export async function toBuffer(input: Blob | Buffer | File | NodeBlob | NodeFile) {
|
|
35
39
|
if (Buffer.isBuffer(input)) return input;
|
|
36
40
|
return Buffer.from(await input.arrayBuffer());
|
|
37
41
|
}
|