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

@idot-digital/generic-helpers

v0.17.0

Published

Collection of useful helper functions.

Downloads

41

Readme

@idot-digital/generic-helpers

This package/repo provides a collection of useful helper functions for various tasks.

Installation

You can install this package via npm or yarn.

npm install @idot-digital/generic-helpers

or

yarn add @idot-digital/generic-helpers

Features

General Helper

  • wait(ms: number): Promise<void>: A helper function that returns a promise that resolves after a given amount of time in milliseconds.

Array Helpers

  • Arrays.filterNull<T>(array: (T | null | undefined)[]): T[]: A static method that filters out null and undefined values from an array.

Color Helpers

The Colors class provides several color-related helper methods, including:

  • hexToRgba(hex: HEX): RGBA | null: Converts a hex color to rgba values.
  • rgbaToHex(color: RGB | RGBA): HEX: Converts rgb values to hex color format.
  • getContrastColor(color: Color, settings?: {...}): string: Calculates a contrast text color for a given background color.
  • And many more!

Date Helpers

The Dates class provides date-related helper methods, such as:

  • getRelativeTimeString(date: Date, date2: Date = new Date(), short: boolean = false, roundToDate = false): string: Represents the difference between two dates as a string.
  • onSameDay(date1: Date, date2?: Date): boolean: Checks if two dates are on the same day.
  • And more!

Iterator Helpers

The Iterators class provides helper methods for working with iterators, such as:

  • toArray<T>(iterator: AsyncGenerator<T> | Generator<T> | IterableIterator<T> | AsyncIterableIterator<T>, limit?: number): Promise<T[]>: Converts an iterator to an array.
  • fromArray<T>(array: (T | Promise<T>)[]): AsyncGenerator<T>: Converts an array with promise items to an async iterator.
  • And more!

Object Helpers

The Objects class provides object-related helper methods:

  • deepEqual<T>(a: T, b: T): boolean: Deeply compares two objects and returns true if they are equal.
  • deepClone<T>(obj: T): T: Deeply clones an object and returns the cloned object.

Text Helpers

The Text class provides text-related helper methods:

  • bigNumbers(num: number): string: Formats big numbers to a more readable format.
  • grades(percentage: number): string: Converts a percent value to a corresponding letter grade.

Conclusion

This package offers various functionalities, including array manipulation, color conversion, date handling, iterator operations, object comparison/cloning, and text formatting.

Contributing

If you are an employee of idot digital or one of its subsidiaries, you can create issues or pull/merge requests. They will regularly be reviewed and merged. The code standards are your default company standards.

If you are someone who just found the package on npm and you have feedback or additional functions you want to see in the package, please send us an email to [email protected] with "[generic-helpers]" in the subject.

License

The package is licensed under the ISC License or MIT License.