Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: load lodash method from lodash core #705

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@
"@types/glob": "^7.1.1",
"@types/jest": "^27.4.0",
"@types/lodash": "^4.14.126",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.sortby": "^4.7.6",
"@types/lodash.throttle": "^4.1.6",
"@types/lodash.uniqby": "^4.1.6",
"@types/md5": "^2.1.33",
"@types/node": "^10.14.6",
"@types/node-fetch": "^2.5.12",
Expand Down Expand Up @@ -131,8 +127,6 @@
"jest-jasmine2": "^27.5.1",
"jsdom": "^16.7.0",
"jsdom-worker": "^0.2.1",
"lodash.groupby": "^4.6.0",
"lodash.uniqby": "^4.7.0",
"mkdirp": "^0.5.1",
"node-fetch": "^2.6.1",
"offline-iconfont": "^1.1.0",
Expand Down
2 changes: 0 additions & 2 deletions packages/comments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
},
"dependencies": {
"@opensumi/ide-core-common": "2.16.1",
"lodash.flattendeep": "^4.4.0",
"lodash.groupby": "^4.6.0",
"marked": "4.0.10",
"react-mentions": "^3.3.1"
},
Expand Down
9 changes: 4 additions & 5 deletions packages/comments/src/browser/comments.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import debounce = require('lodash.debounce');
import flattenDeep from 'lodash.flattendeep';
import groupBy from 'lodash.groupby';
import debounce from 'lodash/debounce';
import flattenDeep from 'lodash/flattenDeep';
import groupBy from 'lodash/groupBy';
import { observable, computed, action } from 'mobx';

