Bug 1378817 - Stop using sdk/lang/functional in DevTools. r=jdescottes

MozReview-Commit-ID: CXMu5a0KNGT

--HG--
extra : rebase_source : acdb62a83a4f27c566ea6c9dabf0d0dce9b253e0
This commit is contained in:
sole 2017-07-20 17:57:28 +01:00
parent c4a54bfe61
commit b7601c1b53
5 changed files with 43 additions and 3 deletions

View File

@ -15,7 +15,7 @@
* view of the visualization is drawn onto this canvas, providing a crisp zoomed
* in view of the tree map.
*/
const { debounce } = require("sdk/lang/functional");
const { debounce } = require("devtools/shared/debounce");
const EventEmitter = require("devtools/shared/event-emitter");
const HTML_NS = "http://www.w3.org/1999/xhtml";

View File

@ -4,7 +4,7 @@
"use strict";
const { debounce } = require("sdk/lang/functional");
const { debounce } = require("devtools/shared/debounce");
const { lerp } = require("devtools/client/memory/utils");
const EventEmitter = require("devtools/shared/event-emitter");

View File

@ -5,7 +5,7 @@
/* import-globals-from ../includes.js */
const { debounce } = require("sdk/lang/functional");
const { debounce } = require("devtools/shared/debounce");
const flags = require("devtools/shared/flags");
// Globals for d3 stuff

View File

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/**
* From underscore's `_.debounce`
* http://underscorejs.org
* (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Underscore may be freely distributed under the MIT license.
*
* [and in turn extracted from "sdk/lang/functional/concurrent.js"]
*/
exports.debounce = function (fn, wait) {
let timeout, args, context, timestamp, result;
let later = function () {
let last = Date.now() - timestamp;
if (last < wait) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
result = fn.apply(context, args);
context = args = null;
}
};
return function (...aArgs) {
context = this;
args = aArgs;
timestamp = Date.now();
if (!timeout) {
timeout = setTimeout(later, wait);
}
return result;
};
};

View File

@ -46,6 +46,7 @@ DevToolsModules(
'async-utils.js',
'builtin-modules.js',
'content-observer.js',
'debounce.js',
'defer.js',
'deprecated-sync-thenables.js',
'DevToolsUtils.js',