Use "lodash/groupBy" (#7438)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-02-01 18:26:59 +02:00
1 parent bd2166b798
commit 0aec777e68
1 file changed
+1 -8
+1 -8
View File
@@ -10,6 +10,7 @@ const readline = require("readline");
const stringify = require("json-stable-stringify");
const fromPairs = require("lodash/fromPairs");
const pick = require("lodash/pick");
const groupBy = require("lodash/groupBy");
const minimist = require("./minimist");
const prettier = require("../../index");
@@ -738,14 +739,6 @@ function indent(str, spaces) {
return str.replace(/^/gm, " ".repeat(spaces));
}
function groupBy(array, getKey) {
return array.reduce((obj, item) => {
const key = getKey(item);
const previousItems = key in obj ? obj[key] : [];
return { ...obj, [key]: previousItems.concat(item) };
}, Object.create(null));
}
function createLogger(logLevel) {
return {
warn: createLogFunc("warn", "yellow"),