OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2014 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/base.html"> | 8 <link rel="import" href="/tracing/base/base.html"> |
9 | 9 |
10 <script> | 10 <script> |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 const result = {}; | 96 const result = {}; |
97 for (let i = 0; i < arguments.length; i++) { | 97 for (let i = 0; i < arguments.length; i++) { |
98 const object = arguments[i]; | 98 const object = arguments[i]; |
99 for (const j in object) { | 99 for (const j in object) { |
100 result[j] = object[j]; | 100 result[j] = object[j]; |
101 } | 101 } |
102 } | 102 } |
103 return result; | 103 return result; |
104 } | 104 } |
105 | 105 |
106 function dictionaryContainsValue(dict, value) { | |
107 for (const key in dict) { | |
108 if (dict[key] === value) { | |
109 return true; | |
110 } | |
111 } | |
112 return false; | |
113 } | |
114 | |
115 /** | 106 /** |
116 * Returns a new Map with items grouped by the return value of the | 107 * Returns a new Map with items grouped by the return value of the |
117 * specified function being called on each item. | 108 * specified function being called on each item. |
118 * @param {!Array.<!*>} ary The array being iterated through | 109 * @param {!Array.<!*>} ary The array being iterated through |
119 * @param {!function(!*):!*} callback The mapping function between the array | 110 * @param {!function(!*):!*} callback The mapping function between the array |
120 * value and the map key. | 111 * value and the map key. |
121 * @param {*=} opt_this | 112 * @param {*=} opt_this |
122 */ | 113 */ |
123 function groupIntoMap(ary, callback, opt_this, opt_arrayConstructor) { | 114 function groupIntoMap(ary, callback, opt_this, opt_arrayConstructor) { |
124 const arrayConstructor = opt_arrayConstructor || Array; | 115 const arrayConstructor = opt_arrayConstructor || Array; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 if (!b.has(x)) return false; | 331 if (!b.has(x)) return false; |
341 } | 332 } |
342 return true; | 333 return true; |
343 } | 334 } |
344 | 335 |
345 return { | 336 return { |
346 asArray, | 337 asArray, |
347 concatenateObjects, | 338 concatenateObjects, |
348 compareArrays, | 339 compareArrays, |
349 comparePossiblyUndefinedValues, | 340 comparePossiblyUndefinedValues, |
350 dictionaryContainsValue, | |
351 getOnlyElement, | 341 getOnlyElement, |
352 getFirstElement, | 342 getFirstElement, |
353 groupIntoMap, | 343 groupIntoMap, |
354 mapItems, | 344 mapItems, |
355 filterItems, | 345 filterItems, |
356 inPlaceFilter, | 346 inPlaceFilter, |
357 invertArrayOfDicts, | 347 invertArrayOfDicts, |
358 arrayToDict, | 348 arrayToDict, |
359 identity, | 349 identity, |
360 findFirstIndexInArray, | 350 findFirstIndexInArray, |
361 findFirstInArray, | 351 findFirstInArray, |
362 findFirstKeyInDictMatching, | 352 findFirstKeyInDictMatching, |
363 mapValues, | 353 mapValues, |
364 setsEqual, | 354 setsEqual, |
365 }; | 355 }; |
366 }); | 356 }); |
367 </script> | 357 </script> |
OLD | NEW |