FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/archive/code/node_modules/call-bind/index.js at main · iu5git/JavaScript · GitHub
iu5git
/
JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
21
Star
52
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
archive
/
code
/
node_modules
/
call-bind
/
index.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
47 lines (40 loc) · 1.28 KB
Breadcrumbs
JavaScript
/
archive
/
code
/
node_modules
/
call-bind
/
index.js
Copy path
File metadata and controls
executable file
·
47 lines (40 loc) · 1.28 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
36
37
38
39
40
41
42
43
44
45
46
47
'use strict'
;
var
bind
=
require
(
'function-bind'
)
;
var
GetIntrinsic
=
require
(
'get-intrinsic'
)
;
var
$apply
=
GetIntrinsic
(
'%Function.prototype.apply%'
)
;
var
$call
=
GetIntrinsic
(
'%Function.prototype.call%'
)
;
var
$reflectApply
=
GetIntrinsic
(
'%Reflect.apply%'
,
true
)
||
bind
.
call
(
$call
,
$apply
)
;
var
$gOPD
=
GetIntrinsic
(
'%Object.getOwnPropertyDescriptor%'
,
true
)
;
var
$defineProperty
=
GetIntrinsic
(
'%Object.defineProperty%'
,
true
)
;
var
$max
=
GetIntrinsic
(
'%Math.max%'
)
;
if
(
$defineProperty
)
{
try
{
$defineProperty
(
{
}
,
'a'
,
{
value
:
1
}
)
;
}
catch
(
e
)
{
// IE 8 has a broken defineProperty
$defineProperty
=
null
;
}
}
module
.
exports
=
function
callBind
(
originalFunction
)
{
var
func
=
$reflectApply
(
bind
,
$call
,
arguments
)
;
if
(
$gOPD
&&
$defineProperty
)
{
var
desc
=
$gOPD
(
func
,
'length'
)
;
if
(
desc
.
configurable
)
{
// original length, plus the receiver, minus any additional arguments (after the receiver)
$defineProperty
(
func
,
'length'
,
{
value
:
1
+
$max
(
0
,
originalFunction
.
length
-
(
arguments
.
length
-
1
)
)
}
)
;
}
}
return
func
;
}
;
var
applyBind
=
function
applyBind
(
)
{
return
$reflectApply
(
bind
,
$apply
,
arguments
)
;
}
;
if
(
$defineProperty
)
{
$defineProperty
(
module
.
exports
,
'apply'
,
{
value
:
applyBind
}
)
;
}
else
{
module
.
exports
.
apply
=
applyBind
;
}
Back
|
FazBrowse Home
|
New Git URL