Skip to content

Instantly share code, notes, and snippets.

@Gozala
Last active August 29, 2015 14:00
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 Gozala/11160381 to your computer and use it in GitHub Desktop.
Save Gozala/11160381 to your computer and use it in GitHub Desktop.
function Map(source, f) {
this.f = f
this.source = source
}
MapInput.prototype = Object.create(InputPort.prototype)
MapInput.prototype.take = function() {
var take = this.source.take()
var f = this.f
return Object.create(take, {
valueOf: function() {
return f(take.valueOf())
}
})
}
function map(source, f) {
return new Map(source, f)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment