How to use the findIndex function from underscore
Find comprehensive JavaScript underscore.findIndex code examples handpicked from public code repositorys.
GitHub: cliss/camel
137 138 139 140 141 142 143 144 145
// posts are simply "\n". Remove all the "\r"s so that // everything looks like we expect. data = data.replace(/\r/g, ''); var lines = data.lines(); // Extract the metadata var metadataEnds = _.findIndex(lines, function (line) { return line.trim().length === 0; }); metadataEnds = metadataEnds === -1 ? lines.length : metadataEnds;
55
265
27
+ 38 other calls in file
4928 4929 4930 4931 4932 4933 4934 4935 4936 4937
// Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { var key; if (isArrayLike(obj)) { key = _.findIndex(obj, predicate, context); } else { key = _.findKey(obj, predicate, context); } if (key !== void 0 && key !== -1) return obj[key];
0
2
0
33 34 35 36 37 38 39 40 41 42
boardId: undefined, boardType: undefined, userId: undefined } const keyRecordI = _.findIndex(records, (curRecord) => { const userEmail = curRecord.expand.userId.email const userPhone = curRecord.expand.userId.phone const curRecordUserContact = (curRecord.expand.userId === 'email') ? userEmail : userPhone
0
0
1
underscore.keys is the most popular function in underscore (11266 examples)