Skip to content

Instantly share code, notes, and snippets.

@rcallahan
Last active December 20, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcallahan/0748c6b40f590d43e096 to your computer and use it in GitHub Desktop.
Save rcallahan/0748c6b40f590d43e096 to your computer and use it in GitHub Desktop.
sciencedirect = {
doi: munk.select("#ddDoi")
.bind(function(a) { return a.href})
.bind(function(a) { return a.split("org/")[1]}),
attachments: [munk.select(".icon-pdf a").href()]
}
/* .bind(fn) composes fn with the previous returned value
fn is additionally called with the values of previous returned values as arguments
(munk.bind(function(){return 1}).bind(function(){return 2}).bind(function(a,b){return [a,b]}))() evaluates to [2,1]
.bind(function(a) {return a.href}) will be common enough to be sugared to .attr("href") or .href()
.select is sugar for .bind(function(a){return Sizzle(a)})
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment