Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9342401
function-bind.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
function-bind.js
View Options
'use strict'
;
var
uncurryThis
=
require
(
'../internals/function-uncurry-this'
);
var
aCallable
=
require
(
'../internals/a-callable'
);
var
isObject
=
require
(
'../internals/is-object'
);
var
hasOwn
=
require
(
'../internals/has-own-property'
);
var
arraySlice
=
require
(
'../internals/array-slice'
);
var
NATIVE_BIND
=
require
(
'../internals/function-bind-native'
);
var
$Function
=
Function
;
var
concat
=
uncurryThis
([].
concat
);
var
join
=
uncurryThis
([].
join
);
var
factories
=
{};
var
construct
=
function
(
C
,
argsLength
,
args
)
{
if
(
!
hasOwn
(
factories
,
argsLength
))
{
for
(
var
list
=
[],
i
=
0
;
i
<
argsLength
;
i
++
)
list
[
i
]
=
'a['
+
i
+
']'
;
factories
[
argsLength
]
=
$Function
(
'C,a'
,
'return new C('
+
join
(
list
,
','
)
+
')'
);
}
return
factories
[
argsLength
](
C
,
args
);
};
// `Function.prototype.bind` method implementation
// https://tc39.es/ecma262/#sec-function.prototype.bind
module
.
exports
=
NATIVE_BIND
?
$Function
.
bind
:
function
bind
(
that
/* , ...args */
)
{
var
F
=
aCallable
(
this
);
var
Prototype
=
F
.
prototype
;
var
partArgs
=
arraySlice
(
arguments
,
1
);
var
boundFunction
=
function
bound
(
/* args... */
)
{
var
args
=
concat
(
partArgs
,
arraySlice
(
arguments
));
return
this
instanceof
boundFunction
?
construct
(
F
,
args
.
length
,
args
)
:
F
.
apply
(
that
,
args
);
};
if
(
isObject
(
Prototype
))
boundFunction
.
prototype
=
Prototype
;
return
boundFunction
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 4, 12:42 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3321784
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment