X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils.ts;h=88562ca3531f9acbb446414075366a4b50ba1ce4;hb=c3024c5998f1aa6c228c5db083e160b6fd967d7c;hp=d74cfbfd3768592134fce5df367bb15ab299d5d4;hpb=e9ed6eeed0f1c96d89c1506ee342b3000a95b4ba;p=poolifier.git diff --git a/src/utils.ts b/src/utils.ts index d74cfbfd..88562ca3 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,6 @@ -import * as os from 'node:os' import { getRandomValues } from 'node:crypto' +import * as os from 'node:os' + import type { KillBehavior } from './worker/worker-options.js' /** @@ -118,24 +119,24 @@ export const round = (num: number, scale = 2): number => { } /** - * Is the given object a plain object? + * Is the given value a plain object? * - * @param obj - The object to check. - * @returns `true` if the given object is a plain object, `false` otherwise. + * @param value - The value to check. + * @returns `true` if the given value is a plain object, `false` otherwise. * @internal */ -export const isPlainObject = (obj: unknown): obj is object => - typeof obj === 'object' && - obj !== null && - obj.constructor === Object && - Object.prototype.toString.call(obj) === '[object Object]' +export const isPlainObject = (value: unknown): value is object => + typeof value === 'object' && + value !== null && + value.constructor === Object && + Object.prototype.toString.call(value) === '[object Object]' /** * Detects whether the given value is a kill behavior or not. * * @typeParam KB - Which specific KillBehavior type to test against. * @param killBehavior - Which kind of kill behavior to detect. - * @param value - Any value. + * @param value - Unknown value. * @returns `true` if `value` was strictly equals to `killBehavior`, otherwise `false`. * @internal */ @@ -200,7 +201,7 @@ export const max = (...args: number[]): number => * @internal */ // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const once = ( +export const once = ( fn: (...args: A) => R, context: T ): ((...args: A) => R) => {