source: imaps-frontend/node_modules/core-js/internals/ordinary-to-primitive.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 2 weeks ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 723 bytes
Line 
1'use strict';
2var call = require('../internals/function-call');
3var isCallable = require('../internals/is-callable');
4var isObject = require('../internals/is-object');
5
6var $TypeError = TypeError;
7
8// `OrdinaryToPrimitive` abstract operation
9// https://tc39.es/ecma262/#sec-ordinarytoprimitive
10module.exports = function (input, pref) {
11 var fn, val;
12 if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
13 if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val;
14 if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val;
15 throw new $TypeError("Can't convert object to primitive value");
16};
Note: See TracBrowser for help on using the repository browser.