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:
380 bytes
|
Line | |
---|
1 | import { pathOr } from 'ramda';
|
---|
2 | import { PredicateVisitor, BREAK, visit } from "./visitor.mjs"; // find first element that satisfies the provided predicate
|
---|
3 | const find = (predicate, element) => {
|
---|
4 | const visitor = new PredicateVisitor({
|
---|
5 | predicate,
|
---|
6 | returnOnTrue: BREAK
|
---|
7 | });
|
---|
8 | visit(element, visitor);
|
---|
9 | return pathOr(undefined, [0], visitor.result);
|
---|
10 | };
|
---|
11 | export default find; |
---|
Note:
See
TracBrowser
for help on using the repository browser.