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 🙏

© 2024 – Pkg Stats / Ryan Hefner

use-gorkem

v2.2.2

Published

Provides you with hooks to speed up your development process

Downloads

23

Readme

Provides you with hooks to speed up your development process

useArray

Manage your state arrays properly


import { useArray } from "use-gorkem"

export const MyComponent = () => {
  const { array, filter, update, clear, set, push, remove } = useArray([
    10, 13, 100, 200
  ])

  // array: this is the current state of your array
  // filter((): function): example: filter(a => a !== 13)
  // update(n: int,s: any): example: update(2, "Hello World")
  // clear(): sets array to []
  // set(n: any[]): set([1,2,3]) would set array to [1,2,3]
  // push(n: int): adds item to the end of your array
  // remove(n: int): removes item at index n

  return <></>
}

You can also have your own names for specific items (as you wish):

  const { array: myArray, filter: myFilter, update: myUpdate, clear, set, push, remove } = useArray([
    10, 13, 100, 200
  ])

useToggle

Instead of using useState for a toggle, use useToggle

  import { useToggle } from "use-gorkem"


export const MyComponent = () => {
  const [myValue, toggle] = useToggle(false)
  return (
    <div>
      <div>{myValue ? "true" : "false"}</div>
      <button onClick={toggle}>Toggle</button>
    </div>
  )
}

useDebounce

In the following example, if "Increment Counter" button was not pressed for minimum 2 seconds, it will do: alert(counter). Use case: API calls after user action

import { useState } from "react"
import { useDebounce } from "use-gorkem"

export const MyComponent = () => {
  const [counter, setCounter] = useState(5)
  useDebounce(() => alert(counter), 2000, [counter])

  return (
    <div>
      <div>{counter}</div>
      <button onClick={() => setCounter(cur => cur + 1)}>Increment Counter</button>
    </div>
  )

}

Sponsor

⚽ Booklified Football Manager is a browser based strategy game where you can become a football manager. Coach your favourite football club! https://fm-land.booklified.com

📅 Booklified is a scheduling app. It lets other people easily book on your calendar. https://booklified.com

▶️ Youtube: ▶https://www.youtube.com/channel/UCa5K76Kap1iUqqML9JLhmxw

Author

👤 GorkemSinirlioglu

🤝 Contributing

Contact me if you would like to access the source code, or if you are facing any issues.

Buy me Coffee ☕

If this project helped you

📝 License

This project is MIT licensed.