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

@mo_lee/utils

v0.0.5

Published

deepCopy range once rand promiseLike debounce throttle

Readme

utils

This module provides various utility functions written in Vanilla JavaScript.

Install

This is a Node.js module available through the npm registry. Please download and install Node.js before proceeding with the installation.

The installation using npm install is performed using the following command.

npm i @mo_lee/utils

Note: It is written in ESM format and may not function correctly in some Content Management Systems (CMS).

Function

version 0.0.5

  • makeGenerator

version 0.0.4

  • debounce
  • throttle
  • deepCopy
  • promiseLike
  • rand
  • range

Usage

debounce

import { debounce } from "@mo_lee/utils";

const printNumber = debounce(console.log, 1000);

let count = 0;

const printInter = setInterval(() => {
  if ((count += 1) > 20) return clearInterval(printInter);
  printNumber(1);
}, 100);

// Executes once after 3 seconds

throttle

import { throttle } from "@mo_lee/utils";

const printNumber = throttle(console.log, 1000);

let count = 0;

const printInter = setInterval(() => {
  if ((count += 1) > 20) return clearInterval(printInter);
  printNumber(1);
}, 100);

// Run twice for 2 seconds

deepCopy

import { deepCopy } from "@mo_lee/utils";

class Dog {
  name;
  constructor(name) {
    this.name = name;
  }
}

const user = {
  id: 1,
  name: "Jone",
  addr: {
    city: "New York City",
    Detailed: {
      Borough: "Brooklyn",
    },
  },
  like: ["soccer", "food"],
  pet: new Dog("lucy"),
};

const copiedUser = deepCopy(user); // user !==  copiedUser

promiseLike

import { promiseLike } from "@mo_lee/utils";

const myPromise = new promiseLike((resolve, reject) => {
  setTimeout(() => {
    const now = Date.now();
    if (now % 2 >= 0) resolve(now);
    else reject(new Error("error"));
  }, 1000);
});

myPromise.then((res) => console.log(res)); // promise OK

rand

import { rand } from "@mo_lee/utils";

console.log(rand(1, 10)); //Random number between 1 and 10
console.log(rand(5, 20)); //Random number between 5 and 20

range

import { range } from "@mo_lee/utils";

range(0); // [0]
range(1, 10, 1); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
range(1, 10); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
range(10, 1, -2); // [10, 8, 6, 4, 2]
range(-5); // [-5, -4, -3, -2, -1]

makeGenerator

import { makeGenerator } from "@mo_lee/utils";

const user = { id: 1, name: "John", job: "Doctor" };

for (const value of user) console.log(value); // Error: user is not iterable

makeGenerator(user);

for (const value of user) console.log(value); // OK!
/*
1
John
Doctor
*/

People

mo_lee

License

MIT