From f56309f448510259af230cc9baa294b306308247 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Thu, 22 May 2025 00:00:11 +0700 Subject: [PATCH] chore(lib/modules/finders/filters): update docs --- lib/modules/src/finders/filters.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/modules/src/finders/filters.ts b/lib/modules/src/finders/filters.ts index ec00224..6326fa0 100644 --- a/lib/modules/src/finders/filters.ts +++ b/lib/modules/src/finders/filters.ts @@ -74,7 +74,7 @@ export type ByProps = = Record>( * * @example * ```ts - * const React = await findModule(byProps('createElement')) + * const [React] = lookupModule(byProps('createElement')) * // const React: typeof import('react') * ``` */ @@ -121,7 +121,7 @@ export type BySingleProp = >(prop: keyof T) => Fil * * @example * ```ts - * const FormSwitchModule = await findModule(bySingleProp('FormSwitch')) + * const [FormSwitchModule] = lookupModule(bySingleProp('FormSwitch')) * // const FormSwitchModule: { FormSwitch: any } * ``` */ @@ -142,15 +142,15 @@ export type ByName = (name: string) => Filter * - * const MyComponent = await findModule(byName('MyComponent')) + * const [MyComponent] = lookupModule(byName('MyComponent')) * // const MyComponent: MyComponent & { name: 'MyComponent' } * ``` * @@ -160,7 +160,7 @@ export type ByName = (name: string) => Filter('SomeClass')) + * const [SomeClass] = lookupModule(byName<{ new(param: string): SomeClass }>('SomeClass')) * // const SomeClass: { new(): SomeClass, name: 'SomeClass' } */ export const byName = createFilterGenerator>( @@ -190,18 +190,18 @@ type ByDependencies = (deps: ComparableDependencyMap) => Filter * * @example * ```ts - * const Logger = await findModule(byDependencies([4, undefined, 2])) + * const [Logger] = lookupModule(byDependencies([4, undefined, 2])) * // or - * const Logger = await findModule(byDependencies([4, , 2])) + * const [Logger] = lookupModule(byDependencies([4, , 2])) * // or with relative dependencies * // If Logger's module ID is 20, [19, ..., ..., 2] would match: - * const Logger = await findModule(byDependencies([relativeDep(-1), , 2])) + * const [Logger] = lookupModule(byDependencies([relativeDep(-1), , 2])) * // or with nested dependencies * // The last dependency would need to have zero dependencies: - * const Logger = await findModule(byDependencies([4, , []])) + * const [Logger] = lookupModule(byDependencies([4, , []])) * // or with loose dependencies * // Module having 4 dependencies [4, ...], [4, ..., ...], [4, ..., ..., ...] etc. would match: - * const SomeOtherModule = await findModule(byDependencies(looseDeps([4, ,]))) + * const [SomeOtherModule] = lookupModule(byDependencies(looseDeps([4, ,]))) * ``` */ export const byDependencies = createFilterGenerator>( @@ -308,7 +308,7 @@ export type Every = { * * @example * ```ts - * const SomeModule = await findModule(every( + * const [SomeModule] = lookupModule(every( * byProps('x', 'name'), * byName('SomeName'), * byDependencies([1, 485, , 2]), @@ -350,7 +350,7 @@ export type Some = { * * @example * ```ts - * const SomeModule = await findModule(some( + * const [SomeModule] = lookupModule(some( * byProps('x', 'name'), * byName('SomeName'), * byDependencies([1, 485, , 2]), @@ -386,7 +386,7 @@ export type ModuleStateAware = ( * ```ts * // will filter byProps('x') for initialized modules * // and byDependencies([1, 485, , 2]) for uninitialized modules - * const SomeModule = await findModule(moduleStateAware( + * const [SomeModule] = lookupModule(moduleStateAware( * byProps('x'), * byDependencies([1, 485, , 2]), * )) @@ -423,7 +423,7 @@ export type PreferExports = ( * ```ts * // will filter byProps('x') for modules with proper exports * // and byDependencies([1, 485, , 2]) for without proper exports (uninitialized or bad) - * const SomeModule = await findModule(preferExports( + * const [SomeModule] = lookupModule(preferExports( * byProps('x'), * byDependencies([1, 485, , 2]), * ))