How to use the @ts-common/iterator.fold function in @ts-common/iterator

To help you get started, we’ve selected a few @ts-common/iterator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / oav / lib / util / validationError.ts View on Github external
} else if (
      (node.in === "query" || node.in === "path") &&
      node.path[0] === "paths" &&
      node.name
    ) {
      // in this case we will want to normalize the path with the uri and the paramter name
      node.path = [node.path[1], node.name]
    }
    path = consolidatePath(path, node.path)
  }

  const serializedErrors = flatMap(node.errors, validationError =>
    serializeErrors(validationError, path)
  ).toArray()

  const serializedInner = fold(
    node.inner,
    (acc, validationError) => {
      const errs = serializeErrors(validationError, path)
      errs.forEach(err => {
        const similarErr = acc.find(el => areErrorsSimilar(err, el))
        if (similarErr && similarErr.path) {
          if (!similarErr.similarPaths) {
            similarErr.similarPaths = []
          }
          similarErr.similarPaths.push(err.path as string)

          if (!similarErr.similarJsonPaths) {
            similarErr.similarJsonPaths = []
          }
          similarErr.similarJsonPaths.push(err.jsonPath as string)
        } else {