Browse Source

Removes some custom methods for built-ins

main
Eric Amodio 3 years ago
parent
commit
ea291b5f01
8 changed files with 31 additions and 78 deletions
  1. +2
    -2
      src/annotations/annotations.ts
  2. +1
    -1
      src/configuration.ts
  3. +2
    -2
      src/git/git.ts
  4. +1
    -2
      src/git/gitService.ts
  5. +2
    -15
      src/system/array.ts
  6. +1
    -28
      src/system/object.ts
  7. +11
    -14
      src/views/nodes/branchTrackingStatusFilesNode.ts
  8. +11
    -14
      src/views/nodes/statusFilesNode.ts

+ 2
- 2
src/annotations/annotations.ts View File

@ -16,7 +16,7 @@ import { Config, configuration } from '../configuration';
import { Colors, GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatOptions, CommitFormatter, GitCommit } from '../git/git';
import { Objects, Strings } from '../system';
import { Strings } from '../system';
import { toRgba } from '../webviews/apps/shared/colors';
export interface ComputedHeatmap {
@ -171,7 +171,7 @@ export class Annotations {
): RenderOptions {
// Get the character count of all the tokens, assuming there there is a cap (bail if not)
let chars = 0;
for (const token of Objects.values(options.tokenOptions!)) {
for (const token of Object.values(options.tokenOptions!)) {
if (token === undefined) continue;
// If any token is uncapped, kick out and set no max

+ 1
- 1
src/configuration.ts View File

@ -299,7 +299,7 @@ export class Configuration {
return configuration.update(
section,
Objects.areEquivalent(value, inspect.defaultValue) ? undefined : value,
Objects.areEqual(value, inspect.defaultValue) ? undefined : value,
ConfigurationTarget.Global,
);
}

+ 2
- 2
src/git/git.ts View File

@ -7,7 +7,7 @@ import { Uri, window, workspace } from 'vscode';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { Logger } from '../logger';
import { Objects, Strings } from '../system';
import { Strings } from '../system';
import { findGitPath, GitLocation } from './locator';
import { fsExists, run, RunError, RunOptions } from './shell';
import { GitBranchParser, GitLogParser, GitReflogParser, GitStashParser, GitTagParser } from './parsers/parsers';
@ -182,7 +182,7 @@ export async function git(options: GitCommandOptio
function defaultExceptionHandler(ex: Error, cwd: string | undefined, start?: [number, number]): string {
const msg = ex.message || ex.toString();
if (msg != null && msg.length !== 0) {
for (const warning of Objects.values(GitWarnings)) {
for (const warning of Object.values(GitWarnings)) {
if (warning.test(msg)) {
const duration = start !== undefined ? `${Strings.getDurationMilliseconds(start)} ms` : emptyStr;
Logger.warn(

+ 1
- 2
src/git/gitService.ts View File

@ -95,7 +95,6 @@ import {
gate,
Iterables,
log,
Objects,
Promises,
Strings,
TernarySearchTree,
@ -391,7 +390,7 @@ export class GitService implements Disposable {
};
const excludedPaths = [
...Iterables.filterMap(Objects.entries(excludes), ([key, value]) => {
...Iterables.filterMap(Object.entries(excludes), ([key, value]) => {
if (!value) return undefined;
if (key.startsWith('**/')) return key.substring(3);
return key;

+ 2
- 15
src/system/array.ts View File

@ -1,10 +1,6 @@
'use strict';
import {
findLastIndex as _findLastIndex,
intersectionWith as _intersectionWith,
isEqual as _isEqual,
xor as _xor,
} from 'lodash-es';
export { findLastIndex, intersection } from 'lodash-es';
export function chunk<T>(source: T[], size: number): T[][] {
const chunks = [];
@ -62,8 +58,6 @@ export function filterMapAsync(
}, [] as any);
}
export const findLastIndex = _findLastIndex;
export function groupBy<T>(source: T[], groupingKey: (item: T) => string): Record<string, T[]> {
return source.reduce((groupings, current) => {
const value = groupingKey(current);
@ -110,13 +104,6 @@ export function groupByFilterMap(
}, new Map<TKey, TMapped[]>());
}
export const intersection = _intersectionWith;
export const isEqual = _isEqual;
export function areEquivalent<T>(value: T[], other: T[]) {
return _xor(value, other).length === 0;
}
export function isStringArray<T extends any[]>(array: string[] | T): array is string[] {
return typeof array[0] === 'string';
}

+ 1
- 28
src/system/object.ts View File

@ -1,14 +1,6 @@
'use strict';
import { isEqual as _isEqual } from 'lodash-es';
import { areEquivalent as arraysAreEquivalent } from './array';
export function entries<T>(o: Record<string, T>): IterableIterator<[string, T]>;
export function entries<T>(o: Record<number, T>): IterableIterator<[string, T]>;
export function* entries<T>(o: any): IterableIterator<[string, T]> {
for (const key in o) {
yield [key, o[key]];
}
}
export { isEqual as areEqual } from 'lodash-es';
export function flatten(o: any, prefix: string = '', stringify: boolean = false): Record<string, any> {
const flattened = Object.create(null) as Record<string, any>;
@ -49,17 +41,6 @@ function _flatten(flattened: Record, key: string, value: any, strin
}
}
export function isEqual(value: any, other: any) {
return _isEqual(value, other);
}
export function areEquivalent(value: any, other: any) {
if (Array.isArray(value) && Array.isArray(other)) {
return arraysAreEquivalent(value, other);
}
return isEqual(value, other);
}
export function paths(o: Record<string, any>, path?: string): string[] {
const results = [];
@ -74,11 +55,3 @@ export function paths(o: Record, path?: string): string[] {
return results;
}
export function values<T>(o: Record<string, T>): IterableIterator<T>;
export function values<T>(o: Record<number, T>): IterableIterator<T>;
export function* values<T>(o: any): IterableIterator<T> {
for (const key in o) {
yield o[key];
}
}

+ 11
- 14
src/views/nodes/branchTrackingStatusFilesNode.ts View File

@ -9,7 +9,7 @@ import { FileNode, FolderNode } from './folderNode';
import { GitBranch, GitFileWithCommit, GitRevision } from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { StatusFileNode } from './statusFileNode';
import { Arrays, Iterables, Objects, Strings } from '../../system';
import { Arrays, Iterables, Strings } from '../../system';
import { ViewsWithCommits } from '../viewBase';
import { ContextValues, ViewNode } from './viewNode';
@ -70,19 +70,16 @@ export class BranchTrackingStatusFilesNode extends ViewNode {
const groups = Arrays.groupBy(files, s => s.fileName);
let children: FileNode[] = [
...Iterables.map(
Objects.values(groups),
files =>
new StatusFileNode(
this.view,
this,
this.repoPath,
files[files.length - 1],
files.map(s => s.commit),
),
),
];
let children: FileNode[] = Object.values(groups).map(
files =>
new StatusFileNode(
this.view,
this,
this.repoPath,
files[files.length - 1],
files.map(s => s.commit),
),
);
if (this.view.config.files.layout !== ViewFilesLayout.List) {
const hierarchy = Arrays.makeHierarchical(

+ 11
- 14
src/views/nodes/statusFilesNode.ts View File

@ -14,7 +14,7 @@ import {
GitTrackingState,
} from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { Arrays, Iterables, Objects, Strings } from '../../system';
import { Arrays, Iterables, Strings } from '../../system';
import { RepositoriesView } from '../repositoriesView';
import { FileNode, FolderNode } from './folderNode';
import { StatusFileNode } from './statusFileNode';
@ -97,19 +97,16 @@ export class StatusFilesNode extends ViewNode {
const groups = Arrays.groupBy(files, s => s.fileName);
let children: FileNode[] = [
...Iterables.map(
Objects.values(groups),
files =>
new StatusFileNode(
this.view,
this,
repoPath,
files[files.length - 1],
files.map(s => s.commit),
),
),
];
let children: FileNode[] = Object.values(groups).map(
files =>
new StatusFileNode(
this.view,
this,
repoPath,
files[files.length - 1],
files.map(s => s.commit),
),
);
if (this.view.config.files.layout !== ViewFilesLayout.List) {
const hierarchy = Arrays.makeHierarchical(

Loading…
Cancel
Save