all files / models/highlight/ highlight.js

71.79% Statements 28/39
44.44% Branches 4/9
81.82% Functions 9/11
71.79% Lines 28/39
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 62 63  12× 12×   12× 12×   20×   10×                 12×             15×                                  
"use strict";
var immutable_class_1 = require('immutable-class');
var filter_1 = require('../filter/filter');
var check;
var Highlight = (function () {
    function Highlight(parameters) {
        var owner = parameters.owner;
        Iif (typeof owner !== 'string')
            throw new TypeError('owner must be a string');
        this.owner = owner;
        this.delta = parameters.delta;
    }
    Highlight.isHighlight = function (candidate) {
        return immutable_class_1.isInstanceOf(candidate, Highlight);
    };
    Highlight.fromJS = function (parameters) {
        return new Highlight({
            owner: parameters.owner,
            delta: filter_1.Filter.fromJS(parameters.delta)
        });
    };
    Highlight.prototype.valueOf = function () {
        return {
            owner: this.owner,
            delta: this.delta
        };
    };
    Highlight.prototype.toJS = function () {
        return {
            owner: this.owner,
            delta: this.delta.toJS()
        };
    };
    Highlight.prototype.toJSON = function () {
        return this.toJS();
    };
    Highlight.prototype.toString = function () {
        return "[Highlight " + this.owner + "]";
    };
    Highlight.prototype.equals = function (other) {
        return Highlight.isHighlight(other) &&
            this.owner === other.owner &&
            this.delta.equals(other.delta);
    };
    Highlight.prototype.applyToFilter = function (filter) {
        return filter.applyDelta(this.delta);
    };
    Highlight.prototype.constrainToDimensions = function (dimensions, timeAttribute) {
        var delta = this.delta;
        var newDelta = delta.constrainToDimensions(dimensions, timeAttribute);
        if (newDelta === delta)
            return this;
        if (newDelta.length() === 0)
            return null;
        var value = this.valueOf();
        value.delta = newDelta;
        return new Highlight(value);
    };
    return Highlight;
}());
exports.Highlight = Highlight;
check = Highlight;