Javascript Array findIfNotError(filter)
Array.prototype.findIfNotError = function(filter) { var result = this.find(filter); //from w ww . jav a 2 s . co m if ( !result ) { throw new Error(); } return result; }