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

@rqm/tools

v1.4.1

Published

Tools like debounce, memoize, etc.

Readme

Tools

Motivation

  • education
  • convenient code sharing between projects
  • low size compared to lodash and suchlike

Importing

If tree shaking enabled:

import { debounce } from '@rqm/tools'

otherwise

import debounce from '@rqm/tools/debounce'

debounce

Creates a debounced function that delays callback invoking until after wait milliseconds have elapsed since the last time the debounced function was invoked.

const debouncedCallback = debounce(callback, [, options])

Options:

  • ms=300: Delay in milliseconds.
  • onStart=false: Execute callback on first call without delay.
  • withCancel=false: Return function that cancels delayed execution. Supplied in array with debounced callback:
const [debouncedCallback, cancel] = debounce(callback, { withCancel: true })

throttle

Creates a throttled function that delays callback invoking until after wait milliseconds have elapsed since the last time the delayed callback was executed.

const throttledCallback = throttle(callback, [, options])

Options:

  • ms=300: Delay in milliseconds.
  • onStart=false: Execute callback on first call without delay.
  • withCancel=false: Return function that cancels delayed execution. Supplied in array with throttled callback:
const [throttledCallback, cancel] = throttle(callback, { withCancel: true })

memoize

Creates function that invokes passed callback and returns its result if this function invoked first time or its arguments differs with previous call arguments, otherwise its returns previous call result.

const callbackMemoizingResult = memoize(callback)

getCookie

Returns cookie value or empty string on fallback

const cookieValue = getCookie(cookieName)

With Typescript

type ThemeType = 'dark' | 'light'
const theme = getCookie<ThemeType>('theme')
// typeof theme = '' | 'dark' | 'light'

spin

Accepts array length as first parameter and index as second. Index can be any number. It's not matter whether it fits default array index restrictions (0 <= index < array.length) or not. When given index passed this restrictions, spin returns index itself, otherwise it'll be index divided with modulo array.length % index if index isn't negative. For negative index computations is more complicated, but result is similar: array[spin(array, -1)] === array[array.length -1]. Abstraction for this can be the wheel with array items reeled up on it. You spin it too much or in wrong direction and still get index with valid value.

const arr = ['a', 'b', 'c']
const len = arr.length
arr[spin(len, 3)]   // "a"
arr[spin(len, 30)]  // "a"
arr[spin(len, -30)] // "a"
arr[spin(len, -31)] // "c"
arr[spin(len, -1)]  // "c"

createArraySpinner

Returns passed array wrapped with Proxy that uses spin for getting array items:

const arr = ['a', 'b', 'c']
const arrSpinner = createArraySpinner(arr)
arrSpinner[-1] // 'c'

createGetUniqId

Creates function that always returns unique string based on passed radix, minLength and time it was called.

const getId = createGetUniqId(2, 3)
const id1 = getId() // '100'
const id2 = getId() // '101'

Options:

  • radix=16: base for id computation
  • minLength=1: minimal length for id

lastOf

Returns last item of given array and undefined if array has no items.

const arr = ['a', 'b', 'c']
const lastItem = lastOf(arr) // 'c'
lastOf([]) // undefined

range

returns array with the numbers from 0 to n

const arr = range(3)
// ['0', '1', '2']