How to use the @ts-common/iterator.flatMap 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 / jsonUtils.ts View on Github external
const applySuppression = (result: SwaggerObject) => {
    const rootInfo = getFilePosition(result)
    // apply suppression
    for (const s of suppressionArray) {
      if (s.where !== undefined) {
        const paths = it.flatMap(it.isArray(s.where) ? s.where : [s.where], where => {
          try {
            return jp.paths(result, where)
          } catch (e) {
            log.error(e)
            // TODO: return the error.
            return []
          }
        })
        for (const p of paths) {
          // drop "$" and apply suppressions.
          setSuppression(getDescendantFilePosition(result, it.drop(p)), s)
        }
      } else {
        setSuppression(rootInfo, s)
      }
    }
github Azure / oav / lib / util / validationError.ts View on Github external
if (node.path) {
    // in this case the path will be set to the url instead of the path to the property
    if (node.code === "INVALID_REQUEST_PARAMETER" && node.in === "body") {
      node.path = []
    } 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) {
github Azure / oav / lib / util / path.ts View on Github external
export const splitPathAndReverse = (p: string | undefined) =>
  p === undefined ? undefined : Array.from(flatMap(p.split("/"), s => s.split("\\"))).reverse()