UNPKG

523 BJavaScriptView Raw
1'use strict';
2var anObject = require('../internals/an-object');
3var ordinaryToPrimitive = require('../internals/ordinary-to-primitive');
4
5var $TypeError = TypeError;
6
7// `Date.prototype[@@toPrimitive](hint)` method implementation
8// https://tc39.es/ecma262/#sec-date.prototype-@@toprimitive
9module.exports = function (hint) {
10 anObject(this);
11 if (hint === 'string' || hint === 'default') hint = 'string';
12 else if (hint !== 'number') throw new $TypeError('Incorrect hint');
13 return ordinaryToPrimitive(this, hint);
14};