|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
876 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const identity = require('../../function/identity.js');
|
|---|
| 6 | const iteratee = require('../util/iteratee.js');
|
|---|
| 7 |
|
|---|
| 8 | function find(source, _doesMatch = identity.identity, fromIndex = 0) {
|
|---|
| 9 | if (!source) {
|
|---|
| 10 | return undefined;
|
|---|
| 11 | }
|
|---|
| 12 | if (fromIndex < 0) {
|
|---|
| 13 | fromIndex = Math.max(source.length + fromIndex, 0);
|
|---|
| 14 | }
|
|---|
| 15 | const doesMatch = iteratee.iteratee(_doesMatch);
|
|---|
| 16 | if (!Array.isArray(source)) {
|
|---|
| 17 | const keys = Object.keys(source);
|
|---|
| 18 | for (let i = fromIndex; i < keys.length; i++) {
|
|---|
| 19 | const key = keys[i];
|
|---|
| 20 | const value = source[key];
|
|---|
| 21 | if (doesMatch(value, key, source)) {
|
|---|
| 22 | return value;
|
|---|
| 23 | }
|
|---|
| 24 | }
|
|---|
| 25 | return undefined;
|
|---|
| 26 | }
|
|---|
| 27 | return source.slice(fromIndex).find(doesMatch);
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | exports.find = find;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.