Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Unified Diff: Tools/GardeningServer/scripts/base.js

Issue 400423002: Remove base.* methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Tools/GardeningServer/run-unittests.html ('k') | Tools/GardeningServer/scripts/base_unittests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Tools/GardeningServer/scripts/base.js
diff --git a/Tools/GardeningServer/scripts/base.js b/Tools/GardeningServer/scripts/base.js
index 7547978ada63985ed98d3ea8f45fd2185a951a2a..ee59bcec83627451684b6e2880f3bbf7591129fc 100644
--- a/Tools/GardeningServer/scripts/base.js
+++ b/Tools/GardeningServer/scripts/base.js
@@ -27,79 +27,6 @@ var base = base || {};
(function(){
-base.endsWith = function(string, suffix)
-{
- if (suffix.length > string.length)
- return false;
- var expectedIndex = string.length - suffix.length;
- return string.lastIndexOf(suffix) == expectedIndex;
-};
-
-base.joinPath = function(parent, child)
-{
- if (parent.length == 0)
- return child;
- return parent + '/' + child;
-};
-
-base.trimExtension = function(url)
-{
- var index = url.lastIndexOf('.');
- if (index == -1)
- return url;
- return url.substr(0, index);
-}
-
-base.uniquifyArray = function(array)
-{
- var seen = {};
- var result = [];
- array.forEach(function(value) {
- if (seen[value])
- return;
- seen[value] = true;
- result.push(value);
- });
- return result;
-};
-
-base.filterTree = function(tree, isLeaf, predicate)
-{
- var filteredTree = {};
-
- function walkSubtree(subtree, directory)
- {
- for (var childName in subtree) {
- var child = subtree[childName];
- var childPath = base.joinPath(directory, childName);
- if (isLeaf(child)) {
- if (predicate(child))
- filteredTree[childPath] = child;
- continue;
- }
- walkSubtree(child, childPath);
- }
- }
-
- walkSubtree(tree, '');
- return filteredTree;
-};
-
-base.parseJSONP = function(jsonp)
-{
- if (!jsonp)
- return {};
-
- if (!jsonp.match(/^[^{[]*\(/))
- return JSON.parse(jsonp);
-
- var startIndex = jsonp.indexOf('(') + 1;
- var endIndex = jsonp.lastIndexOf(')');
- if (startIndex == 0 || endIndex == -1)
- return {};
- return JSON.parse(jsonp.substr(startIndex, endIndex - startIndex));
-};
-
// This is effectively a cache of possibly-resolved promises.
base.AsynchronousCache = function(fetch)
{
@@ -125,38 +52,4 @@ base.AsynchronousCache.prototype.clear = function()
this._promiseCache = {};
};
-// Based on http://src.chromium.org/viewvc/chrome/trunk/src/chrome/browser/resources/shared/js/cr/ui.js
-base.extends = function(base, prototype)
-{
- var extended = function() {
- var element = typeof base == 'string' ? document.createElement(base) : base.call(this);
- extended.prototype.__proto__ = element.__proto__;
- element.__proto__ = extended.prototype;
- var singleton = element.init && element.init.apply(element, arguments);
- if (singleton)
- return singleton;
- return element;
- }
-
- extended.prototype = prototype;
- return extended;
-}
-
-base.underscoredBuilderName = function(builderName)
-{
- return builderName.replace(/[ .()]/g, '_');
-}
-
-base.queryParam = function(params)
-{
- var result = []
- Object.keys(params, function(key, value) {
- result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
- });
- // FIXME: Remove the conversion of space to plus. This is just here
- // to remain compatible with jQuery.param, but there's no reason to
- // deviate from the built-in encodeURIComponent behavior.
- return result.join('&').replace(/%20/g, '+');
-}
-
})();
« no previous file with comments | « Tools/GardeningServer/run-unittests.html ('k') | Tools/GardeningServer/scripts/base_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698