Re-enable index-basics-workers test to see if still times
[chromium-blink-merge.git] / tools / cc-frame-viewer / src / base / range.js
blob9dd9009f9be979fccd4170c4fca5aa649481af89
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 'use strict';
6 /**
7 * @fileoverview Quick range computations.
8 */
9 base.exportTo('base', function() {
11 function Range() {
12 this.isEmpty_ = true;
13 this.min_ = undefined;
14 this.max_ = undefined;
17 Range.prototype = {
18 __proto__: Object.prototype,
20 reset: function() {
21 this.isEmpty_ = true;
22 this.min_ = undefined;
23 this.max_ = undefined;
26 get isEmpty() {
27 return this.isEmpty_;
30 addRange: function(range) {
31 if (range.isEmpty)
32 return;
33 this.addValue(range.min);
34 this.addValue(range.max);
37 addValue: function(value) {
38 if (this.isEmpty_) {
39 this.max_ = value;
40 this.min_ = value;
41 this.isEmpty_ = false;
42 return;
44 this.max_ = Math.max(this.max_, value);
45 this.min_ = Math.min(this.min_, value);
48 get min() {
49 if (this.isEmpty_)
50 return undefined;
51 return this.min_;
54 get max() {
55 if (this.isEmpty_)
56 return undefined;
57 return this.max_;
61 return {
62 Range: Range
65 });