Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@idot-digital/generic-helpers

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@idot-digital/generic-helpers

Collection of useful helper functions.

latest
npmnpm
Version
0.29.4
Version published
Maintainers
2
Created
Source

@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 contact@idot-digital.de with "[generic-helpers]" in the subject.

License

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

FAQs

Package last updated on 10 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts