Skip to content

Commit

Permalink
kill Date#toISOString shim
Browse files Browse the repository at this point in the history
  • Loading branch information
boneskull committed Oct 1, 2017
1 parent 43501a2 commit 7af6611
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 75 deletions.
1 change: 0 additions & 1 deletion .eslintignore
@@ -1,5 +1,4 @@
coverage/
lib/to-iso-string/**/*.js
mocha.js
BUILDTMP
*.fixture.js
19 changes: 0 additions & 19 deletions lib/to-iso-string/LICENSE

This file was deleted.

37 changes: 0 additions & 37 deletions lib/to-iso-string/index.js

This file was deleted.

8 changes: 1 addition & 7 deletions lib/utils.js
Expand Up @@ -16,7 +16,6 @@ var readdirSync = require('fs').readdirSync;
var statSync = require('fs').statSync;
var watchFile = require('fs').watchFile;
var lstatSync = require('fs').lstatSync;
var toISOString = require('./to-iso-string');
var he = require('he');

/**
Expand Down Expand Up @@ -349,12 +348,7 @@ function jsonStringify (object, spaces, depth) {
: val.toString();
break;
case 'date':
var sDate;
if (isNaN(val.getTime())) { // Invalid date
sDate = val.toString();
} else {
sDate = val.toISOString ? val.toISOString() : toISOString(val);
}
var sDate = isNaN(val.getTime()) ? val.toString() : val.toISOString();
val = '[Date: ' + sDate + ']';
break;
case 'buffer':
Expand Down
13 changes: 2 additions & 11 deletions test/unit/utils.spec.js
@@ -1,7 +1,6 @@
'use strict';

var utils = require('../../lib/utils');
var toISOString = require('../../lib/to-iso-string');

describe('lib/utils', function () {
describe('clean', function () {
Expand Down Expand Up @@ -170,18 +169,10 @@ describe('lib/utils', function () {
});

it('should return Date object with .toISOString() + string prefix', function () {
expect(stringify(new Date(0))).to.equal('[Date: ' + shimToISOString(new Date(0)) + ']');
expect(stringify(new Date(0))).to.equal('[Date: ' + new Date(0).toISOString() + ']');

var date = new Date(); // now
expect(stringify(date)).to.equal('[Date: ' + shimToISOString(date) + ']');

function shimToISOString (date) {
if (date.toISOString) {
return date.toISOString();
} else {
return toISOString(date);
}
}
expect(stringify(date)).to.equal('[Date: ' + date.toISOString() + ']');
});

it('should return invalid Date object with .toString() + string prefix', function () {
Expand Down

0 comments on commit 7af6611

Please sign in to comment.