-
-
Save frewsxcv/2012315 to your computer and use it in GitHub Desktop.
using -> for concise functions and => for TCP functions
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
// non-TCP, shorter function | |
a.some((x) → { | |
if (invalid(x)) | |
return true; | |
console.log(x); | |
}) | |
// maximally concise, implicit return | |
a.map((x) → x * 17) | |
// preserves this-binding | |
CSVReader.prototype.read = function(str) { | |
return str.split(/\n/) | |
.map((line) → line.split(this.regexp)); | |
}; | |
// using loop controls from within TCP functions | |
// compare and contrast with: https://gist.github.com/1609202 | |
Mailbox.prototype.extractContents = function(contacts) { | |
for (let a = this.messages, i = 0, n = a.length; i < n; i++) { | |
a[i].headers.forEach((header) → do { | |
if (header.isSpam()) | |
continue; // could use a label but unnecessary | |
let addresses = header.extractAddresses(); | |
addresses.forEach((addr) → { | |
contacts.add(addr.name, addr.email); | |
}); | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment