0.17.0 • Published 3 months ago

@idot-digital/generic-helpers v0.17.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 months ago

@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.

0.16.0

3 months ago

0.17.0

3 months ago

0.15.0

3 months ago

0.14.4

3 months ago

0.14.3

3 months ago

0.12.0

3 months ago

0.13.0

3 months ago

0.14.1

3 months ago

0.14.2

3 months ago

0.11.2

3 months ago

0.11.0

5 months ago

0.11.1

5 months ago

0.10.0

6 months ago

0.9.0

6 months ago

0.8.5

6 months ago

0.6.7

7 months ago

0.8.4

6 months ago

0.6.6

9 months ago

0.8.1

6 months ago

0.6.3

9 months ago

0.8.0

6 months ago

0.6.2

9 months ago

0.8.3

6 months ago

0.6.5

9 months ago

0.8.2

6 months ago

0.6.4

9 months ago

0.7.0

6 months ago

0.6.1

9 months ago

0.6.0

12 months ago

0.5.0

12 months ago

0.4.0

12 months ago

0.3.0

12 months ago

0.2.0

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago

0.0.1

12 months ago