Commit d7486f3e authored by nanahira's avatar nanahira

bump and kick lodash

parent 5c14fa72
#!/bin/bash
npm install --save \
lodash
npm install --save-dev \
@types/node \
@types/lodash \
typescript \
'@typescript-eslint/eslint-plugin@^4.28.2' \
'@typescript-eslint/parser@^4.28.2 '\
'eslint@^7.30.0' \
'eslint-config-prettier@^8.3.0' \
'eslint-plugin-prettier@^3.4.0' \
prettier
This diff is collapsed.
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
"peerDependencies": { "peerDependencies": {
"@nestjs/common": "^9.0.3 || ^8.0.0", "@nestjs/common": "^9.0.3 || ^8.0.0",
"@nestjs/core": "^9.0.3 || ^8.0.0", "@nestjs/core": "^9.0.3 || ^8.0.0",
"koishi": "^4.11.0", "koishi": "^4.11.1",
"rxjs": "^7.5.5" "rxjs": "^7.5.5"
}, },
"devDependencies": { "devDependencies": {
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
"@types/jest": "^29.2.0", "@types/jest": "^29.2.0",
"@types/koa": "^2.13.4", "@types/koa": "^2.13.4",
"@types/koa-bodyparser": "^4.3.7", "@types/koa-bodyparser": "^4.3.7",
"@types/lodash": "^4.14.175",
"@types/node": "^16.10.2", "@types/node": "^16.10.2",
"@types/supertest": "^2.0.11", "@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.32.0", "@typescript-eslint/eslint-plugin": "^4.32.0",
...@@ -66,8 +65,7 @@ ...@@ -66,8 +65,7 @@
"@types/ws": "^8.5.3", "@types/ws": "^8.5.3",
"koa": "^2.13.4", "koa": "^2.13.4",
"koa-bodyparser": "^4.3.0", "koa-bodyparser": "^4.3.0",
"koishi-thirdeye": "^11.1.20", "koishi-thirdeye": "^11.1.21",
"lodash": "^4.17.21",
"typed-reflector": "^1.0.11", "typed-reflector": "^1.0.11",
"ws": "^8.7.0" "ws": "^8.7.0"
}, },
......
...@@ -12,7 +12,6 @@ import { ...@@ -12,7 +12,6 @@ import {
KoishiCommandInterceptorRegistration, KoishiCommandInterceptorRegistration,
KoishiModuleOptions, KoishiModuleOptions,
} from '../utility/koishi.interfaces'; } from '../utility/koishi.interfaces';
import _ from 'lodash';
import { KoishiContextService } from './koishi-context.service'; import { KoishiContextService } from './koishi-context.service';
import { Module } from '@nestjs/core/injector/module'; import { Module } from '@nestjs/core/injector/module';
import { KoishiMetadataFetcherService } from '../koishi-metadata-fetcher/koishi-metadata-fetcher.service'; import { KoishiMetadataFetcherService } from '../koishi-metadata-fetcher/koishi-metadata-fetcher.service';
...@@ -22,6 +21,7 @@ import { registerAtLeastEach } from '../utility/take-first-value'; ...@@ -22,6 +21,7 @@ import { registerAtLeastEach } from '../utility/take-first-value';
import { koishiRegistrar } from 'koishi-thirdeye/dist/src/registrar'; import { koishiRegistrar } from 'koishi-thirdeye/dist/src/registrar';
import { CommandConfigExtended } from 'koishi-thirdeye/dist/src/def'; import { CommandConfigExtended } from 'koishi-thirdeye/dist/src/def';
import { map } from 'rxjs'; import { map } from 'rxjs';
import { uniq } from '../utility/utility';
@Injectable() @Injectable()
export class KoishiMetascanService { export class KoishiMetascanService {
...@@ -111,20 +111,15 @@ export class KoishiMetascanService { ...@@ -111,20 +111,15 @@ export class KoishiMetascanService {
fun: (ctx: Context, instance: any) => T, fun: (ctx: Context, instance: any) => T,
): T[] { ): T[] {
const modules = Array.from(this.moduleContainer.values()); const modules = Array.from(this.moduleContainer.values());
return _.flatten( return modules.flatMap((module) => {
modules.map((module) => { const moduleCtx = this.ctxService.getModuleCtx(ctx, module);
const moduleCtx = this.ctxService.getModuleCtx(ctx, module); const allProviders = this.getAllActiveProvidersFromModule(module);
const allProviders = this.getAllActiveProvidersFromModule(module); return allProviders.map((provider) => {
return allProviders.map((provider) => { const instance = provider.instance;
const instance = provider.instance; const providerCtx = this.ctxService.getProviderCtx(moduleCtx, instance);
const providerCtx = this.ctxService.getProviderCtx( return fun(providerCtx, instance);
moduleCtx, });
instance, });
);
return fun(providerCtx, instance);
});
}),
);
} }
preRegisterContext(ctx: Context) { preRegisterContext(ctx: Context) {
...@@ -138,7 +133,7 @@ export class KoishiMetascanService { ...@@ -138,7 +133,7 @@ export class KoishiMetascanService {
key: string, key: string,
command: Command, command: Command,
) { ) {
const interceptorDefs: KoishiCommandInterceptorRegistration[] = _.uniq( const interceptorDefs: KoishiCommandInterceptorRegistration[] = uniq(
this.metaFetcher.getPropertyMetadataArray( this.metaFetcher.getPropertyMetadataArray(
KoishiCommandInterceptorDef, KoishiCommandInterceptorDef,
instance, instance,
......
export function uniq<T>(arr: T[]) {
return [...new Set(arr)];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment