main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
679 bytes
|
Line | |
---|
1 | import { isElement } from '@swagger-api/apidom-core';
|
---|
2 |
|
---|
3 | // eslint-disable-next-line import/prefer-default-export
|
---|
4 | export class AncestorLineage extends Array {
|
---|
5 | includesCycle(element) {
|
---|
6 | return this.filter(ancestors => ancestors.has(element)).length > 1;
|
---|
7 | }
|
---|
8 | includes(searchElement, fromIndex) {
|
---|
9 | if (searchElement instanceof Set) {
|
---|
10 | return super.includes(searchElement, fromIndex);
|
---|
11 | }
|
---|
12 | return this.some(ancestors => ancestors.has(searchElement));
|
---|
13 | }
|
---|
14 | findItem(predicate) {
|
---|
15 | for (const set of this) {
|
---|
16 | for (const item of set) {
|
---|
17 | if (isElement(item) && predicate(item)) {
|
---|
18 | return item;
|
---|
19 | }
|
---|
20 | }
|
---|
21 | }
|
---|
22 | return undefined;
|
---|
23 | }
|
---|
24 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.