Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696663
make-built-in.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
make-built-in.js
View Options
var
fails
=
require
(
'../internals/fails'
);
var
isCallable
=
require
(
'../internals/is-callable'
);
var
hasOwn
=
require
(
'../internals/has-own-property'
);
var
DESCRIPTORS
=
require
(
'../internals/descriptors'
);
var
CONFIGURABLE_FUNCTION_NAME
=
require
(
'../internals/function-name'
).
CONFIGURABLE
;
var
inspectSource
=
require
(
'../internals/inspect-source'
);
var
InternalStateModule
=
require
(
'../internals/internal-state'
);
var
enforceInternalState
=
InternalStateModule
.
enforce
;
var
getInternalState
=
InternalStateModule
.
get
;
// eslint-disable-next-line es-x/no-object-defineproperty -- safe
var
defineProperty
=
Object
.
defineProperty
;
var
CONFIGURABLE_LENGTH
=
DESCRIPTORS
&&
!
fails
(
function
()
{
return
defineProperty
(
function
()
{
/* empty */
},
'length'
,
{
value
:
8
}).
length
!==
8
;
});
var
TEMPLATE
=
String
(
String
).
split
(
'String'
);
var
makeBuiltIn
=
module
.
exports
=
function
(
value
,
name
,
options
)
{
if
(
String
(
name
).
slice
(
0
,
7
)
===
'Symbol('
)
{
name
=
'['
+
String
(
name
).
replace
(
/^Symbol\(([^)]*)\)/
,
'$1'
)
+
']'
;
}
if
(
options
&&
options
.
getter
)
name
=
'get '
+
name
;
if
(
options
&&
options
.
setter
)
name
=
'set '
+
name
;
if
(
!
hasOwn
(
value
,
'name'
)
||
(
CONFIGURABLE_FUNCTION_NAME
&&
value
.
name
!==
name
))
{
if
(
DESCRIPTORS
)
defineProperty
(
value
,
'name'
,
{
value
:
name
,
configurable
:
true
});
else
value
.
name
=
name
;
}
if
(
CONFIGURABLE_LENGTH
&&
options
&&
hasOwn
(
options
,
'arity'
)
&&
value
.
length
!==
options
.
arity
)
{
defineProperty
(
value
,
'length'
,
{
value
:
options
.
arity
});
}
try
{
if
(
options
&&
hasOwn
(
options
,
'constructor'
)
&&
options
.
constructor
)
{
if
(
DESCRIPTORS
)
defineProperty
(
value
,
'prototype'
,
{
writable
:
false
});
// in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable
}
else
if
(
value
.
prototype
)
value
.
prototype
=
undefined
;
}
catch
(
error
)
{
/* empty */
}
var
state
=
enforceInternalState
(
value
);
if
(
!
hasOwn
(
state
,
'source'
))
{
state
.
source
=
TEMPLATE
.
join
(
typeof
name
==
'string'
?
name
:
''
);
}
return
value
;
};
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
// eslint-disable-next-line no-extend-native -- required
Function
.
prototype
.
toString
=
makeBuiltIn
(
function
toString
()
{
return
isCallable
(
this
)
&&
getInternalState
(
this
).
source
||
inspectSource
(
this
);
},
'toString'
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Aug 18, 8:55 PM (21 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3298536
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment