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

@plq/faker

v1.1.1

Published

A set of classes for mocking known data types such as browser history, browser download list, persona, domain name, Jira project, GitHub repository, etc.

Downloads

29

Readme

faker

A set of classes for mocking known data types such as browser history, browser download list, person, domain name, Jira project, GitHub repository, etc.

Installation

Install the library using npm:

npm install @plq/faker

Usage

Domain

Generates an object with random protocol, domain name and TLD. It's using for generating History, Project, Repository, Tracker and User.

import { Domain } from '@plq/faker'

const domain = new Domain()

domain.getItem()
/* Output: {
    protocol: 'https', // Random protocol
    name: 'close-reality', // Random domain name
    tld: 'name', // Random TLD
    domainName: 'close-reality.name',
    full: 'https://close-reality.name',
} */

Or you can generate a domain with predefined data:

new Domain('https://github.com') // Nothing random
new Domain('npmjs.com') // Random protocol
new Domain('development') // Random protocol and TLD

Downloads

Generates an array of random download items. See chrome.downloads.DownloadItem.

import { Downloads } from '@plq/faker'

const downloads = new Downloads()

downloads.getItems() // Returns an array of download items
downloads.getItem() // Returns a single download item

With predefined data, class accepts an object with type of downloads.DownloadQuery:

new Downloads({
    url: 'https://downloads.info', // All download items will have the same domain
    limit: 100, // Number of download items
    startedAfter: new Date('2023-01-01').getTime(), // All items will be created with startTime after 2023-01-01
    startedBefore: new Date('2023-01-31').getTime(), // All items will be created with startTime before 2023-01-31
}) 

History

Generates an array of random history items. See chrome.history.HistoryItem.

import { History } from '@plq/faker'

const history = new History()

history.getItems() // Returns an array of history items
history.getItem() // Returns a single history item

With predefined data, class accepts an object with type of history.search.query:

new History({
    text: 'https://github.com', // All history items will have the same domain
    maxResults: 100, // Number of history items
    startTime: new Date('2023-01-01').getTime(), // All items will be created with lastVisitTime after 2023-01-01
    endTime: new Date('2023-01-31').getTime(), // All items will be created with lastVisitTime before 2023-01-31
}) 

Project

Generates an object with random project name.

import { Project } from '@plq/faker'

const project = new Project()

project.getItem()
/* Output: {
	name: 'Zieme, Hauck and McClure'
	shortName: 'Zieme'
	abbreviation: 'ZHM'
} */

Repository

Generates an object with random GitHub or Gitlab repository data.

import { Repository } from '@plq/faker'

const repository = new Repository()

repository.getItem()
/* Output: {
    provider: 'github' | 'gitlab', // Random or predefined
	user: 'Nettie_Zboncak40', // Random user nickname
	project: 'zieme', // Random project shortName
	url: https://${provider}.${project}.${tld}, // Random url
} */

Repository constructor params:

  • user?: MockUserItem,
  • project?: MockProjectItem,
  • domain?: MockDomainItem
new Repository({
    user: new User().getItem(),
    project: new Project().getItem(),
    domain: new Domain().getItem(),
})

Tracker

Generates an object with random Jira or Youtrack tracker data.

import { Tracker } from '@plq/faker'

const tracker = new Tracker()

tracker.getItem()
/*
Output: {
    provider: 'jira' | 'youtrack', // Random or predefined
	user: 'Nettie_Zboncak40', // Random user nickname
	project: 'zieme', // Random project shortName
	url: `https://${provider}.${tld}/${user}/${project}`, // Random url
	path: `${user}/${project}`
}
*/

Tracker constructor params:

  • user?: MockUserItem,
  • project?: MockProjectItem,
  • domain?: MockDomainItem
new Tracker({
    user: new User().getItem(),
    project: new Project().getItem(),
    domain: new Domain().getItem(),
})

User

Generates an object with random user data.

import { User } from '@plq/faker'

const user = new User()

user.getItem()
/* Output: {
    nickname: 'Helene_Muller11'
	email: '[email protected]'
	firstName: 'Helene'
	lastName: 'Muller'
	fullName: 'Helene Muller'
} */

User constructor params:

  • domain?: MockDomainItem
new User(
    new Domain().getItem() // Using for email generation
)

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, please submit an issue or a pull request on the GitHub repository.

License

This library is distributed under the MIT License. See the LICENSE file for more information.

Bug Reports

If you encounter any bugs or issues, please report them on the issue tracker.