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

ansh-my-utils

v1.0.4

Published

Bunch of utility fuction for everyday use

Readme

List of functions

password.ts

  1. hashpassword Takes a plain text password and returns a hashed version using bcrypt.

Example

import { hashPassword } from "./password";
const hashed = hashPassword("plain-password");
console.log(hashed); // hashed password
  1. comparepassword Takes a plain text password and a hashed version, returns true if they match.

Example

import { comparePassword } from "./password";
const result = comparePassword("plain-password", hashedPassword);
console.log(result); // true or false

encrypt.ts

  1. encryptData Takes a data of type string | Buffer | Object, a secret key, and jsonwebtoken signoptions(optional). Returns an encrypted token.

Example

interface SignOptions {
    /**
     * Signature algorithm. Could be one of these values :
     * - HS256:    HMAC using SHA-256 hash algorithm (default)
     * - HS384:    HMAC using SHA-384 hash algorithm
     * - HS512:    HMAC using SHA-512 hash algorithm
     * - RS256:    RSASSA using SHA-256 hash algorithm
     * - RS384:    RSASSA using SHA-384 hash algorithm
     * - RS512:    RSASSA using SHA-512 hash algorithm
     * - ES256:    ECDSA using P-256 curve and SHA-256 hash algorithm
     * - ES384:    ECDSA using P-384 curve and SHA-384 hash algorithm
     * - ES512:    ECDSA using P-521 curve and SHA-512 hash algorithm
     * - none:     No digital signature or MAC value included
     */
    algorithm?: Algorithm | undefined;
    keyid?: string | undefined;
    expiresIn?: StringValue | number;
    notBefore?: StringValue | number | undefined;
    audience?: string | string[] | undefined;
    subject?: string | undefined;
    issuer?: string | undefined;
    jwtid?: string | undefined;
    mutatePayload?: boolean | undefined;
    noTimestamp?: boolean | undefined;
    header?: JwtHeader | undefined;
    encoding?: string | undefined;
    allowInsecureKeySizes?: boolean | undefined;
    allowInvalidAsymmetricKeyTypes?: boolean | undefined;
}
import { encryptData } from "./encrypt";
const options: SignOptions = {};
const data = "plain-text"
const secretKey = "sdhjfweiuhf98732jkdhf"
const encrypted = encryptData(data, secretKey, options);
console.log(encrypted); // encrypted token
  1. decryptData Takes an encrypted token, a secret key. Returns the decrypted data.
import { decryptData } from "./decrypt";
const secretKey = "sdhjfweiuhf98732jkdhf"
const data = "plain-text"
const encrypted = encryptData(data, secretKey, options);
const decrypted = decryptData(encrypted, secretKey);
console.log(decrypted); // decrypted data

data-validator.ts

  1. checkIfFieldIsEmptyInAobject Takes an object, an optional array of fields to ignore, and an optional custom error message. Returns an error message if any required field is empty, or an empty string if all fields are present.

Note: The custom error message supports the key placeholder, which will be replaced with the name of the empty field. All occurrences of key in the error message will be replaced with the name of the empty field.

Example

const obj = {
  name: "",
  email: "",
  password: ""
}
const error = checkIfFieldIsEmptyInAobject(obj, ["name"], "Please provide your key");

// The key placeholder will be replaced with the name of the empty field
// In this case, the empty field is "name", "email", and "password" but the "name" field is ignored because it is an optional field
console.log(error); // "Please provide your email"
console.log(error); // "Please provide your password"