Last active
December 18, 2015 11:30
-
-
Save chilversc/e732391066e12ec37b82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addHost() { | |
var header = { key: this.hostHeaderKey, value: this.hostHeaderValue }; | |
if (!this.hasHeader(header)) { | |
this.hostHeaders.push(header); | |
this.hostHeaderKey = ''; | |
this.hostHeaderValue = ''; | |
} | |
}; | |
hasHeader(header) { | |
// though I'd change hasElement to return boolean, and then just: | |
// return this.hasElement(this.hostHeaders, header, 'key'); | |
var index = this.hasElement(this.hostHeaders, header, 'key'); | |
// purposfully split fetching the index and the comparison to make it obvious | |
// otherwise a random >= 0 at the end could be missed when scanning the code. | |
return index >= 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment