Lazy decoration (part 8, consistent call order) (#4153)
* Lazy decoration (part 8, consistent call order) * Dedupe * Flatten, no extra calls * Dedupe more * Adjust lazyVariants * Additional flatten * Adjust lazyVariants * Reorder name/index * Deupe strings * Flatten createkeys * Adjust
This commit is contained in:
@@ -97,11 +97,11 @@ function injectFunctions (instanceId: string, api: ApiInterfaceRx, derives: Deri
|
||||
)
|
||||
);
|
||||
|
||||
const getKeys = (s: string) =>
|
||||
Object.keys(derives[s]);
|
||||
const getKeys = (section: string) =>
|
||||
Object.keys(derives[section]);
|
||||
|
||||
const creator = (s: string, m: string) =>
|
||||
derives[s][m](instanceId, api);
|
||||
const creator = (section: string, method: string) =>
|
||||
derives[section][method](instanceId, api);
|
||||
|
||||
const result: Record<string, Record<string, AnyFunction>> = {};
|
||||
const names = Object.keys(derives);
|
||||
|
||||
@@ -8,5 +8,9 @@ type LazySection <T> = Record<string, T>;
|
||||
type LazyRecord <T> = Record<string, LazySection<T>>;
|
||||
|
||||
export function lazyDeriveSection <T> (result: LazyRecord<T>, section: string, getKeys: (s: string) => string[], creator: (s: string, m: string) => T): void {
|
||||
lazyMethod(result, section, (s) => lazyMethods(getKeys(s), (m) => creator(s, m)));
|
||||
lazyMethod(result, section, () =>
|
||||
lazyMethods({}, getKeys(section), (method: string) =>
|
||||
creator(section, method)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user