File tree Expand file tree Collapse file tree 1 file changed +35
-8
lines changed Expand file tree Collapse file tree 1 file changed +35
-8
lines changed Original file line number Diff line number Diff line change @@ -12,14 +12,41 @@ if (!Fp.bind) {
12
12
Fp . bind = function ( context ) {
13
13
var func = this ;
14
14
var args = slice . call ( arguments , 1 ) ;
15
- return args . length > 0 ? function ( ) {
16
- return func . apply (
17
- context || this ,
18
- args . concat ( slice . call ( arguments ) )
19
- ) ;
20
- } : function ( ) {
21
- return func . apply ( context || this , arguments ) ;
22
- } ;
15
+ var bound ;
16
+
17
+ if ( func . prototype ) {
18
+ if ( args . length > 0 ) {
19
+ bound = function ( ) {
20
+ return func . apply (
21
+ ! ( this instanceof func ) && context || this ,
22
+ args . concat ( slice . call ( arguments ) )
23
+ ) ;
24
+ } ;
25
+ } else {
26
+ bound = function ( ) {
27
+ return func . apply (
28
+ ! ( this instanceof func ) && context || this ,
29
+ arguments
30
+ ) ;
31
+ } ;
32
+ }
33
+
34
+ bound . prototype = Object . create ( func . prototype ) ;
35
+
36
+ } else if ( args . length > 0 ) {
37
+ bound = function ( ) {
38
+ return func . apply (
39
+ context || this ,
40
+ args . concat ( slice . call ( arguments ) )
41
+ ) ;
42
+ } ;
43
+ } else {
44
+ bound = function ( ) {
45
+ return func . apply ( context || this , arguments ) ;
46
+ } ;
47
+ }
48
+
49
+ return bound ;
23
50
} ;
24
51
}
25
52
You can’t perform that action at this time.
0 commit comments