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

datafactory

v0.0.3

Published

A lightweight node package for creating test / demo data and fixtures.

Downloads

12

Readme

datafactory

Travis Status devDependency Status Dependency Status

A lightweight node package for creating test data, demo data and fixtures.

Example Usage

import DataFactory from 'datafactory';

let _id = 0;
function generateId() {
  return _id++;
}

// Each root key will become a builder function on the factory
let demoData = new DataFactory({
  organization: {
    _id: generateId,
    name: 'Example organization'
  },

  user: {
    _id: generateId,
    name: 'Joe Smith',
    // You can use a function to build a property for the document
    organizationId: (group) => {
      // Assign the user to the first organization in the group by default
      if (group && group.data.organization) return group.data.organization[0]._id;
    }
  },

  // You can use a function to build the entire document
  tweet: (group) => {
    const tweet = {
      _id: generateId(),
      text: 'Hi!'
    };

    // Assign the tweet to the first user in the group by default
    if (group && group.data.user) {
      tweet.userId = group.data.user[0]._id;
    }

    return tweet;
  }
});

// Generate an organization, a user for the organization, and a tweet for the user -- you can chain calls.
let group = demoData.createGroup().organization().user().tweet({
  text: 'Joe: cool demo data!'
});

// Create another user and a tweet for them
let elisabeth = group.user({
  name: 'Elisabeth'
}).value;

group.tweet({
  userId: elisabeth._id,
  text: 'Elisabeth: Thanks!'
});

console.log('Generated documents\n\n', group.data);

console output

Generated documents

{
  organization: [{
    _id: 0,
    name: 'Example organization'
  }],
  user: [{
    _id: 1,
    name: 'Joe Smith',
    organizationId: 0
  }, {
    _id: 3,
    name: 'Elisabeth',
    organizationId: 0
  }],
  tweet: [{
    _id: 2,
    text: 'Joe: cool demo data!',
    userId: 1
  }, {
    _id: 4,
    text: 'Elisabeth: Thanks!',
    userId: 3
  }]
};

Contributing

Follow the airbnb styleguide.

I recommend setting up the babel and eslint plugins for sublime.

Requires node ^5.0.0.

npm install 
  • npm run production - Build task that generates minified scripts for production
  • npm run precommit - Run the unit tests and generate a minified script
  • npm run clean - Remove the dist folder
  • npm run eslint:source - Lint the source
  • npm run eslint:common - Lint the unit tests shared by Karma and Mocha
  • npm run clean - Remove the coverage report and the dist folder
  • npm run test - Runs unit tests for both server and the browser
  • npm run test:browser - Runs the unit tests for browser / client
  • npm run test:server - Runs the unit tests on the server
  • npm run watch:server - Run all unit tests for server & watch files for changes
  • npm run watch:browser - Run all unit tests for browser & watch files for changes
  • npm run karma:firefox - Run all unit tests with Karma & Firefox
  • npm run karma:chrome - Run all unit tests with Karma & Chrome
  • npm run packages - List installed packages
  • npm run package:purge - Remove all dependencies
  • npm run package:reinstall - Reinstall all dependencies
  • npm run package:updates - shows a list over dependencies with a higher version number then the current one - if any
  • npm run package:upgrade - Automaticly upgrade all dependencies and update package.json

Contributors

Thank you @kflash for trolly the skeleton this project was started with.

License

MIT © Dispatch