MCPcopy Create free account
hub / github.com/NativeScript/NativeScript / parseNamedImports

Function parseNamedImports

packages/vite/hmr/server/websocket.ts:168–185  ·  view source on GitHub ↗
(clause: string, binding: NativeScriptImportBinding)

Source from the content-addressed store, hash-verified

166 };
167
168 const parseNamedImports = (clause: string, binding: NativeScriptImportBinding) => {
169 const inner = clause.replace(/^\{/, '').replace(/\}$/, '');
170 inner
171 .split(',')
172 .map((segment) => segment.trim())
173 .filter(Boolean)
174 .forEach((segment) => {
175 const [imported, local] = segment.split(/\s+as\s+/i).map((s) => s.trim());
176 const resolvedImported = imported;
177 const resolvedLocal = local || imported;
178 if (resolvedImported) {
179 binding.named.push({
180 imported: resolvedImported,
181 local: resolvedLocal,
182 });
183 }
184 });
185 };
186
187 // Handle "import ... from 'x'" forms
188 code = code.replace(importRegex, (full: string, pfx: string, clause: string, rawSpec: string) => {

Callers 1

Calls 5

replaceMethod · 0.80
forEachMethod · 0.80
mapMethod · 0.65
filterMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected