| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 var result = {}; | 85 var result = {}; |
| 86 | 86 |
| 87 for (var key in dictionary) { | 87 for (var key in dictionary) { |
| 88 if (predicate(key)) | 88 if (predicate(key)) |
| 89 result[key] = dictionary[key]; | 89 result[key] = dictionary[key]; |
| 90 } | 90 } |
| 91 | 91 |
| 92 return result; | 92 return result; |
| 93 }; | 93 }; |
| 94 | 94 |
| 95 base.mapDictionary = function(dictionary, functor) | |
| 96 { | |
| 97 var result = {}; | |
| 98 | |
| 99 for (var key in dictionary) { | |
| 100 var value = functor(dictionary[key]); | |
| 101 if (typeof value !== 'undefined') | |
| 102 result[key] = value; | |
| 103 } | |
| 104 | |
| 105 return result; | |
| 106 }; | |
| 107 | |
| 108 base.filterTree = function(tree, isLeaf, predicate) | 95 base.filterTree = function(tree, isLeaf, predicate) |
| 109 { | 96 { |
| 110 var filteredTree = {}; | 97 var filteredTree = {}; |
| 111 | 98 |
| 112 function walkSubtree(subtree, directory) | 99 function walkSubtree(subtree, directory) |
| 113 { | 100 { |
| 114 for (var childName in subtree) { | 101 for (var childName in subtree) { |
| 115 var child = subtree[childName]; | 102 var child = subtree[childName]; |
| 116 var childPath = base.joinPath(directory, childName); | 103 var childPath = base.joinPath(directory, childName); |
| 117 if (isLeaf(child)) { | 104 if (isLeaf(child)) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 return null; | 255 return null; |
| 269 return decodeURI(match[1]) | 256 return decodeURI(match[1]) |
| 270 } | 257 } |
| 271 | 258 |
| 272 base.underscoredBuilderName = function(builderName) | 259 base.underscoredBuilderName = function(builderName) |
| 273 { | 260 { |
| 274 return builderName.replace(/[ .()]/g, '_'); | 261 return builderName.replace(/[ .()]/g, '_'); |
| 275 } | 262 } |
| 276 | 263 |
| 277 })(); | 264 })(); |
| OLD | NEW |