mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
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:
parent
c4a54bfe61
commit
b7601c1b53
@ -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";
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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
|
||||
|
39
devtools/shared/debounce.js
Normal file
39
devtools/shared/debounce.js
Normal 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;
|
||||
};
|
||||
};
|
@ -46,6 +46,7 @@ DevToolsModules(
|
||||
'async-utils.js',
|
||||
'builtin-modules.js',
|
||||
'content-observer.js',
|
||||
'debounce.js',
|
||||
'defer.js',
|
||||
'deprecated-sync-thenables.js',
|
||||
'DevToolsUtils.js',
|
||||
|
Loading…
Reference in New Issue
Block a user