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

lostash

v1.2.0

Published

An enhanced version of `useState` with additional utilities for common state management patterns.

Downloads

3

Readme

Lostash

A collection of enhanced useState that provides utility methods for common use cases.

npm version license downloads

Installation

# npm
npm install lostash

# yarn
yarn add lostash

# pnpm
pnpm add lostash

Usage Examples

useBoolState

Switch Example

Codesandbox

function Switch () {
  const onState = useBoolState();
  return (
    <button
      className={onState.isTrue ? "button-primary" : ""}
      onClick={onState.toggle}
    >
      {onState.isTrue ? "On" : "Off"}
    </button>
  );
};

useStringState

Text Input Example

import { useStringState } from "lostash";

function SearchBar() {
  const searchState = useStringState("");
  return (
    <div>
      <input
        type="text"
        placeholder="Search..."
        value={searchState.value}
        onChange={searchState.onChange}
      />
      <button onClick={searchState.clear}>Clear</button>
    </div>
  );
}

useNumberState

Counter Example

import { useNumberState } from "lostash";

function Counter() {
  const counterState = useNumberState(0);
  return (
    <div style={counterStyles}>
      <h2>Counter: {value}</h2>
      <button onClick={counterState.increment}>+1</button>
      <button onClick={counterState.decrement}>-1</button>
      <button onClick={counterState.reset}>Reset</button>
    </div>
  );
}

useArrayState

To-do List Example

import { useArrayState } from "lostash";

function TodoList() {
  const listState = useArrayState<Task>([
    { id: 1, text: "Buy groceries" },
    { id: 2, text: "Walk the dog" },
  ]);

  return (
    <div>
      <h2>To-Do List</h2>
      <ul>
        {listState.value.map((task) => (
          <li>
            {task.text}
            <button onClick={() => listState.remove(task)}>Delete</button>
          </li>
        ))}
      </ul>
      <button onClick={() => listState.push({ id: Date.now(), text: "New Task" })}>
        Add Task
      </button>
      <button onClick={listState.clear}>Clear All</button>
      <button onClick={listState.reset}>Reset</button>
    </div>
  );
}

API

useBoolState

Codesandbox

useBoolState<Props = {}>(
  initialValue?: boolean,
  options?: {
    props?: [K in keyof Props]: [Props[K], Props[K]];
  }
): UseBoolState

| Property | Type | Description | |------------|-----------|-------------| | value | boolean | The current boolean state. | | set | (newState: boolean) => void | Manually set the boolean state. | | reset | () => void | Resets the state back to the initial value. | | toggle | () => void | Toggles the boolean state (truefalse). | | setTrue | () => void | Sets the state to true. | | setFalse | () => void | Sets the state to false. | | isTrue | boolean | A derived boolean indicating if value is true. | | isFalse | boolean | A derived boolean indicating if value is false. | | props | Props | An object containing derived properties based on the current boolean state and the props provided in the options parameter. |