MCPcopy
hub / github.com/browserless/browserless / removeNullStringify

Function removeNullStringify

src/utils.ts:342–354  ·  view source on GitHub ↗
(
  json: unknown,
  allowNull = true,
)

Source from the content-addressed store, hash-verified

340};
341
342export const removeNullStringify = (
343 json: unknown,
344 allowNull = true,
345): string => {
346 return JSON.stringify(
347 json,
348 (_key, value) => {
349 if (allowNull) return value;
350 if (value !== null) return value;
351 },
352 ' ',
353 );
354};
355
356export const jsonOrString = (maybeJson: string): unknown | string =>
357 safeParse(maybeJson) ?? maybeJson;

Callers 1

jsonResponseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected