Never Print Magazines

    proliferate

    0.0.5 • Public • Published

    Proliferate

    /pɹəˈlɪf.əɹ.eɪt/ (transitive, intransitive)
    To increase in number or spread rapidly; to multiply.

    The files proliferated rapidly.


    Create a bunch of simple files in a jiffy.

    Right now it's pretty simple and just makes a bunch of files in a brute force way. In the future I'd like to support more token replacement, and bulk creation of directories in addition to files.

    Usage

    Install the package via npm: npm i -D proliferate.

    const Proliferation = require('proliferate');
    const path = require('path');
     
    // create a proliferation
    const p = new Proliferation({
      count: 5000,
      fileName: 'file-%ID%.json',
      filePath: path.join(__dirname, 'data'),
      content: '{ "id": "%ID%" }'
    });
     
    // make it rain
    p.write(); // write is done asynchronously

    Usage

    The Proliferation class takes a simple configuration object. Right now it simply replaces the %ID% token where it appears in the file name or content with a numeric ID. The ID is zero indexed, left padded to match the full count.

    Proliferation class instances have a single, async method,write. It uses fsPromises.writeFile(), and does path.join(filePath, fileName) for the location. Any files which already exist will be replaced.

    API

    Property What you need to know
    count Number. How many files to make
    filePath String. Base path for where the files will be written. If it does not exist, it will be created recursively.
    fileName String. Template for the name of the file. %ID% will be replaced with the ID as described above.
    content String. What goes in the file. %ID% will be replaced with the ID as described above.

    Keywords

    none

    Install

    npm i proliferate

    DownloadsWeekly Downloads

    5

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    8.07 kB

    Total Files

    6

    Last publish

    Collaborators

    • bryanlevay