How to use the where function from underscore

Find comprehensive JavaScript underscore.where code examples handpicked from public code repositorys.

2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
};

// Convenience version of a common use case of `find`: getting the first object
// containing specific `key:value` pairs.
_.findWhere = function(obj, attrs) {
  return _.where(obj, attrs, true);
};

// Return the maximum element or (element-based computation).
// Can't optimize arrays of integers longer than 65,535 elements.
fork icon0
star icon2
watch icon0

61
62
63
64
65
66
67
68
69
}else{
    approvalProcesses = objectql.getSourceApprovalProcesses();
}

if (filters.object_name){
    approvalProcesses = _.where(approvalProcesses, {object_name: filters.object_name});
}

approvalProcesses = getInternalApprovalProcesses(approvalProcesses, filters);
fork icon0
star icon0
watch icon1

+ 2 other calls in file

82
83
84
85
86
87
88
89
90
91
92
 *                             exactly.  The returned object may have more values than the passed in query
 *                             object.
 * @param  {TokenCacheFindCallback} callback
 */
MemoryCache.prototype.find = function(query, callback) {
  var results = _.where(this._entries, query);
  callback(null, results);
};


module.exports = MemoryCache;
fork icon0
star icon0
watch icon0

198
199
200
201
202
203
204
205
206

var returnVal;
var isResourceTenantSpecific;

if (potentialEntries && 0 < potentialEntries.length) {
  var resourceTenantSpecificEntries = _.where(potentialEntries, { resource : self._resource, _authority : self._authority });

  if (!resourceTenantSpecificEntries || 0 === resourceTenantSpecificEntries.length) {
    self._log.verbose('No resource specific cache entries found.');
fork icon0
star icon0
watch icon0