Breaking out of a Protractor .filter() or .map() loop
问题 I'm using Protractor and cucumber framework; how do I break out of a .filter or .map loop? I do not want to continue to iterate further if I found a match! Page.prototype.getElementByKey = function (key) { var foundElement = null; return someElement.all(by.css('.someClass')).map(function (rawItem, index) { var itemObject = new ItemObjectClass(rawItem); return itemObject.getItemKey().then(function (foundItemKey) { var matched = String(foundItemKey).trim() === String(key).trim(); console.log('