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

package.es.traversal.find.mjs Maven / Gradle / Ivy

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;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy