-
Notifications
You must be signed in to change notification settings - Fork 0
/
tap.js
35 lines (26 loc) · 948 Bytes
/
tap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void function(root){
'use strict'
var slice = [].slice,
lib = {}
// tap itself
var tap = function(fn){
var val = this.valueOf ? this.valueOf() : this
if ( arguments.length == 1 ) return fn(val)
var args = slice.call(arguments, 1)
return fn.apply(null, [val].concat(args))
}
// tap.mixin
var tapPD = { enumerable: false, value: tap, configurable: true, writable: true }
var mixinOne = function(o){
if ( Object.defineProperty ) Object.defineProperty(o, 'tap', tapPD)
else o.tap = tap
}
lib.mixin = function(){
var args = slice.call(arguments)
args.forEach(mixinOne)
return args[0]
}
// export
if ( typeof module == 'undefined' || module.exports == undefined ) root.tap = lib
else module.exports = lib
}(this)