Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
'use strict';

var assert = require('assert');
var assert = {
ok(cond, msg) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably just be function assert(cond, msg) { as we only use the default export of assert here.

if (!cond) {
throw new Error(msg);
}
}
};

var tzdata = require('./lib/tzdata.js');
exports.tzdata = tzdata;

Expand Down Expand Up @@ -85,7 +92,7 @@ function passthrough(fn) {
// there should be no _Date objects in user code when using MockDate.
real_date = this;
} else {
assert(false, 'Unexpected object type');
assert.ok(false, 'Unexpected object type');
}
return real_date[fn].apply(real_date, arguments);
};
Expand Down Expand Up @@ -292,7 +299,7 @@ function unregister(glob) {
}
}
if (glob.Date === MockDate) {
assert(_Date);
assert.ok(_Date, 'need to pass a date');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More accurate message is probably "unregister() called but missing original Date constructor".

glob.Date = _Date;
}
}
Expand Down