1 // Copyright 2013 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.
6 * @fileoverview Some utility functions that don't belong anywhere else in the
10 var util = (function() {
14 * Calls a function for each element in an object/map/hash.
16 * @param obj The object to iterate over.
17 * @param f The function to call on every value in the object. F should have
18 * the following arguments: f(value, key, object) where value is the value
19 * of the property, key is the corresponding key, and obj is the object that
20 * was passed in originally.
21 * @param optObj The object use as 'this' within f.
23 util.object.forEach = function(obj, f, optObj) {
27 if (obj.hasOwnProperty(key)) {
28 f.call(optObj, obj[key], key, obj);
32 util.millisecondsToString = function(timeMillis) {
41 var date = new Date(timeMillis);
42 return pad(date.getUTCHours()) + ':' + pad(date.getUTCMinutes()) + ':' +
43 pad(date.getUTCSeconds()) + ' ' + pad((date.getMilliseconds()) % 1000);