MCPcopy Create free account
hub / github.com/babel/babel / parse

Function parse

packages/babel-core/src/parse.ts:36–54  ·  view source on GitHub ↗
(
  code,
  opts?,
  callback?: FileParseCallback,
)

Source from the content-addressed store, hash-verified

34});
35
36export const parse: Parse = function parse(
37 code,
38 opts?,
39 callback?: FileParseCallback,
40) {
41 if (typeof opts === "function") {
42 callback = opts;
43 opts = undefined;
44 }
45
46 if (callback === undefined) {
47 throw new Error(
48 "Starting from Babel 8.0.0, the 'parse' function expects a callback. If you need to call it synchronously, please use 'parseSync'.",
49 );
50 }
51
52 beginHiddenCallStack(parseRunner.errback)(code, opts, callback);
53 return null;
54};
55
56export function parseSync(...args: Parameters<typeof parseRunner.sync>) {
57 return beginHiddenCallStack(parseRunner.sync)(...args);

Callers

nothing calls this directly

Calls 1

beginHiddenCallStackFunction · 0.90

Tested by

no test coverage detected