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 🙏

© 2026 – Pkg Stats / Ryan Hefner

yamock

v1.0.9

Published

Yet another library for mocking data in JavaScript.

Readme

yaMock

Yet another library for mocking data in JavaScript.

Features

  • Scheme based API
  • Intuitive mock scheme description with integrated Types
  • Posibility to make promise based responses

Installation

Using npm:

$ npm install yamock

Using yarm:

$ yarn add yamock

Example

Creating mock object, that will return random person data with random amount of posts, after random timeout:

import Mock from 'yamock'
import {UUID, FullName, Username, Bool, DateTime, ArrayOf, Sentence, Sentences, Integer} from 'yamock/types'

const person = Mock({
    id: UUID(),
    name: FullName(Bool()),
    username: Username(),
    birthday: DateTime(0, new Date(2000, 1, 1)),
    posts: ArrayOf({
        id: UUID(),
        title: Sentence(3, 6),
        text: Sentences(Integer(2, 4))
    }, Integer(1, 3))
}, Integer(500, 2000))

const result = await person()

Mock function returns a function, that return random values each call based on scheme.

Usage

Mock

Mock - main object of module. Creates a function that return random values based on scheme.

Parameters: |Name|Value|Description| |-|-|-| |Scheme|Object Array|Describes mock object structure| |timeout|optional: Number Function|Creates delay for output< default value is 0|

Return Object if timeout equals 0, and Promise if timeout greater than 0.

Scheme and types

Scheme - describes structure of mock object. Scheme is made of Types, that can be imported from yamock/types.

Example:

import Mock from 'yamock'
import {Integer, String} from 'yamock/types'

const mock = Mock({
    int: Integer(0, 100), // generate random integer number between 0 and 100
    string: String(10) // generate string of random characters 10 symbols long
})

Types

List of currently available types: Numbers:

  • Integer(min, max) - generates random integer between min and max
  • Id(max) - generates random integer between 0 and max
  • Float(min, max) - generates random float number between min and - max

Date and Time:

  • DateTime(min, max) - generates random Date beetween min and max, - min and max can be both Number and Date
  • Time(min, max) - generates random time between min and max

Boolean:

  • Bool(chance) - return random boolean with chance of true value

String:

  • String(length) - generates string of random characters length - symbols long
  • Word() - generates random word
  • Words(length) - generates length count of words
  • Sentence(min, max) - generate sentence of words
  • Sentences(length) - generate random sentences length sentences - long
  • FirstName() - generate random first name
  • LastName() - generate random last name
  • FullName(double) - generate random full name
  • Country() - generate random country
  • City() - generate random city
  • UUID() - return uuidv4
  • Email(provider) - generate random email with provider
  • Phone(code) - generate random phone number with country code
  • CreditCard() - generate random credit card number
  • Street() - generate random street name
  • Coordinates(type) - generate random WGS84 coordinates
  • Gender() - return random gender
  • Username() - generate random username

Array:

  • PickArray(array) - pick element from array randomly
  • ArrayOf(type, length) - generates array with length elements of type

URL:

  • Wikipedia - return url to random Wikipedia article
  • Avatar(size) - return url to random avatar
  • PlaceholderImage(width, height, text, format) - return url to placeholder image