MCPcopy Index your code
hub / github.com/lingodotdev/lingo.dev / composeLoaders

Function composeLoaders

packages/cli/src/cli/loaders/_utils.ts:3–43  ·  view source on GitHub ↗
(
  ...loaders: ILoader<any, any, any>[]
)

Source from the content-addressed store, hash-verified

1import { ILoader, ILoaderDefinition } from "./_types";
2
3export function composeLoaders(
4 ...loaders: ILoader<any, any, any>[]
5): ILoader<any, any> {
6 return {
7 init: async () => {
8 for (const loader of loaders) {
9 await loader.init?.();
10 }
11 },
12 setDefaultLocale(locale: string) {
13 for (const loader of loaders) {
14 loader.setDefaultLocale?.(locale);
15 }
16 return this;
17 },
18 pull: async (locale, input) => {
19 let result: any = input;
20 for (let i = 0; i < loaders.length; i++) {
21 result = await loaders[i].pull(locale, result);
22 }
23 return result;
24 },
25 push: async (locale, data) => {
26 let result: any = data;
27 for (let i = loaders.length - 1; i >= 0; i--) {
28 result = await loaders[i].push(locale, result);
29 }
30 return result;
31 },
32 pullHints: async (originalInput?) => {
33 let result: any = originalInput;
34 for (let i = 0; i < loaders.length; i++) {
35 const subResult = await loaders[i].pullHints?.(result);
36 if (subResult) {
37 result = subResult;
38 }
39 }
40 return result;
41 },
42 };
43}
44
45export function createLoader<I, O, C>(
46 lDefinition: ILoaderDefinition<I, O, C>,

Callers 6

createBucketLoaderFunction · 0.90
createFlatLoaderFunction · 0.90
createCsvLoaderFunction · 0.90
createDatoLoaderFunction · 0.90
createPoLoaderFunction · 0.90
createVariableLoaderFunction · 0.90

Calls 4

initMethod · 0.65
pullMethod · 0.65
pushMethod · 0.65
pullHintsMethod · 0.65

Tested by

no test coverage detected