Created
November 10, 2015 20:19
-
-
Save highercomve/6ac765f1f3867c386e6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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