MCPcopy Create free account
hub / github.com/OpenPipe/OpenPipe / passThroughNulls

Function passThroughNulls

app/src/utils/utils.ts:27–37  ·  view source on GitHub ↗
(
  func: T,
)

Source from the content-addressed store, hash-verified

25export const getEntries = <T extends object>(obj: T) => Object.entries(obj) as Entries<T>;
26
27export function passThroughNulls<T extends (arg: any) => any>(
28 func: T,
29): ((arg: null) => null) &
30 ((arg: NonNullable<Parameters<T>[0]>) => ReturnType<T>) &
31 ((arg: Parameters<T>[0] | null) => ReturnType<T> | null) {
32 return (arg: Parameters<T>[0] | null) => {
33 if (arg === null) return null;
34 // eslint-disable-next-line @typescript-eslint/no-unsafe-return
35 return func(arg as NonNullable<Parameters<T>[0]>);
36 };
37}
38
39export const numberWithDefault = (
40 num: number | string | bigint | null | undefined,

Callers 1

utils.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected