1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Timestamp = exports.LongWithoutOverridesClass = void 0;
- var long_1 = require("./long");
- /** @public */
- exports.LongWithoutOverridesClass = long_1.Long;
- /** @public */
- var Timestamp = /** @class */ (function (_super) {
- __extends(Timestamp, _super);
- function Timestamp(low, high) {
- var _this = this;
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- ///@ts-expect-error
- if (!(_this instanceof Timestamp))
- return new Timestamp(low, high);
- if (long_1.Long.isLong(low)) {
- _this = _super.call(this, low.low, low.high, true) || this;
- }
- else {
- _this = _super.call(this, low, high, true) || this;
- }
- Object.defineProperty(_this, '_bsontype', {
- value: 'Timestamp',
- writable: false,
- configurable: false,
- enumerable: false
- });
- return _this;
- }
- Timestamp.prototype.toJSON = function () {
- return {
- $timestamp: this.toString()
- };
- };
- /** Returns a Timestamp represented by the given (32-bit) integer value. */
- Timestamp.fromInt = function (value) {
- return new Timestamp(long_1.Long.fromInt(value, true));
- };
- /** Returns a Timestamp representing the given number value, provided that it is a finite number. Otherwise, zero is returned. */
- Timestamp.fromNumber = function (value) {
- return new Timestamp(long_1.Long.fromNumber(value, true));
- };
- /**
- * Returns a Timestamp for the given high and low bits. Each is assumed to use 32 bits.
- *
- * @param lowBits - the low 32-bits.
- * @param highBits - the high 32-bits.
- */
- Timestamp.fromBits = function (lowBits, highBits) {
- return new Timestamp(lowBits, highBits);
- };
- /**
- * Returns a Timestamp from the given string, optionally using the given radix.
- *
- * @param str - the textual representation of the Timestamp.
- * @param optRadix - the radix in which the text is written.
- */
- Timestamp.fromString = function (str, optRadix) {
- return new Timestamp(long_1.Long.fromString(str, true, optRadix));
- };
- /** @internal */
- Timestamp.prototype.toExtendedJSON = function () {
- return { $timestamp: { t: this.high >>> 0, i: this.low >>> 0 } };
- };
- /** @internal */
- Timestamp.fromExtendedJSON = function (doc) {
- return new Timestamp(doc.$timestamp.i, doc.$timestamp.t);
- };
- /** @internal */
- Timestamp.prototype[Symbol.for('nodejs.util.inspect.custom')] = function () {
- return this.inspect();
- };
- Timestamp.prototype.inspect = function () {
- return "new Timestamp(" + this.getLowBits().toString() + ", " + this.getHighBits().toString() + ")";
- };
- Timestamp.MAX_VALUE = long_1.Long.MAX_UNSIGNED_VALUE;
- return Timestamp;
- }(exports.LongWithoutOverridesClass));
- exports.Timestamp = Timestamp;
- //# sourceMappingURL=timestamp.js.map
|