Commit a63822ea authored by nanahira's avatar nanahira

kick lodash out

parent 4ab3e9ec
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
"version": "1.0.22", "version": "1.0.22",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"lodash": "^4.17.21",
"mustache": "^4.2.0", "mustache": "^4.2.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rxjs": "^7.5.6", "rxjs": "^7.5.6",
...@@ -18,7 +17,6 @@ ...@@ -18,7 +17,6 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^28.1.4", "@types/jest": "^28.1.4",
"@types/lodash": "^4.14.182",
"@types/mustache": "^4.1.3", "@types/mustache": "^4.1.3",
"@types/node": "^18.0.3", "@types/node": "^18.0.3",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
...@@ -33,7 +31,7 @@ ...@@ -33,7 +31,7 @@
"typescript": "^4.7.4" "typescript": "^4.7.4"
}, },
"peerDependencies": { "peerDependencies": {
"cordis": "^2.4.4", "cordis": "^2.6.0",
"schemastery": "^3.5.1" "schemastery": "^3.5.1"
} }
}, },
...@@ -1208,12 +1206,6 @@ ...@@ -1208,12 +1206,6 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "dev": true
}, },
"node_modules/@types/lodash": {
"version": "4.14.182",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz",
"integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==",
"dev": true
},
"node_modules/@types/mustache": { "node_modules/@types/mustache": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.3.tgz", "resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.3.tgz",
...@@ -1853,9 +1845,9 @@ ...@@ -1853,9 +1845,9 @@
} }
}, },
"node_modules/cordis": { "node_modules/cordis": {
"version": "2.4.4", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/cordis/-/cordis-2.4.4.tgz", "resolved": "https://registry.npmjs.org/cordis/-/cordis-2.6.0.tgz",
"integrity": "sha512-mXkb7jTEpAwqY5zbE03Tmm2QN5oQs96NJ7VSYWv4yZZyFnkv+GuYwt5s58u97OXDxHKiqbj59iHDW8LIAf/M4A==", "integrity": "sha512-4VUY2x6ufctBr1zYAML3c+b1eXwgY94nkqLP7/icb3QVGXMBJuH4Nztakf6ADVonN5MvgJ06RRawRvmWdx3LxA==",
"peer": true, "peer": true,
"dependencies": { "dependencies": {
"cosmokit": "^1.3.3" "cosmokit": "^1.3.3"
...@@ -5751,12 +5743,6 @@ ...@@ -5751,12 +5743,6 @@
"integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==",
"dev": true "dev": true
}, },
"@types/lodash": {
"version": "4.14.182",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.182.tgz",
"integrity": "sha512-/THyiqyQAP9AfARo4pF+aCGcyiQ94tX/Is2I7HofNRqoYLgN1PBoOWu2/zTA5zMxzP5EFutMtWtGAFRKUe961Q==",
"dev": true
},
"@types/mustache": { "@types/mustache": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.3.tgz", "resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.3.tgz",
...@@ -6204,9 +6190,9 @@ ...@@ -6204,9 +6190,9 @@
} }
}, },
"cordis": { "cordis": {
"version": "2.4.4", "version": "2.6.0",
"resolved": "https://registry.npmjs.org/cordis/-/cordis-2.4.4.tgz", "resolved": "https://registry.npmjs.org/cordis/-/cordis-2.6.0.tgz",
"integrity": "sha512-mXkb7jTEpAwqY5zbE03Tmm2QN5oQs96NJ7VSYWv4yZZyFnkv+GuYwt5s58u97OXDxHKiqbj59iHDW8LIAf/M4A==", "integrity": "sha512-4VUY2x6ufctBr1zYAML3c+b1eXwgY94nkqLP7/icb3QVGXMBJuH4Nztakf6ADVonN5MvgJ06RRawRvmWdx3LxA==",
"peer": true, "peer": true,
"requires": { "requires": {
"cosmokit": "^1.3.3" "cosmokit": "^1.3.3"
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^28.1.4", "@types/jest": "^28.1.4",
"@types/lodash": "^4.14.182",
"@types/mustache": "^4.1.3", "@types/mustache": "^4.1.3",
"@types/node": "^18.0.3", "@types/node": "^18.0.3",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
...@@ -55,11 +54,10 @@ ...@@ -55,11 +54,10 @@
"typescript": "^4.7.4" "typescript": "^4.7.4"
}, },
"peerDependencies": { "peerDependencies": {
"cordis": "^2.4.4", "cordis": "^2.6.0",
"schemastery": "^3.5.1" "schemastery": "^3.5.1"
}, },
"dependencies": { "dependencies": {
"lodash": "^4.17.21",
"mustache": "^4.2.0", "mustache": "^4.2.0",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rxjs": "^7.5.6", "rxjs": "^7.5.6",
......
import { Context } from 'cordis'; import { Context } from 'cordis';
import { Registrar } from './registrar'; import { Registrar } from './registrar';
import { generateRenderer } from './utility/render-object'; import { extractObjectMethod, uniq } from './utility/utility';
import { extractObjectMethod } from './utility/utility';
import { ControlType } from './def'; import { ControlType } from './def';
import { import {
from, from,
...@@ -10,7 +9,6 @@ import { ...@@ -10,7 +9,6 @@ import {
ObservableInput, ObservableInput,
ObservedValueOf, ObservedValueOf,
} from 'rxjs'; } from 'rxjs';
import _ from 'lodash';
import ContextTransformer = Registrar.ContextTransformer; import ContextTransformer = Registrar.ContextTransformer;
import { RegisterMeta } from './utility/register-meta'; import { RegisterMeta } from './utility/register-meta';
...@@ -176,7 +174,7 @@ export class RegistrarAspect<Ctx extends Context, T = any> { ...@@ -176,7 +174,7 @@ export class RegistrarAspect<Ctx extends Context, T = any> {
if (autoScope) { if (autoScope) {
ctx = this.getScopeContext(ctx); ctx = this.getScopeContext(ctx);
} }
const actions = _.uniq( const actions = uniq(
this.registrar.reflector.getArray('CordisTopLevelAction', this.obj), this.registrar.reflector.getArray('CordisTopLevelAction', this.obj),
); );
actions.forEach((action) => actions.forEach((action) =>
......
...@@ -12,8 +12,8 @@ import type { ...@@ -12,8 +12,8 @@ import type {
import { RegistrarAspect } from './registrar-aspect'; import { RegistrarAspect } from './registrar-aspect';
import Schema from 'schemastery'; import Schema from 'schemastery';
import { PluginRegistrar } from './plugin-def'; import { PluginRegistrar } from './plugin-def';
import _ from 'lodash';
import { RegisterMeta } from './utility/register-meta'; import { RegisterMeta } from './utility/register-meta';
import { uniq } from './utility/utility';
declare module 'cordis' { declare module 'cordis' {
interface Context { interface Context {
...@@ -241,7 +241,7 @@ export class Registrar<Ctx extends Context> { ...@@ -241,7 +241,7 @@ export class Registrar<Ctx extends Context> {
if (fork) { if (fork) {
list = [...list, ...fork.using]; list = [...list, ...fork.using];
} }
return _.uniq(list); return uniq(list);
} }
static get reusable() { static get reusable() {
......
import Mustache from 'mustache'; import Mustache from 'mustache';
import _ from 'lodash';
import { ParamRenderer } from '../def'; import { ParamRenderer } from '../def';
import { mapValues } from './utility';
export function renderObject<T = any>( export function renderObject<T = any>(
object: T, object: T,
...@@ -24,7 +24,7 @@ export function renderObject(object: any, view: any, visited: Set<any>): any { ...@@ -24,7 +24,7 @@ export function renderObject(object: any, view: any, visited: Set<any>): any {
} }
if (typeof object === 'object') { if (typeof object === 'object') {
visited.add(object); visited.add(object);
return _.mapValues(object, (value) => renderObject(value, view, visited)); return mapValues(object, (value) => renderObject(value, view, visited));
} }
return object; return object;
} }
......
...@@ -8,3 +8,16 @@ export function extractObjectMethod<T, K extends keyof T>( ...@@ -8,3 +8,16 @@ export function extractObjectMethod<T, K extends keyof T>(
// @ts-ignore // @ts-ignore
return (...args: any[]) => o[key](...args); return (...args: any[]) => o[key](...args);
} }
export function uniq<T>(arr: T[]) {
return [...new Set(arr)];
}
export function mapValues<T extends Record<string, any>, R>(
obj: T,
fn: (v: T[keyof T], k: keyof T) => R,
): Record<keyof T, R> {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, fn(v, k)]));
}
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