This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
/// <reference types="node" />
/**
* Generates a fake docx file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
export declare function generateDocx(fileSize: number | string, fileName?: string): Promise<{
contents: Buffer;
size: number;
name: string;
mime: string;
}>;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateDocx = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const promises_1 = require("fs/promises");
const generate_1 = require("../generate");
/**
* Generates a fake docx file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
async function generateDocx(fileSize, fileName) {
const mime = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
const name = fileName || `${(0, crypto_1.randomUUID)()}.docx`;
const contents = (0, generate_1.generate)(fileSize, await (0, promises_1.readFile)((0, path_1.join)(__dirname, './fake.docx')));
return { contents, mime, size: contents.length, name };
}
exports.generateDocx = generateDocx;
+5
View File
@@ -0,0 +1,5 @@
/// <reference types="node" />
/**
* Generates a buffer for a given size with pre-filled contents
*/
export declare function generate(fileSize: string | number, contents: Buffer): Buffer;
+24
View File
@@ -0,0 +1,24 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.generate = void 0;
const bytes_1 = __importDefault(require("bytes"));
/**
* Generates a buffer for a given size with pre-filled contents
*/
function generate(fileSize, contents) {
const size = typeof fileSize === 'string' ? (0, bytes_1.default)(fileSize) : fileSize;
const contentsSize = contents.length;
return Buffer.alloc(size < contentsSize ? contentsSize : size, contents, 'binary');
}
exports.generate = generate;
Binary file not shown.

After

Width:  |  Height:  |  Size: 42 B

+13
View File
@@ -0,0 +1,13 @@
/// <reference types="node" />
/**
* Generates a fake gif file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
export declare function generateGif(fileSize: number | string, fileName?: string): Promise<{
contents: Buffer;
size: number;
name: string;
mime: string;
}>;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateGif = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const promises_1 = require("fs/promises");
const generate_1 = require("../generate");
/**
* Generates a fake gif file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
async function generateGif(fileSize, fileName) {
const mime = 'image/gif';
const name = fileName || `${(0, crypto_1.randomUUID)()}.gif`;
const contents = (0, generate_1.generate)(fileSize, await (0, promises_1.readFile)((0, path_1.join)(__dirname, './fake.gif')));
return { contents, mime, size: contents.length, name };
}
exports.generateGif = generateGif;
Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

+13
View File
@@ -0,0 +1,13 @@
/// <reference types="node" />
/**
* Generates a fake jpg file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
export declare function generateJpg(fileSize: number | string, fileName?: string): Promise<{
contents: Buffer;
size: number;
name: string;
mime: string;
}>;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateJpg = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const promises_1 = require("fs/promises");
const generate_1 = require("../generate");
/**
* Generates a fake jpg file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
async function generateJpg(fileSize, fileName) {
const mime = 'image/jpeg';
const name = fileName || `${(0, crypto_1.randomUUID)()}.jpg`;
const contents = (0, generate_1.generate)(fileSize, await (0, promises_1.readFile)((0, path_1.join)(__dirname, './fake.jpg')));
return { contents, mime, size: contents.length, name };
}
exports.generateJpg = generateJpg;
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
/// <reference types="node" />
/**
* Generates a fake pdf file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
export declare function generatePdf(fileSize: number | string, fileName?: string): Promise<{
contents: Buffer;
size: number;
name: string;
mime: string;
}>;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePdf = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const promises_1 = require("fs/promises");
const generate_1 = require("../generate");
/**
* Generates a fake pdf file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
async function generatePdf(fileSize, fileName) {
const mime = 'application/pdf';
const name = fileName || `${(0, crypto_1.randomUUID)()}.pdf`;
const contents = (0, generate_1.generate)(fileSize, await (0, promises_1.readFile)((0, path_1.join)(__dirname, './fake.pdf')));
return { contents, mime, size: contents.length, name };
}
exports.generatePdf = generatePdf;
Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

+13
View File
@@ -0,0 +1,13 @@
/// <reference types="node" />
/**
* Generates a fake png file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
export declare function generatePng(fileSize: number | string, fileName?: string): Promise<{
contents: Buffer;
size: number;
name: string;
mime: string;
}>;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generatePng = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const promises_1 = require("fs/promises");
const generate_1 = require("../generate");
/**
* Generates a fake png file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
async function generatePng(fileSize, fileName) {
const mime = 'image/png';
const name = fileName || `${(0, crypto_1.randomUUID)()}.png`;
const contents = (0, generate_1.generate)(fileSize, await (0, promises_1.readFile)((0, path_1.join)(__dirname, './fake.png')));
return { contents, mime, size: contents.length, name };
}
exports.generatePng = generatePng;
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
/// <reference types="node" />
/**
* Generates a fake xlxs file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
export declare function generateXlsx(fileSize: number | string, fileName?: string): Promise<{
contents: Buffer;
size: number;
name: string;
mime: string;
}>;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
/*
* @poppinss/file-generator
*
* (c) Poppinss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateXlsx = void 0;
const path_1 = require("path");
const crypto_1 = require("crypto");
const promises_1 = require("fs/promises");
const generate_1 = require("../generate");
/**
* Generates a fake xlxs file for the given file size.
*
* @example
* generate(1000 * 1000 * 2) // Generates a 2mb file
*/
async function generateXlsx(fileSize, fileName) {
const mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
const name = fileName || `${(0, crypto_1.randomUUID)()}.xlsx`;
const contents = (0, generate_1.generate)(fileSize, await (0, promises_1.readFile)((0, path_1.join)(__dirname, './fake.xlsx')));
return { contents, mime, size: contents.length, name };
}
exports.generateXlsx = generateXlsx;