UNPKG

bson-ts-converter

Version:

Converts BSON timestamps to UNIX timestamps or Date objects.

23 lines (18 loc) 501 B
'use strict'; module.exports = { pretty: function (ts) { return "Timestamp(" + ts.getHighBits() + ", " + ts.getLowBits() + ")"; }, getSeconds: function (ts) { return ts.getHighBits(); }, getOperations: function (ts) { return ts.getLowBits(); }, toObject: function (ts) { return {ts: ts.getHighBits(), op: ts.getLowBits()} }, toDate: function (ts) { return new Date(ts.getHighBits() * 1000); } }