You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
561 B
22 lines
561 B
4 years ago
|
'use strict';
|
||
|
|
||
|
var GetIntrinsic = require('../GetIntrinsic');
|
||
|
|
||
|
var $Number = GetIntrinsic('%Number%');
|
||
|
|
||
|
var isPrimitive = require('../helpers/isPrimitive');
|
||
|
|
||
|
var ToPrimitive = require('./ToPrimitive');
|
||
|
var ToNumber = require('./ToNumber');
|
||
|
var Type = require('./Type');
|
||
|
|
||
|
// https://www.ecma-international.org/ecma-262/6.0/#sec-tonumber
|
||
|
|
||
|
module.exports = function ToNumeric(argument) {
|
||
|
var primValue = isPrimitive(argument) ? argument : ToPrimitive(argument, $Number);
|
||
|
if (Type(primValue) === 'BigInt') {
|
||
|
return primValue;
|
||
|
}
|
||
|
return ToNumber(primValue);
|
||
|
};
|