Skip to content

Instantly share code, notes, and snippets.

@highercomve
Created November 10, 2015 20:19
Show Gist options
  • Select an option

  • Save highercomve/6ac765f1f3867c386e6b to your computer and use it in GitHub Desktop.

Select an option

Save highercomve/6ac765f1f3867c386e6b to your computer and use it in GitHub Desktop.
const _tap = function _tap(input) {
return new Tap(input);
}
class Tap {
constructor(value) {
this.value = value
}
valueOf () {
return this.value
}
tap (fn) {
if ( arguments.length == 1 ) {
this.value = fn(this.value)
} else {
var args = Array.prototype.slice.call(arguments, 1)
this.value = fn.apply(null, [this.value].concat(args))
}
return this
}
}
export default _tap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment