npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

automake

v0.1.4

Published

Making a various file format and make fake data eaily in stream in Nodejs, automake can easily help you making fake data with different file format easily. And cause this module is using stream so you could create really large fake data!!!

Downloads

172

Readme

automake

Making a various file format and make fake data eaily in stream in Nodejs, automake can easily help you making fake data with different file format easily. And cause this module is using stream so you could create really large fake data!!!

Usage

A sample example of making a csv file using automake, first of all, creating a write stream and make header, body, footer and send a finish callback. You can also setup your customized callback to each header, body and footer functions.

An easy sample

var fs = require('fs');
var am = require('automake')
// creating a write stream
var wb = fs.createWriteStream('./test/body_test.csv');
var am_stream = am
    .wstream(wb)
    .head('name, city, ip, people', function() {
        console.log('done making header')
    })
    .times(100, '{{Name.firstName}}, {{Address.city}}, {{Internet.ip}}, {{Image.imageUrl}}', function() {
        console.log('done a record');
    })
    .foot(function() {
        console.log('done making footer');
    })
    .error(function() {
        console.log('occor some error')
    })
    .finish(function() {
        cb();
    })

For automaticlly build random data, I've build up this module using https://github.com/Marak/Faker.js , thanks for the powerful module, you can use all of the Faker.js functions in generating random data. https://github.com/Marak/Faker.js#api (API of Faker.js)

For a sample usage

var am_stream = am
    .wstream(wb)
    .once('{{Name.firstName}}, {{Address.city}}, {{Internet.ip}}, {{Image.imageUrl}}')
    .foot()
    .finish(function() {
        console.log('finished build fake data');
    })

Making Fake data easily

in once(), .times() you can use schema {{one of faker.js API, without () in the end}}, automake module will parse {{}} to a particular fake data via faker.js.

for example

    .once('{{Name.firstName}}, {{Address.city}}, {{Internet.ip}}, {{Image.imageUrl}}')
    // compile to 
    // Leonora, Port Rocio, 193.102.170.120, http://lorempixel.com/640/480
    .times(10, '{{Name.firstName}}, {{Address.city}}, {{Internet.ip}}, {{Image.imageUrl}}')
    // compile to 
    // Alec, Imogeneport, 161.163.49.107, http://lorempixel.com/640/480
    // Maverick, New Dahlia, 180.199.13.252, http://lorempixel.com/640/480
    // Ubaldo, South Darrick, 159.2.89.75, http://lorempixel.com/640/480
    // Derrick, Lake Alizatown, 18.247.94.61, http://lorempixel.com/640/480
    // Coralie, Lake Maiaton, 154.107.166.62, http://lorempixel.com/640/480
    // Caleigh, Jacobihaven, 215.88.155.74, http://lorempixel.com/640/480
    // Tianna, Samantaport, 141.205.130.144, http://lorempixel.com/640/480
    // Nestor, Nadermouth, 92.18.147.49, http://lorempixel.com/640/480
    // Trisha, South Leopold, 213.149.47.50, http://lorempixel.com/640/480
    // Zachery, Spinkaville, 222.217.24.133, http://lorempixel.com/640/480
    // Coralie, North Wilburn, 158.129.20.221, http://lorempixel.com/640/480

Chaining methods

.head(template, [encoding], [callbak])

  • template (string)
  • encoding (string): like the encoding settings in writeable stream. http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback
  • callback (function): callback function settings in writeable http://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback

.once(template, [encoding], [callback])

  • template (string): automake module will automatically parse {{}} according to faker.js module
  • encoding (string): same as .head method
  • callback (function): same as .head method

.times(times, template, {encoding: [encoding], join: [string]}, [callback])

  • times (number): How many times do you want to loop.
  • template (string): automake module will automatically parse {{}} according to faker.js module
  • options (object): you can setup encoding and joining templates by a specific string
  • callback (function)

.foot([string], [encoding], [callback])

Same as .head method, but string is also optional.

.error(callback)

You can make a callback, while the stream prompt error

see more: http://nodejs.org/api/stream.html#stream_event_error_1

.finish(callback)

Make a callback while finished, **using this method you have to call ** .foot before calling this method

see more: http://nodejs.org/api/stream.html#stream_event_finish

Examples

Here are some examples of files that genereated from automake

https://github.com/chilijung/allfake

License

MIT