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

gpassword

v1.0.1

Published

Password generator library

Readme

generatePassword Function

This repository contains a function generatePassword which generates a password based on various criteria.

Installation

To use the generatePassword function in your project, first install the required packages:

npm install gpassword

Usage

To use the generatePassword function, import it into your project as follows:

import { generatePassword } from "gpassword";

Function Parameters

The generatePassword function accepts an object with the following optional properties:

| Prop | Type | Description | Default Value | |---------------------------|---------|--------------------------------------------------------------|---------------| | length | number | Length of the generated password | 8 | | numbers | boolean | Include numbers in the password | true | | lowercase | boolean | Include lowercase letters in the password | true | | uppercase | boolean | Include uppercase letters in the password | true | | containSpecialCharacters| boolean | Include special characters in the password | true | | uniqueCharacters | boolean | Ensure all characters in the password are unique | false |

Example Usage

Here are some examples of how to use the generatePassword function:

// Generate a default password
const password1 = generatePassword({});
console.log(password1); // Example output: aB1@cD2#

// Generate a password with specified length
const password2 = generatePassword({ length: 12 });
console.log(password2); // Example output: aB1@cD2#eF3$

// Generate a password with only numbers
const password3 = generatePassword({
  numbers: true,
  lowercase: false,
  uppercase: false,
  containSpecialCharacters: false,
});
console.log(password3); // Example output: 12345678

// Generate a password with unique characters
const password4 = generatePassword({ length: 10, uniqueCharacters: true });
console.log(password4); // Example output: aB1@cD2#eF

Test Coverage

The function is thoroughly tested to cover various scenarios:

| Test Case | Description | |-----------|-------------| | Default settings | Generates a password with length 8, including numbers, lowercase, uppercase, and special characters | | Specified length | Generates a password with a specified length | | Numbers only | Generates a password containing only numbers | | No character types | Throws an error if no character types are included | | Length smaller than conditions | Throws an error if the length is smaller than the number of required conditions | | Unique characters | Generates a password with unique characters | | Exceeding unique length | Throws an error if the unique character length exceeds available characters | | No special characters | Generates a password without special characters | | No uppercase characters | Generates a password without uppercase characters | | No lowercase characters | Generates a password without lowercase characters | | Only special characters | Generates a password containing only special characters | | Mix with unique characters | Generates a password with a mix of all character types and unique characters |

To run the tests, use the following command:

npm run test

This will execute all the test cases and verify the functionality of the generatePassword function.