package.es.traversal.find.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apidom-core Show documentation
Show all versions of apidom-core Show documentation
Tools for manipulating ApiDOM structures.
The newest version!
import { pathOr } from 'ramda';
import { PredicateVisitor, BREAK, visit } from "./visitor.mjs"; // find first element that satisfies the provided predicate
const find = (predicate, element) => {
const visitor = new PredicateVisitor({
predicate,
returnOnTrue: BREAK
});
visit(element, visitor);
return pathOr(undefined, [0], visitor.result);
};
export default find;