main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
774 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | 'use strict';
|
---|
| 2 | var $ = require('../internals/export');
|
---|
| 3 | var fails = require('../internals/fails');
|
---|
| 4 | var toObject = require('../internals/to-object');
|
---|
| 5 | var toPrimitive = require('../internals/to-primitive');
|
---|
| 6 |
|
---|
| 7 | var FORCED = fails(function () {
|
---|
| 8 | return new Date(NaN).toJSON() !== null
|
---|
| 9 | || Date.prototype.toJSON.call({ toISOString: function () { return 1; } }) !== 1;
|
---|
| 10 | });
|
---|
| 11 |
|
---|
| 12 | // `Date.prototype.toJSON` method
|
---|
| 13 | // https://tc39.es/ecma262/#sec-date.prototype.tojson
|
---|
| 14 | $({ target: 'Date', proto: true, arity: 1, forced: FORCED }, {
|
---|
| 15 | // eslint-disable-next-line no-unused-vars -- required for `.length`
|
---|
| 16 | toJSON: function toJSON(key) {
|
---|
| 17 | var O = toObject(this);
|
---|
| 18 | var pv = toPrimitive(O, 'number');
|
---|
| 19 | return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
|
---|
| 20 | }
|
---|
| 21 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.