Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
import { parentPort } from 'node:worker_threads'
import { secondsToMilliseconds } from 'date-fns'
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 {
import { BaseError } from '../exception/index.js'
import {
try {
performance.measure(name, markId)
} catch (error) {
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
/* Ignore */
} else {
throw error
minutesToSeconds,
secondsToMilliseconds
} from 'date-fns'
minutesToSeconds,
secondsToMilliseconds
} from 'date-fns'
+import { is } from 'rambda'
* @internal
*/
export const isAsyncFunction = (fn: unknown): fn is (...args: unknown[]) => Promise<unknown> => {
* @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 => {
}
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 => {
}
export const hasOwnProp = (value: unknown, property: PropertyKey): boolean => {
return JSON.stringify(
object,
(_, value: Record<string, unknown>) => {
return JSON.stringify(
object,
(_, value: Record<string, unknown>) => {
- if (value instanceof Map) {
switch (mapFormat) {
case MapStringifyFormat.object:
return { ...Object.fromEntries<Map<string, Record<string, unknown>>>(value.entries()) }
switch (mapFormat) {
case MapStringifyFormat.object:
return { ...Object.fromEntries<Map<string, Record<string, unknown>>>(value.entries()) }
default:
return [...value]
}
default:
return [...value]
}
- } else if (value instanceof Set) {
+ } else if (is(Set, value)) {
return [...value] as JsonType[]
}
return value
return [...value] as JsonType[]
}
return value