"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;
