• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 24834367427

23 Apr 2026 12:09PM UTC coverage: 78.541% (+0.2%) from 78.391%
24834367427

Pull #1893

github

web-flow
Merge ab101147d into 715603479
Pull Request #1893: Error Handling and Stringify Changes

3126 of 4197 branches covered (74.48%)

Branch coverage included in aggregate %.

801 of 975 new or added lines in 76 files covered. (82.15%)

20 existing lines in 11 files now uncovered.

7056 of 8767 relevant lines covered (80.48%)

173930.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.56
/src/modules/loader/index.ts
1
import type { Context } from '../../types';
2
import { WrongChapterForModuleError } from '../errors';
3
import type {
4
  ModuleInfo,
5
  LoadedBundle,
6
  ImportLoadingOptions,
7
  PartialSourceModule,
8
  Importer,
9
} from '../moduleTypes';
10
import { loadModuleBundleAsync, loadModuleTabsAsync } from './loaders';
11

12
/**
13
 * Initialize module contexts and add UI tabs needed for modules to program context. If the tabs
14
 * array is not provided or left empty, no tabs are loaded.
15
 */
16
async function initModuleContextAsync(moduleName: string, context: Context, tabs?: string[]) {
17
  // Load the module's tabs
18
  if (!(moduleName in context.moduleContexts)) {
120!
19
    context.moduleContexts[moduleName] = {
120✔
20
      state: null,
21
      tabs: tabs ? await loadModuleTabsAsync(tabs) : null,
120✔
22
    };
NEW
23
  } else if (context.moduleContexts[moduleName].tabs === null && tabs) {
×
NEW
24
    context.moduleContexts[moduleName].tabs = await loadModuleTabsAsync(tabs);
×
25
  }
26
}
27

28
/**
29
 * With the given set of Source Modules to Import, load all of the bundles and
30
 * tabs (if `loadTabs` is true) and populate the `context.nativeStorage.loadedModules`
31
 * property.
32
 */
33
export default async function loadSourceModules(
34
  sourceModulesToImport: Record<string, ModuleInfo>,
35
  context: Context,
36
  { loadTabs = true, sourceBundleImporter }: Partial<ImportLoadingOptions> = {},
2,212✔
37
) {
38
  const loadedModules = await Promise.all(
1,106✔
39
    Object.values(sourceModulesToImport).map(async ({ name, tabs, requires, node }) => {
40
      if (requires !== undefined && context.chapter < requires) {
115✔
41
        throw new WrongChapterForModuleError(name, requires, context.chapter, node);
1✔
42
      }
43

44
      await initModuleContextAsync(name, context, loadTabs ? tabs : []);
114✔
45
      const bundle = await loadModuleBundleAsync(name, context, sourceBundleImporter, node);
114✔
46
      return [name, bundle] as [string, LoadedBundle];
114✔
47
    }),
48
  );
49
  const loadedObj = Object.fromEntries(loadedModules);
1,105✔
50
  context.nativeStorage.loadedModules = loadedObj;
1,105✔
51
  return loadedObj;
1,105✔
52
}
53

54
export async function loadSourceModuleTypes(
55
  sourceModulesToImport: Set<string>,
56
  context: Context,
57
  sourceBundleImporter?: Importer<PartialSourceModule>,
58
) {
59
  const loadedModules = await Promise.all(
3✔
60
    [...sourceModulesToImport].map(async moduleName => {
61
      await initModuleContextAsync(moduleName, context);
6✔
62
      const bundle = await loadModuleBundleAsync(moduleName, context, sourceBundleImporter);
6✔
63
      return [moduleName, bundle] as [string, LoadedBundle];
6✔
64
    }),
65
  );
66
  const loadedObj = Object.fromEntries(loadedModules);
3✔
67
  sourceModulesToImport.forEach(module => {
3✔
68
    context.nativeStorage.loadedModuleTypes[module] = loadedObj[module].type_map as Record<
6✔
69
      string,
70
      string
71
    >;
72
  });
73
}
74

75
export { MODULES_STATIC_URL, defaultSourceBundleImporter } from './importers';
76

77
export {
78
  memoizedLoadModuleDocsAsync as memoizedGetModuleDocsAsync,
79
  memoizedLoadModuleManifestAsync as memoizedGetModuleManifestAsync,
80
  setModulesStaticURL,
81
} from './loaders';
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc