Skip to content

Instantly share code, notes, and snippets.

Last active December 18, 2015 11:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
addHost() {
var header = { key: this.hostHeaderKey, value: this.hostHeaderValue };
if (!this.hasHeader(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