findBy is not a valid option on sparse stores. From 4.2 onwards, it will throw an exception which in debug mode (your built code will not throw)
But if you really have a use case, here's an implementation:
Code:
/**
* Returns the first record in this page map which elicits a true return value from the
* passed selection function.
* @param {Function} fn The selection function to execute for each item.
* @param {Mixed} fn.rec The record.
* @param {String} fn.key The record's internalId.
* @param {Object} scope (optional) The scope (`this` reference) in which the
* function is executed. Defaults to this PageMap.
* @return {Object} The first record in this page map which returned true from the selection
* function, or null if none was found.
*/
findBy: function(fn, scope) {
var me = this,
result = null;
this.forEach(function(rec) {
if (fn.call(scope||me, rec)) {
result = rec;
return false;
}
});
return result;
},
filterBy is valid though. This will be implemented in 4.2 though which was missing before.