зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1737988 - [devtools] Remove lodash times usage. r=bomsy.
The whole function could be refactored to not use any lodash method. Differential Revision: https://phabricator.services.mozilla.com/D129608
This commit is contained in:
Родитель
c884c7e108
Коммит
7b01e258e1
|
@ -5,8 +5,6 @@
|
|||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
import { times, zip, flatten } from "lodash";
|
||||
|
||||
import { formatDisplayName } from "../../utils/pause/frames";
|
||||
|
||||
import "./PreviewFunction.css";
|
||||
|
@ -22,19 +20,26 @@ export default class PreviewFunction extends Component {
|
|||
|
||||
renderParams(func) {
|
||||
const { parameterNames = [] } = func;
|
||||
const params = parameterNames.filter(Boolean).map(param => (
|
||||
<span className="param" key={param}>
|
||||
{param}
|
||||
</span>
|
||||
));
|
||||
|
||||
const commas = times(params.length - 1).map((_, i) => (
|
||||
<span className="delimiter" key={i}>
|
||||
{", "}
|
||||
</span>
|
||||
));
|
||||
|
||||
return flatten(zip(params, commas));
|
||||
return parameterNames
|
||||
.filter(Boolean)
|
||||
.map((param, i, arr) => {
|
||||
const elements = [
|
||||
<span className="param" key={param}>
|
||||
{param}
|
||||
</span>,
|
||||
];
|
||||
// if this isn't the last param, add a comma
|
||||
if (i !== arr.length - 1) {
|
||||
elements.push(
|
||||
<span className="delimiter" key={i}>
|
||||
{", "}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return elements;
|
||||
})
|
||||
.flat();
|
||||
}
|
||||
|
||||
jumpToDefinitionButton(func) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче