All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.es.dereference.util.mjs Maven / Gradle / Ivy

Go to download

Advanced algorithms for semantic ApiDOM manipulations like dereferencing or resolution.

There is a newer version: 1.0.0-alpha.9
Show newest version
import { isElement } from '@swagger-api/apidom-core';

// eslint-disable-next-line import/prefer-default-export
export class AncestorLineage extends Array {
  includesCycle(element) {
    return this.filter(ancestors => ancestors.has(element)).length > 1;
  }
  includes(searchElement, fromIndex) {
    if (searchElement instanceof Set) {
      return super.includes(searchElement, fromIndex);
    }
    return this.some(ancestors => ancestors.has(searchElement));
  }
  findItem(predicate) {
    for (const set of this) {
      for (const item of set) {
        if (isElement(item) && predicate(item)) {
          return item;
        }
      }
    }
    return undefined;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy