Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9347578
ordinary-to-primitive.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
705 B
Subscribers
None
ordinary-to-primitive.js
View Options
var
call
=
require
(
'../internals/function-call'
);
var
isCallable
=
require
(
'../internals/is-callable'
);
var
isObject
=
require
(
'../internals/is-object'
);
var
$TypeError
=
TypeError
;
// `OrdinaryToPrimitive` abstract operation
// https://tc39.es/ecma262/#sec-ordinarytoprimitive
module
.
exports
=
function
(
input
,
pref
)
{
var
fn
,
val
;
if
(
pref
===
'string'
&&
isCallable
(
fn
=
input
.
toString
)
&&
!
isObject
(
val
=
call
(
fn
,
input
)))
return
val
;
if
(
isCallable
(
fn
=
input
.
valueOf
)
&&
!
isObject
(
val
=
call
(
fn
,
input
)))
return
val
;
if
(
pref
!==
'string'
&&
isCallable
(
fn
=
input
.
toString
)
&&
!
isObject
(
val
=
call
(
fn
,
input
)))
return
val
;
throw
$TypeError
(
"Can't convert object to primitive value"
);
};
File Metadata
Details
Attached
Mime Type
text/x-Algol68
Expires
Jul 4 2025, 5:42 PM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3353001
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment