How to use the find function from underscore
Find comprehensive JavaScript underscore.find code examples handpicked from public code repositorys.
378 379 380 381 382 383 384 385 386 387
var seed = random.float(0, total) var counter = 0 return _.find(ar, function(a){ if(counter + a.probability > seed && counter <= seed){ return true }
33
58
7
+ 2 other calls in file
80 81 82 83 84 85 86 87 88 89
'province 3': { provinceCard: _.find(provinceThree, (card) => card.isProvince), dynastyCards: _.reject(provinceThree, (card) => card.isProvince) }, 'province 4': { provinceCard: _.find(provinceFour, (card) => card.isProvince), dynastyCards: _.reject(provinceFour, (card) => card.isProvince) } }; }
18
17
0
+ 11 other calls in file
294 295 296 297 298 299 300 301 302
} } // Checks if there's an active subscription for the incoming delta function topicIsSubscribed(topic) { return _.find(plugin.subscriptions, subs => { return matchTopic(subs.topic, topic); }) != undefined; }
2
1
0
9545 9546 9547 9548 9549 9550 9551 9552 9553 9554
}; // Convenience version of a common use case of `find`: getting the first object // containing specific `key:value` pairs. _.findWhere = function(obj, attrs) { return _.find(obj, _.matcher(attrs)); }; // Return the maximum element (or element-based computation). _.max = function(obj, iteratee, context) {
1
1
2
+ 9 other calls in file
6 7 8 9 10 11 12 13 14 15 16 17
return admins; }; exports.find = function(id, done) { var _ = require('underscore'); var returnList = _.find(admins, {adminID: adminID}); return done(null, returnList); }; exports.findByAdminID = function(id, done) {
1
0
8
37 38 39 40 41 42 43 44 45 46
const xcodeproj = xcode.project(pbxPath); xcodeproj.parseSync(); const xcBuildConfiguration = xcodeproj.pbxXCBuildConfigurationSection(); const plist_file_entry = _.find(xcBuildConfiguration, entry => entry.buildSettings && entry.buildSettings.INFOPLIST_FILE); const plist_file = path.join(project_dir, plist_file_entry.buildSettings.INFOPLIST_FILE.replace(/^"(.*)"$/g, '$1').replace(/\\&/g, '&')); const config_file = path.join(path.dirname(plist_file), 'config.xml'); if (!fs.existsSync(plist_file) || !fs.existsSync(config_file)) {
0
0
0
GitHub: evan-org/yapi
164 165 166 167 168 169 170 171 172 173 174 175
} return isRepeat; } function handleCurrDomain(domains, case_env) { let currDomain = _.find(domains, (item) => item.name === case_env); if (!currDomain) { currDomain = domains[0]; }
0
0
1
+ 3 other calls in file
570 571 572 573 574 575 576 577 578
this._featureViews = {}; } if (!this._featureViews[featureType]) { var featureViews = this.contentFeatureViews.concat(this.deliveryFeatureViews); this._featureViews[featureType] = Underscore.find(featureViews, function (featureView) { return featureView.model.get('type') === featureType; }); }
0
0
1
+ 4 other calls in file
60 61 62 63 64 65 66 67 68 69
}, afterFindOne: async function(){ if (_.isEmpty(this.data.values)) { const all = objectql.getAllObjectValidationRules(); const id = this.id; this.data.values = _.find(all, function (item) { return item._id === id }); } },
0
0
1
GitHub: 444748104/oa
63 64 65 66 67 68 69 70 71 72
} }, afterFindOne: async function(){ let id = this.id; if(id && _.isEmpty(this.data.values) && this.spaceId === 'template'){ this.data.values = _.find(getFlows(), function(flow){ return flow._id === id; }) } },
0
0
1
82 83 84 85 86 87 88 89 90 91
return result.map(function(values) { return values.withValue(exports.sequence.source, source); }); }; rule.head = function() { var firstCapture = _.find(parsers, isCapturedRule); return exports.then( rule, exports.sequence.extract(firstCapture) );
0
0
1
164 165 166 167 168 169 170 171 172 173 174 175
} return isRepeat; } function handleCurrDomain(domains, case_env) { let currDomain = _.find(domains, item => item.name === case_env); if (!currDomain) { currDomain = domains[0]; }
0
0
1
underscore.keys is the most popular function in underscore (11266 examples)