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

react-crazy-utils

v1.0.1

Published

A library of custom utils for React, designed to simplify common tasks in both JavaScript and TypeScript projects

Downloads

45

Readme

React Crazy Utils

📚 VIETNAMESE Documents: VIEW NOW

react-crazy-utils is a useful library for React that helps you write better code.

Installation

You can install react-crazy-utils via bun, npm or yarn:

Using bun

bash bun add react-crazy-utils

Using npm

bash npm install react-crazy-utils

Using yarn

bash yarn add react-crazy-utils

Usage

1. isEmptyObject

This function checks if an object is empty.

console.log("Empty Object?", isEmptyObject(obj)); // Output: true

2. isEmptyArray

This function checks if an array is empty.

const arr = [];
console.log("Empty Array?", isEmptyArray(arr)); // Output: true

3. debounce

This function limits the frequency of function calls by delaying execution until when a certain amount of time has passed.

const debouncedFunc = debounce(
  () => console.log("Call debounce function"),
  300
);

debouncedFunc();

4. throttle This function limits the number of function calls within a given period of time.

const throttledFunc = throttle(
  () => console.log("Call throttle function"),
  500
);

throttledFunc();

5. randomInt

This function generates a random integer in the range min to max.

const randomNum = randomInt(1, 10);
console.log("Random number:", randomNum);

6. uniqueArray

This function removes the duplicate elements in array.

const originalArray = [1, 2, 2, 3, 3, 4];
const uniqueValues = uniqueArray(originalArray);
console.log("Array after removing duplicates:", uniqueValues);

7. sleep

This function creates a wait time in milliseconds.

async function exampleUsage() {
  console.log("Starting waiting...");
  await sleep(2000); // Wait 2 seconds
  console.log("End of wait!");
}

exampleUsage();

8. formatCurrency

This function formats a number to a currency string.

const formattedAmount = formatCurrency(1000000);
console.log("Formatted Amount:", formattedAmount); // Output: "1,000,000"

9. parseCurrency

This function removes commas and returns a numeric value corresponding integer or NaN if the input is invalid.

const inputString = "1,000,000";
const parsedValue = parseCurrency(inputString);
console.log("Integer value:", parsedValue); // Output: 1000000

11. getDateNow

This function returns a Date object representing the current time

const currentDate = getDateNow();
console.log("Current date and time:", currentDate);

12. getTimestamp

This function returns the current time as a timestamp (milliseconds / seconds)

const timestamp = getTimestamp();
console.log("Current timestamp:", timestamp);

13. capitalizeFirstLetter

Capitalizes the first character of the passed string.

const capitalizedString = capitalizeFirstLetter(inputString);
console.log("Capitalized string:", capitalizedString); // Output: "Hello, world!"

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Author

Nguyen Phuc Bao Chau - GitHub Profile

License

This project is licensed under the MIT License.