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

@consumidor-positivo/ts-utils

v1.17.0

Published

<div align="center"> <img src="http://assets.acordocerto.com.br/f/114280/500x147/81e872f257/typescript-utils.png" alt="TypeScript Utils Logo" /> </div>

Downloads

2,380

Readme

@consumidor-positivo/ts-utils

TypeScript utilities library for Consumidor Positivo projects.

Installation

npm install @consumidor-positivo/ts-utils

Usage

Utility Functions

import { range } from '@consumidor-positivo/ts-utils';

// Generate an array of sequential numbers
const numbers = range(5);
console.log(numbers); // [0, 1, 2, 3, 4]

React Hooks (Optional)

The library also provides React hooks that can be imported separately. These hooks are optional and require React as a peer dependency.

usePersistedState

import { usePersistedState } from '@consumidor-positivo/ts-utils/hooks';

function UserPreferences() {
  // Persist state in localStorage (default)
  const [preferences, setPreferences, clearPreferences] = usePersistedState('user-preferences', {
    theme: 'light',
    fontSize: 14
  });
  
  // Persist state in sessionStorage
  const [sessionData, setSessionData] = usePersistedState('session-data', 
    { isLoggedIn: true }, 
    { storage: 'session' }
  );
  
  const toggleTheme = () => {
    setPreferences({
      ...preferences,
      theme: preferences?.theme === 'light' ? 'dark' : 'light'
    });
  };
  
  return (
    <div>
      <p>Current theme: {preferences?.theme}</p>
      <button onClick={toggleTheme}>Toggle Theme</button>
      <button onClick={clearPreferences}>Reset Preferences</button>
    </div>
  );
}

See the documentation for more detailed examples and API reference.

Development Guidelines

This library is designed to contain only generic utility functions that can be safely used in client-side applications. When contributing, please adhere to these important principles:

  • No business logic: This library should not contain any business-specific logic or rules.
  • No internal requests: Do not include API calls or requests to internal services.
  • No sensitive code: Avoid including any sensitive information or algorithms.
  • Client-side safe: All utilities should be appropriate for use in browser environments.

The purpose of this library is to provide reusable, generic utility functions that help with common programming tasks across different Consumidor Positivo projects.

Contributing

Please read our Contributing Guide for details on our development process, Git workflows, and how to submit pull requests.

Documentation

Generate documentation

To generate the library documentation, run:

npm run docs

The documentation will be generated in the docs/ directory.

View documentation locally

To generate and view the documentation on a local server, run:

npm run docs:serve

This will start a local server and the documentation will be available at http://localhost:3000.

Build library and documentation

To build both the library and documentation, run:

npm run build:all

Testing

This library uses Vitest for testing. Here are the available test commands:

Run tests

npm test

Run tests in watch mode

npm run test:watch

Run tests with coverage

npm run test:coverage

Run tests with UI

npm run test:ui

License

Proprietary - Consumidor Positivo