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

functional-hooks

v1.1.4

Published

Just another react hook library. Light-weight, simple, and easy to use.

Readme

functional-hooks

Just another react custom hook library focused on being light-weight, simple, and easy to use.

Credits

  • functional-hooks uses Vite as build environment for minimal and robust results.
  • It's also implemented using typescript so all the type definitions are built-in and no external package needs to be installed.

Index

Installation

# npm
npm install functional-hooks
# yarn
yarn add functional-hooks

Documentation

useDebouncedState

Works as a normal react built-in useState hook, in addition, the state will be set as a debounced value after a dedicated delay. In other words, the state value is going to be set after a small period of time, if the set function is not invoked again during the timeout, otherwise, the timeout is going to be restarted.

  • This hook, can have many use cases; for example, when you want to implement a search text field in react you can set its value in a debounced state using this hook and send the search request to server after this state is set to a value.

See the code below on github

import {useDebouncedState} from "functional-hooks";
import React, {useState} from "react";

export const MyCoolSearchInput = () => {

  const [results, setResults] = useState(null)
  const [searchValue, setSearchValue, instantlySetValue] = useDebouncedState<string>("", 3000, {
    after: async () => {
      const res = await fetch(`http://localhost:8080/posts?search=${encodeURIComponent(searchValue)}`)
      setResults(await res.json())
    },
    before: () => console.log(`State is going to be set to: ${searchValue}`)
  })

  return (
    <div>
      <input placeholder={"Debounced text field"} onChange={(e) => setSearchValue(e.target.value)}/>
      <input placeholder={"Instant text field"} onChange={(e) => instantlySetValue(e.target.value)}/>
      <pre>
      {results}
    </pre>
    </div>
  )

}

useDeepClone

It works as a duplicator for your states or props. You can create, keep and modify the component specific version of a particular state or prop.

See the code below on github

import {useDeepClone} from "functional-hooks";
import React, {FunctionComponent} from "react";

interface Post {
  id: number
  title: string
  content: string
  author: string
  date: Date
}


export const SomeComponent: FunctionComponent<{ Posts: Post[] }> = (
  {Posts}
) => {
  const [internalPosts, setInternalPosts] = useDeepClone<Post[]>(Posts)

  return <main>
    {internalPosts.map(post => (
      <section>
        <title>
          {post.title}
        </title>
        <div>
          {post.content}
        </div>
        <button onClick={() => setInternalPosts((prevState => prevState.filter((item) => item.id === post.id)))}>
          Remove Post
        </button>
      </section>
    ))}
  </main>
}

useLocalStorage

Gives you the access to local storage I/O and lets you to read from and write to it much easier.

  • It works like a simple useState hook. In addition, the state will be consistent and will not be removed after user refreshes the page.

Example: Coming soon!

useQueue

Works as a normal react built-in useState hook, in addition, the state will be a queue.

Example: Coming soon!

useStateWithTrack

Works as a normal react built-in useState hook, in addition, the state's history will be preserved in the memory and user can access to the former values of that particular state at any time.

  • User can determine the size of items kept in the memory.

Example: Coming soon!