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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gabrielduumont/data-mocker-js

v1.2.1

Published

Fake data generator.

Readme

@gabrielduumont/data-mocker-js

v.1.2.1 Mock data generator. Fast development and testing for front-end tasks.

Installing

Using npm:

$ npm install @gabrielduumont/data-mocker-js

Using yarn:

$ yarn add @gabrielduumont/data-mocker-js

Usage

const DataMocker = require('@gabrielduumont/data-mocker-js');
const dataMocker = new DataMocker();
// dataMocker.<method> will now provide autocomplete and parameter typings

Numbers

const DataMocker = require('@gabrielduumont/data-mocker-js');
// Instantiate the class
const dataMocker = new DataMocker();

// Get a random integer between 1000 and 100000
var bigInt = dataMocker.numbers.bigInt();

// Get a random integer between 0 and 10
var smallInt = dataMocker.numbers.smallInt();

// Get a random integer above 1000000
var hugeInt = dataMocker.numbers.hugeInt();

// Get a random integer between 0 and 1000000
var int = dataMocker.numbers.int();

// Get a random decimal between 1000 and 100000
var bigDecimal = dataMocker.numbers.bigDecimal();

// Get a random decimal between 0 and 10
var smallDecimal = dataMocker.numbers.smallDecimal();

// Get a random decimal between 0 and 1
var smallestDecimal = dataMocker.numbers.smallestDecimal();

// Get a random decimal between above 1000000
var hugeDecimal = dataMocker.numbers.hugeDecimal();

// Get a random decimal between 0 and 1000000
var decimal = dataMocker.numbers.decimal();

Strings

const DataMocker = require('@gabrielduumont/data-mocker-js');
// Instantiate the class
const dataMocker = new DataMocker();

// Get a random word
var word = dataMocker.strings.word();

// Get a random phrase
var phrase = dataMocker.strings.phrase();

// Get a random paragraph
var paragraph = dataMocker.strings.paragraph();

// Get a random text (multiple paragraphs)
var bigText = dataMocker.strings.bigText();

Names

Names takes on a 'locale' parameter, which by now the only one default and available is 'BR'. A list of all available locales will be linked here (whenever we have more than just one)

const DataMocker = require('@gabrielduumont/data-mocker-js');
// Instantiate the class
const dataMocker = new DataMocker();

// Get a random first name
var firstName = dataMocker.names.firstName();

// Get a random last name
var lastName = dataMocker.names.lastName();

// Get a random fullname
var fullname = dataMocker.names.fullname();

// Get a random city name
var cities = dataMocker.names.cities();

// Get a random brand name
var brand = dataMocker.names.brand();

// Get a random brand name (with locale example)
var usBrand = dataMocker.names.brand('US'); // not available at the moment, but will be in the future (hopefully with more contributors :)
var canadaBrand = dataMocker.names.brand('CA'); // not available at the moment, but will be in the future (hopefully with more contributors :)

React examples


import './App.css';
import DataMocker from '@gabrielduumont/data-mocker-js';

function App() {
  const dataMocker = new DataMocker();
  return (
    <div className="App">
        <p>int: {dataMocker.numbers.int()}</p>
        <p>bigInt: {dataMocker.numbers.bigInt()}</p>
        <p>hugeInt: {dataMocker.numbers.hugeInt()}</p>
        <p>smallInt: {dataMocker.numbers.smallInt()}</p>
        <p>decimal: {dataMocker.numbers.decimal()}</p>
        <p>bigDecimal: {dataMocker.numbers.bigDecimal()}</p>
        <p>hugeDecimal: {dataMocker.numbers.hugeDecimal()}</p>
        <p>smallDecimal: {dataMocker.numbers.smallDecimal()}</p>
        <p>smallestDecimal: {dataMocker.numbers.smallestDecimal()}</p>
        <p>word: {dataMocker.strings.word()}</p>
        <p>phrase: {dataMocker.strings.phrase()}</p>
        <p>paragraph: {dataMocker.strings.paragraph()}</p>
        <p>bigText: {dataMocker.strings.bigText()}</p>
    </div>
  );
}

export default App;

Testing examples

const DataMocker = require('@gabrielduumont/data-mocker-js');

const dataMocker = new DataMocker();

const testMethod = (
  methodName,
  min = 0,
  max = 1,
) => {
  const executions = dataMocker.numbers.bigInt();
  const result = [...Array(executions).keys()]
    .map(item => {
      const resultFromMethod = dataMocker.numbers[methodName]();
      return resultFromMethod >= min && resultFromMethod <= max;
    })
    .every(item => (!!item));
  console.log(`${methodName} (test runs: ${executions})`)
  if (result) {
    console.log(`--result: ok`)
  }
  else {
    console.log(`--result: error`)
  }
}

testMethod('bigInt', 1000, 100000);
testMethod('smallInt', 0, 10);
testMethod('hugeInt', 1000000, 100000000);
testMethod('int', 0, 100000000);
testMethod('bigDecimal', 1000, 100000);
testMethod('smallDecimal', 0, 10);
testMethod('smallestDecimal', 0, 1);
testMethod('hugeDecimal', 1000000, 100000000);
testMethod('decimal', 0, 100000000);


const moreExecutions = dataMocker.numbers.smallInt();
const result = [...Array(moreExecutions).keys()].forEach(item => {
  testMethod('bigInt', 1000, 100000);
})

Credits

somewhat inspired on (RIP) fakerjs.

License

MIT