all files / models/max-time/ max-time.js

87.1% Statements 27/31
66.67% Branches 4/6
81.82% Functions 9/11
87.1% Lines 27/31
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61  12× 12×   20×                         10× 10×     10×                 12×             15×        
"use strict";
var immutable_class_1 = require('immutable-class');
var check;
var MaxTime = (function () {
    function MaxTime(parameters) {
        this.time = parameters.time;
        this.updated = parameters.updated;
    }
    MaxTime.isMaxTime = function (candidate) {
        return immutable_class_1.isInstanceOf(candidate, MaxTime);
    };
    MaxTime.fromNow = function () {
        var now = new Date();
        return new MaxTime({
            time: now,
            updated: now
        });
    };
    MaxTime.fromDate = function (time) {
        return new MaxTime({
            time: time,
            updated: new Date()
        });
    };
    MaxTime.fromJS = function (parameters) {
        var time = new Date(parameters.time);
        Iif (isNaN(time)) {
            throw new Error('maxTime must have a valid `time`');
        }
        return new MaxTime({
            time: time,
            updated: new Date((parameters.updated || parameters.time))
        });
    };
    MaxTime.prototype.valueOf = function () {
        return {
            time: this.time,
            updated: this.updated
        };
    };
    MaxTime.prototype.toJS = function () {
        return {
            time: this.time,
            updated: this.updated
        };
    };
    MaxTime.prototype.toJSON = function () {
        return this.toJS();
    };
    MaxTime.prototype.toString = function () {
        return "[MaxTime: " + this.time.toISOString() + "]";
    };
    MaxTime.prototype.equals = function (other) {
        return MaxTime.isMaxTime(other) &&
            this.time.valueOf() === other.time.valueOf();
    };
    return MaxTime;
}());
exports.MaxTime = MaxTime;
check = MaxTime;