function debugCleanPayload()

in typescript/src/pubsub/apple-common.ts [101:124]


function debugCleanPayload(
  data: unknown,
  depth = 4,
  isSafe = false,
): object | string {
  if (isObject(data) && depth > 0) {
    if (Array.isArray(data)) {
      const res = [];
      for (const item of data) res.push(debugCleanPayload(item, depth - 1));
      return res;
    } else {
      const result: Record<string, unknown> = {};
      for (const k in data) {
        result[k] = debugCleanPayload(
          data[k],
          depth - 1,
          fieldAllowList.includes(k),
        );
      }
      return result;
    }
  } else if (isSafe) return `${data}`;
  else return `<${typeof data}>`;
}