
Security News
Socket Integrates With Bun 1.3’s Security Scanner API
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
@idot-digital/generic-helpers
Advanced tools
This package/repo provides a collection of useful helper functions for various tasks.
You can install this package via npm or yarn.
npm install @idot-digital/generic-helpers
or
yarn add @idot-digital/generic-helpers
wait(ms: number): Promise<void>
: A helper function that returns a promise that resolves after a given amount of time in milliseconds.Arrays.filterNull<T>(array: (T | null | undefined)[]): T[]
: A static method that filters out null and undefined values from an array.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.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.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.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.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.This package offers various functionalities, including array manipulation, color conversion, date handling, iterator operations, object comparison/cloning, and text formatting.
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.
The package is licensed under the ISC License or MIT License.
FAQs
Collection of useful helper functions.
The npm package @idot-digital/generic-helpers receives a total of 35 weekly downloads. As such, @idot-digital/generic-helpers popularity was classified as not popular.
We found that @idot-digital/generic-helpers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Security News
Python 3.14 adds template strings, deferred annotations, and subinterpreters, plus free-threaded mode, an experimental JIT, and Sigstore verification.
Security News
Former RubyGems maintainers have launched The Gem Cooperative, a new community-run project aimed at rebuilding open governance in the Ruby ecosystem.