Remove deps of lodash.

This commit is contained in:
Peng Lyu
2018-05-22 10:25:12 -07:00
parent 31055b3d89
commit bc473934e5
5 changed files with 25 additions and 18 deletions
+5 -6
View File
@@ -137,18 +137,17 @@
"devDependencies": {
"@types/lodash": "^4.14.106",
"@types/node": "*",
"typescript": "^2.1.4",
"webpack": "^4.1.0",
"webpack-cli": "^2.0.10",
"ts-loader": "^4.0.1"
"typescript": "^2.1.4",
"webpack": "^4.1.0",
"webpack-cli": "^2.0.10",
"ts-loader": "^4.0.1"
},
"dependencies": {
"@octokit/rest": "^15.2.6",
"dugite": "^1.63.0",
"markdown-it": "^8.4.0",
"git-credential-node": "^1.1.0",
"lodash": "4.17.5",
"tmp": "^0.0.31",
"moment": "^2.22.1"
}
}
}
@@ -76,3 +76,11 @@ export function isDescendant(parent: string, descendant: string): boolean {
return descendant.startsWith(parent);
}
export function groupBy<T>(arr: T[], fn: (el: T) => string): { [key: string]: T[] } {
return arr.reduce((result, el) => {
const key = fn(el);
result[key] = [...(result[key] || []), el];
return result;
}, Object.create(null));
}
@@ -8,7 +8,6 @@ import * as vscode from 'vscode';
import { parseDiff, parseDiffHunk, getDiffLineByPosition, mapHeadLineToDiffHunkPosition } from '../common/diff';
import { Repository } from '../common//models/repository';
import { Comment } from '../common/models/comment';
import * as _ from 'lodash';
import { Configuration } from '../configuration';
import { parseComments } from '../common/comment';
import { PRGroupTreeItem, FileChangeTreeItem, PRGroupActionTreeItem, PRGroupActionType, PRDescriptionTreeItem } from '../common/treeItems';
@@ -18,6 +17,7 @@ import * as fs from 'fs';
import { PullRequestModel, PRType } from '../common/models/pullRequestModel';
import { PullRequestGitHelper } from '../common/pullRequestGitHelper';
import { ReviewManager } from '../review/reviewManager';
import { groupBy } from '../common/util';
export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | PullRequestModel | PRGroupActionTreeItem | FileChangeTreeItem | PRDescriptionTreeItem>, vscode.TextDocumentContentProvider, vscode.DecorationProvider {
private static _instance: PRProvider;
@@ -207,7 +207,7 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
};
}
let sections = _.groupBy(matchingComments, comment => comment.position);
let sections = groupBy(matchingComments, comment => String(comment.position));
let threads: vscode.CommentThread[] = [];
for (let i in sections) {
@@ -271,11 +271,11 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
return Promise.resolve([]);
}
return await githubRepo.getPullRequest(prNumber);
return [await githubRepo.getPullRequest(prNumber)];
});
return Promise.all(promises).then(values => {
return _.flatten(values).filter(value => value !== null);
return values.reduce((prev, curr) => prev.concat(...curr), []).filter(value => value !== null);
});
}
@@ -285,11 +285,11 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
if (isRemoteForPR) {
return Promise.resolve([]);
}
return await githubRepository.getPullRequests(element.type);
return [await githubRepository.getPullRequests(element.type)];
});
return Promise.all(promises).then(values => {
return _.flatten(values);
return values.reduce((prev, curr) => prev.concat(...curr), []);
});
}
@@ -7,8 +7,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
import { Repository } from '../common/models/repository';
import { FileChangeTreeItem } from '../common/treeItems';
import { mapCommentsToHead, parseDiff, mapHeadLineToDiffHunkPosition, getDiffLineByPosition, parseDiffHunk, mapOldPositionToNew } from '../common/diff';
import * as _ from 'lodash';
import { mapCommentsToHead, parseDiff, mapHeadLineToDiffHunkPosition, getDiffLineByPosition, parseDiffHunk, mapOldPositionToNew, getLastDiffLine } from '../common/diff';
import { GitContentProvider } from './gitContentProvider';
import { Comment } from '../common/models/comment';
import { PullRequestModel } from '../common/models/pullRequestModel';
@@ -17,6 +16,7 @@ import { GitChangeType } from '../common/models/file';
import { FileChangesProvider } from './fileChangesProvider';
import { PullRequestGitHelper } from '../common/pullRequestGitHelper';
import { GitErrorCodes } from '../common/models/gitError';
import { groupBy } from '../common/util';
const REVIEW_STATE = 'git-extended.state';
+4 -4
View File
@@ -2927,14 +2927,14 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"
lodash@4.17.5, lodash@^4.17.4:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.10, lodash@^4.17.2, lodash@^4.17.5, lodash@^4.3.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
lodash@^4.17.4:
version "4.17.5"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
log-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18"