OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2015 The Chromium Authors. All rights reserved. | 3 Copyright 2015 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel="import" href="/tracing/base/event.html"> | 8 <link rel="import" href="/tracing/base/event.html"> |
9 <link rel="import" href="/tracing/base/event_target.html"> | 9 <link rel="import" href="/tracing/base/event_target.html"> |
10 <link rel="import" href="/tracing/base/iteration_helpers.html"> | 10 <link rel="import" href="/tracing/base/iteration_helpers.html"> |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 }; | 227 }; |
228 | 228 |
229 Unit.byName = {}; | 229 Unit.byName = {}; |
230 Unit.byJSONName = {}; | 230 Unit.byJSONName = {}; |
231 | 231 |
232 Unit.fromJSON = function(object) { | 232 Unit.fromJSON = function(object) { |
233 const u = Unit.byJSONName[object]; | 233 const u = Unit.byJSONName[object]; |
234 if (u) { | 234 if (u) { |
235 return u; | 235 return u; |
236 } | 236 } |
237 throw new Error('Unrecognized unit'); | 237 throw new Error(`Unrecognized unit "${object}"`); |
238 }; | 238 }; |
239 | 239 |
240 /** | 240 /** |
241 * Define all combinations of a unit with isDelta and improvementDirection | 241 * Define all combinations of a unit with isDelta and improvementDirection |
242 * flags. For example, the following code: | 242 * flags. For example, the following code: |
243 * | 243 * |
244 * Unit.define({ | 244 * Unit.define({ |
245 * baseUnitName: 'powerInWatts' | 245 * baseUnitName: 'powerInWatts' |
246 * baseJsonName: 'W' | 246 * baseJsonName: 'W' |
247 * formatSpec: { | 247 * formatSpec: { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 maximumFractionDigits: 1 | 425 maximumFractionDigits: 1 |
426 } | 426 } |
427 }); | 427 }); |
428 | 428 |
429 return { | 429 return { |
430 ImprovementDirection, | 430 ImprovementDirection, |
431 Unit, | 431 Unit, |
432 }; | 432 }; |
433 }); | 433 }); |
434 </script> | 434 </script> |
OLD | NEW |