import { parentPort } from 'node:worker_threads'
import { secondsToMilliseconds } from 'date-fns'
-import { mean, median } from 'rambda'
+import { is, mean, median } from 'rambda'
import { BaseError } from '../exception/index.js'
import {
try {
performance.measure(name, markId)
} catch (error) {
- if (error instanceof Error && error.message.includes('performance mark has not been set')) {
+ if (is(Error, error) && error.message.includes('performance mark has not been set')) {
/* Ignore */
} else {
throw error
minutesToSeconds,
secondsToMilliseconds
} from 'date-fns'
+import { is } from 'rambda'
import {
type JsonType,
* @internal
*/
export const isAsyncFunction = (fn: unknown): fn is (...args: unknown[]) => Promise<unknown> => {
- return typeof fn === 'function' && fn.constructor.name === 'AsyncFunction'
+ return is(Function, fn) && fn.constructor.name === 'AsyncFunction'
}
export const isObject = (value: unknown): value is object => {
- return value != null && typeof value === 'object' && !Array.isArray(value)
+ return value != null && !Array.isArray(value) && is(Object, value)
}
export const hasOwnProp = (value: unknown, property: PropertyKey): boolean => {
return JSON.stringify(
object,
(_, value: Record<string, unknown>) => {
- if (value instanceof Map) {
+ if (is(Map, value)) {
switch (mapFormat) {
case MapStringifyFormat.object:
return { ...Object.fromEntries<Map<string, Record<string, unknown>>>(value.entries()) }
default:
return [...value]
}
- } else if (value instanceof Set) {
+ } else if (is(Set, value)) {
return [...value] as JsonType[]
}
return value