import { INJECTOR_TOKEN, Injector, Injectable, Autowired } from '@opensumi/di';
Expand Down Expand Up @@ -46,7 +46,6 @@ import {
import { CommentsPanel } from './comments-panel.view';
import { CommentsThread } from './comments-thread';


@Injectable()
export class CommentsService extends Disposable implements ICommentsService {
@Autowired(INJECTOR_TOKEN)
Expand Down Expand Up @@ -432,7 +431,7 @@ export class CommentsService extends Disposable implements ICommentsService {
// 消除 document 引用
model?.dispose();
// 拍平,去掉 undefined
const flattenRange: IRange[] = flattenDeep(res).filter(Boolean);
const flattenRange: IRange[] = flattenDeep(res).filter(Boolean) as IRange[];
deferredRes.resolve(flattenRange);
return flattenRange;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/core-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"jsonc-parser": "^2.1.0",
"keycode": "^2.2.0",
"lodash": "^4.17.15",
"lodash.throttle": "^4.1.1",
"lodash.uniqby": "^4.1.1",
"lzutf8": "^0.5.5",
"marked": "4.0.10",
"mobx": "^5.9.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/core-browser/src/layout/layout-state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Injectable, Autowired } from '@opensumi/di';
import { StorageProvider, IStorage, STORAGE_NAMESPACE, DisposableCollection, ILogger } from '@opensumi/ide-core-common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import omit from 'lodash.omit';
import omit from 'lodash/omit';

import { Injectable, Autowired } from '@opensumi/di';

Expand Down
3 changes: 1 addition & 2 deletions packages/core-browser/src/toolbar/toolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classnames from 'classnames';
import throttle = require('lodash.throttle');
import throttle from 'lodash/throttle';
import React from 'react';
import ReactDOM from 'react-dom';

Expand All @@ -24,7 +24,6 @@ import {
ToolbarRegistryReadyEvent,
} from './types';


export const DEFAULT_TOOLBAR_ACTION_MARGIN = 5;
export const DEFAULT_TOOLBAR_MORE_WIDTH = 14;

Expand Down
2 changes: 1 addition & 1 deletion packages/core-browser/src/utils/react-hooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _debounce from 'lodash.debounce';
import _debounce from 'lodash/debounce';
import { useState, useEffect, DependencyList } from 'react';

import { Disposable, DisposableStore, IDisposable } from '@opensumi/ide-core-common';
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/src/browser/debug-session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import {
Emitter,
Expand Down
3 changes: 1 addition & 2 deletions packages/debug/src/browser/editor/debug-hover-widget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';
import React from 'react';
import ReactDOM from 'react-dom';

Expand Down Expand Up @@ -27,7 +27,6 @@ import { DebugExpressionProvider } from './debug-expression-provider';
import { DebugHoverSource } from './debug-hover-source';
import { DebugHoverView } from './debug-hover.view';


@Injectable()
export class DebugHoverWidget implements IDebugHoverWidget {
static ID = 'debug-hover-widget';
Expand Down
3 changes: 1 addition & 2 deletions packages/debug/src/browser/editor/debug-model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Injector, Injectable, Autowired } from '@opensumi/di';
import { DomListener, IContextKeyService, IReporterService } from '@opensumi/ide-core-browser';
Expand Down Expand Up @@ -31,7 +31,6 @@ import { DebugBreakpointWidget } from './debug-breakpoint-widget';
import { DebugHoverWidget } from './debug-hover-widget';
import * as options from './debug-styles';


@Injectable()
export class DebugModel implements IDebugModel {
protected readonly toDispose = new DisposableCollection();
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/src/browser/model/debug-watch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import throttle = require('lodash.throttle');
import throttle from 'lodash/throttle';

import { DisposableCollection, Emitter, Event, IReporterService } from '@opensumi/ide-core-browser';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';
import { observer } from 'mobx-react-lite';
import React from 'react';

Expand All @@ -10,7 +10,6 @@ import { Key } from '@opensumi/ide-core-browser';
import { DebugConsoleFilterService } from './debug-console-filter.service';
import styles from './debug-console.module.less';


/**
* 调试控制台筛选器
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import throttle = require('lodash.throttle');
import throttle from 'lodash/throttle';

import { Autowired, Injectable, Optional } from '@opensumi/di';
import { DisposableCollection, Emitter, Event, MessageType, ILogger } from '@opensumi/ide-core-common';
Expand All @@ -12,7 +12,6 @@ import { ExpressionContainer, AnsiConsoleNode, DebugConsoleNode, DebugVariableCo

import { DebugConsoleTreeModel } from './debug-console-model';


type ConsoleNodes = DebugConsoleNode | AnsiConsoleNode | DebugVariableContainer;

@Injectable({ multiple: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cls from 'classnames';
import { debounce } from 'lodash';
import debounce from 'lodash/debounce';
import { observer } from 'mobx-react-lite';
import React from 'react';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isEqual } from 'lodash';
import isEqual from 'lodash/isEqual';

import { Injectable, Autowired, INJECTOR_TOKEN, Injector } from '@opensumi/di';
import {
Expand All @@ -20,7 +20,6 @@ import {
import { AbstractContextMenuService, MenuId, ICtxMenuRenderer } from '@opensumi/ide-core-browser/lib/menu/next';
import { DebugProtocol } from '@opensumi/vscode-debugprotocol';


import { DebugSession } from '../../debug-session';
import {
ExpressionContainer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uniqueId } from 'lodash';
import uniqueId from 'lodash/uniqueId';

import { URI } from '@opensumi/ide-core-browser';
import { IHashCalculateService } from '@opensumi/ide-core-common/lib/hash-calculate/hash-calculate';
Expand All @@ -9,7 +9,6 @@ import { MockInjector } from '../../../../../tools/dev-tool/src/mock-injector';
import { EditorDocumentModel } from '../../../src/browser/doc-model/main';
import { IDocPersistentCacheProvider } from '../../../src/common';


describe('EmptyDocCacheImpl', () => {
let injector: MockInjector;
let uri: URI;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { promisify } from 'util';

import { uniqueId } from 'lodash';
import uniqueId from 'lodash/uniqueId';

import { ILoggerManagerClient, URI } from '@opensumi/ide-core-browser';
import { IHashCalculateService } from '@opensumi/ide-core-common/lib/hash-calculate/hash-calculate';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { uniqueId } from 'lodash';
import uniqueId from 'lodash/uniqueId';

import { URI, IEventBus } from '@opensumi/ide-core-browser';
import { IHashCalculateService } from '@opensumi/ide-core-common/lib/hash-calculate/hash-calculate';
Expand All @@ -7,7 +7,6 @@ import { EOL } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
import { isMacintosh, isLinux } from '@opensumi/monaco-editor-core/esm/vs/base/common/platform';
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';


import { createBrowserInjector } from '../../../../../tools/dev-tool/src/injector-helper';
import { MockInjector } from '../../../../../tools/dev-tool/src/mock-injector';
import { createMockedMonaco } from '../../../../monaco/__mocks__/monaco';
Expand All @@ -18,7 +17,6 @@ import {
} from '../../../src/browser/doc-model/types';
import { IDocPersistentCacheProvider } from '../../../src/common';


describe('EditorDocumentModel', () => {
let injector: MockInjector;
let hashCalculateService: IHashCalculateService;
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/browser/breadcrumb/default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Autowired, Injectable } from '@opensumi/di';
import {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/browser/breadcrumb/document-symbol.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Injectable, Autowired } from '@opensumi/di';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Autowired, Injectable } from '@opensumi/di';
import {
Expand Down Expand Up @@ -48,7 +48,6 @@ import {
EditorDocumentModelWillSaveEvent,
} from './types';


export interface EditorDocumentModelConstructionOptions {
eol?: EOL;
encoding?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';

import { isEqual } from 'lodash';
import isEqual from 'lodash/isEqual';

import { RPCProtocol } from '@opensumi/ide-connection/lib/common/rpcProtocol';
import { URI, IContextKeyService } from '@opensumi/ide-core-browser';
Expand Down
1 change: 0 additions & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"address": "^1.1.2",
"glob-to-regexp": "0.4.1",
"is-running": "^2.1.0",
"lodash.clonedeep": "^4.5.0",
"picomatch": "^2.2.1",
"tree-kill": "^1.2.2",
"v8-inspect-profiler": "^0.0.20"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import throttle = require('lodash.throttle');
import throttle from 'lodash/throttle';

import { Injectable, Autowired, Optional } from '@opensumi/di';
import { IRPCProtocol } from '@opensumi/ide-connection';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Injectable, Autowired, Optional } from '@opensumi/di';
import { IRPCProtocol } from '@opensumi/ide-connection';
Expand Down Expand Up @@ -52,7 +52,6 @@ import { viewColumnToResourceOpenOptions } from '../../../common/vscode/converte

import { MainThreadExtensionDocumentData } from './main.thread.doc';


@Injectable({ multiple: true })
export class MainThreadEditorService extends WithEventBus implements IMainThreadEditorsService {
@Autowired(WorkbenchEditorService)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';
import type vscode from 'vscode';

import { IRPCProtocol } from '@opensumi/ide-connection';
Expand All @@ -25,7 +25,6 @@ import { Uri, Position, Range, Selection, TextEditorLineNumbersStyle } from '../

import { TextEditorEdit } from './edit.builder';


export class ExtensionHostEditorService implements IExtensionHostEditorService {
private _editors: Map<string, TextEditorData> = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
********************************************************************************/
// Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/plugin-ext/src/plugin/preference-registry.ts

import cloneDeep = require('lodash.clonedeep');
import cloneDeep from 'lodash/cloneDeep';

import { IRPCProtocol } from '@opensumi/ide-connection';
import { Emitter, Event, PreferenceScope, isObject, mixin, isUndefined } from '@opensumi/ide-core-common';
Expand All @@ -34,7 +34,6 @@ import { Uri } from '../../../common/vscode/ext-types';

import { Configuration, ConfigurationChangeEvent, ConfigurationModel } from './preferences';


interface ConfigurationInspect<T> {
key: string;
defaultValue?: T;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cloneDeep = require('lodash.clonedeep');
import cloneDeep from 'lodash/cloneDeep';

import { Uri, isObject } from '@opensumi/ide-core-common';

Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/node/merge-contributes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* handle `kaitianContributes` and `contributes`
*/
import mergeWith = require('lodash/mergeWith');
import mergeWith from 'lodash/mergeWith';

import { asArray } from '@opensumi/ide-core-common';

Expand Down
1 change: 0 additions & 1 deletion packages/file-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"file-type": "^12.0.0",
"iconv-lite": "^0.6.0",
"jschardet": "3.0.0",
"lodash.debounce": "^4.0.8",
"mv": "^2.1.1",
"nsfw": "^2.1.2",
"trash": "^5.2.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/file-service/src/node/file-service-watcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import paths from 'path';

import * as fs from 'fs-extra';
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';
import nsfw from 'nsfw';

import { IDisposable, Disposable, DisposableCollection, isWindows, URI, isLinux } from '@opensumi/ide-core-common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { debounce } from 'lodash';
import debounce from 'lodash/debounce';
import { action, observable } from 'mobx';

import { Injectable, Autowired } from '@opensumi/di';
Expand Down Expand Up @@ -36,7 +36,6 @@ import { IProgressService } from '@opensumi/ide-core-browser/lib/progress';

import { ViewCollapseChangedEvent } from '../../common';


export interface SectionState {
collapsed: boolean;
hidden: boolean;
Expand Down
3 changes: 1 addition & 2 deletions packages/main-layout/src/browser/layout.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';

import { Injectable, Autowired, INJECTOR_TOKEN, Injector } from '@opensumi/di';
import {
Expand Down Expand Up @@ -40,7 +40,6 @@ import { AccordionService } from './accordion/accordion.service';
import { TabBarHandler } from './tabbar-handler';
import { TabbarService } from './tabbar/tabbar.service';


@Injectable()
export class LayoutService extends WithEventBus implements IMainLayoutService {
@Autowired(INJECTOR_TOKEN)
Expand Down
2 changes: 1 addition & 1 deletion packages/main-layout/src/browser/tabbar/tabbar.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import debounce = require('lodash.debounce');
import debounce from 'lodash/debounce';
import { observable, action, observe, computed } from 'mobx';

import { Injectable, Autowired } from '@opensumi/di';
Expand Down
Loading