зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1737976 - [devtools] Remove lodash isEmpty usage. r=ochameau.
Differential Revision: https://phabricator.services.mozilla.com/D136169
This commit is contained in:
Родитель
7032fd4fcc
Коммит
258b5b15d1
|
@ -8524,8 +8524,6 @@ var babelParser = _interopRequireWildcard(__webpack_require__(685));
|
|||
|
||||
var t = _interopRequireWildcard(__webpack_require__(2));
|
||||
|
||||
var _isEmpty = _interopRequireDefault(__webpack_require__(686));
|
||||
|
||||
var _sources = __webpack_require__(687);
|
||||
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
|
@ -8681,7 +8679,7 @@ function clearASTs() {
|
|||
function traverseAst(sourceId, visitor, state) {
|
||||
const ast = getAst(sourceId);
|
||||
|
||||
if ((0, _isEmpty.default)(ast)) {
|
||||
if (!ast || Object.keys(ast).length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -31257,89 +31255,7 @@ exports.tokTypes = tokTypes;
|
|||
|
||||
|
||||
/***/ }),
|
||||
/* 686 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
var baseKeys = __webpack_require__(656),
|
||||
getTag = __webpack_require__(578),
|
||||
isArguments = __webpack_require__(618),
|
||||
isArray = __webpack_require__(563),
|
||||
isArrayLike = __webpack_require__(599),
|
||||
isBuffer = __webpack_require__(595),
|
||||
isPrototype = __webpack_require__(598),
|
||||
isTypedArray = __webpack_require__(621);
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
var mapTag = '[object Map]',
|
||||
setTag = '[object Set]';
|
||||
|
||||
/** Used for built-in method references. */
|
||||
var objectProto = Object.prototype;
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Checks if `value` is an empty object, collection, map, or set.
|
||||
*
|
||||
* Objects are considered empty if they have no own enumerable string keyed
|
||||
* properties.
|
||||
*
|
||||
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
|
||||
* jQuery-like collections are considered empty if they have a `length` of `0`.
|
||||
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @since 0.1.0
|
||||
* @category Lang
|
||||
* @param {*} value The value to check.
|
||||
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
|
||||
* @example
|
||||
*
|
||||
* _.isEmpty(null);
|
||||
* // => true
|
||||
*
|
||||
* _.isEmpty(true);
|
||||
* // => true
|
||||
*
|
||||
* _.isEmpty(1);
|
||||
* // => true
|
||||
*
|
||||
* _.isEmpty([1, 2, 3]);
|
||||
* // => false
|
||||
*
|
||||
* _.isEmpty({ 'a': 1 });
|
||||
* // => false
|
||||
*/
|
||||
function isEmpty(value) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
if (isArrayLike(value) &&
|
||||
(isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
|
||||
isBuffer(value) || isTypedArray(value) || isArguments(value))) {
|
||||
return !value.length;
|
||||
}
|
||||
var tag = getTag(value);
|
||||
if (tag == mapTag || tag == setTag) {
|
||||
return !value.size;
|
||||
}
|
||||
if (isPrototype(value)) {
|
||||
return !baseKeys(value).length;
|
||||
}
|
||||
for (var key in value) {
|
||||
if (hasOwnProperty.call(value, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
module.exports = isEmpty;
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 686 */,
|
||||
/* 687 */
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
|
@ -46611,20 +46527,18 @@ Object.defineProperty(exports, "__esModule", {
|
|||
exports.parseSourceScopes = parseSourceScopes;
|
||||
exports.buildScopeList = buildScopeList;
|
||||
|
||||
var _isEmpty = _interopRequireDefault(__webpack_require__(686));
|
||||
|
||||
var t = _interopRequireWildcard(__webpack_require__(2));
|
||||
|
||||
var _getFunctionName = _interopRequireDefault(__webpack_require__(691));
|
||||
|
||||
var _ast = __webpack_require__(572);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
||||
|
||||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/* 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/>. */
|
||||
|
@ -46658,7 +46572,7 @@ function isGeneratedId(id) {
|
|||
function parseSourceScopes(sourceId) {
|
||||
const ast = (0, _ast.getAst)(sourceId);
|
||||
|
||||
if ((0, _isEmpty.default)(ast)) {
|
||||
if (!ast || Object.keys(ast).length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,6 @@ describe("ui", () => {
|
|||
const range = { start: 3, end: 5, sourceId: "2" };
|
||||
dispatch(actions.highlightLineRange(range));
|
||||
dispatch(actions.clearHighlightLineRange());
|
||||
expect(getHighlightedLineRange(getState())).toEqual({});
|
||||
expect(getHighlightedLineRange(getState())).toEqual(undefined);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
|
||||
|
||||
import { Component } from "react";
|
||||
import { isEmpty } from "lodash";
|
||||
import { connect } from "../../utils/connect";
|
||||
import { getHighlightedLineRange } from "../../selectors";
|
||||
|
||||
|
@ -29,7 +28,7 @@ class HighlightLines extends Component {
|
|||
|
||||
const { codeMirror } = editor;
|
||||
|
||||
if (isEmpty(highlightedLineRange) || !codeMirror) {
|
||||
if (!highlightedLineRange || !codeMirror) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -46,7 +45,7 @@ class HighlightLines extends Component {
|
|||
|
||||
const { codeMirror } = editor;
|
||||
|
||||
if (isEmpty(highlightedLineRange) || !codeMirror) {
|
||||
if (!highlightedLineRange || !codeMirror) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,8 +80,9 @@ function update(state = initialUIState(), action) {
|
|||
|
||||
case "HIGHLIGHT_LINES":
|
||||
const { start, end, sourceId } = action.location;
|
||||
let lineRange = {};
|
||||
let lineRange;
|
||||
|
||||
// Lines are one-based so the check below is fine.
|
||||
if (start && end && sourceId) {
|
||||
lineRange = { start, end, sourceId };
|
||||
}
|
||||
|
@ -90,7 +91,7 @@ function update(state = initialUIState(), action) {
|
|||
|
||||
case "CLOSE_QUICK_OPEN":
|
||||
case "CLEAR_HIGHLIGHT_LINES":
|
||||
return { ...state, highlightedLineRange: {} };
|
||||
return { ...state, highlightedLineRange: undefined };
|
||||
|
||||
case "OPEN_CONDITIONAL_PANEL":
|
||||
return {
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* 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/>. */
|
||||
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
import * as t from "@babel/types";
|
||||
|
||||
import getFunctionName from "../utils/getFunctionName";
|
||||
|
@ -38,7 +37,7 @@ function isGeneratedId(id) {
|
|||
|
||||
export function parseSourceScopes(sourceId) {
|
||||
const ast = getAst(sourceId);
|
||||
if (isEmpty(ast)) {
|
||||
if (!ast || Object.keys(ast).length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
import parseScriptTags from "parse-script-tags";
|
||||
import * as babelParser from "@babel/parser";
|
||||
import * as t from "@babel/types";
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
import { getSource } from "../sources";
|
||||
|
||||
let ASTs = new Map();
|
||||
|
@ -187,7 +186,7 @@ export function clearASTs() {
|
|||
|
||||
export function traverseAst(sourceId, visitor, state) {
|
||||
const ast = getAst(sourceId);
|
||||
if (isEmpty(ast)) {
|
||||
if (!ast || Object.keys(ast).length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче