vite-plugin-utils
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -21,1 +21,12 @@ export declare function cleanUrl(url: string): string; | ||
export declare function relativeify(relative: string): string; | ||
/** | ||
* Ast tree walk | ||
*/ | ||
export declare function walk(ast: Record<string, any>, visitors: { | ||
[type: string]: (node: Record<string, any>) => void | Promise<void>; | ||
}): Promise<void>; | ||
export declare namespace walk { | ||
var sync: (ast: Record<string, any>, visitors: { | ||
[type: string]: (node: Record<string, any>) => void | Promise<void>; | ||
}) => void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.relativeify = exports.MagicString = exports.cleanUrl = void 0; | ||
exports.walk = exports.relativeify = exports.MagicString = exports.cleanUrl = void 0; | ||
function cleanUrl(url) { | ||
@@ -64,1 +64,37 @@ const queryRE = /\?.*$/s; | ||
exports.relativeify = relativeify; | ||
/** | ||
* Ast tree walk | ||
*/ | ||
async function walk(ast, visitors) { | ||
var _a; | ||
if (!ast) | ||
return; | ||
if (Array.isArray(ast)) { | ||
for (const element of ast) { | ||
await walk(element, visitors); | ||
} | ||
} | ||
else { | ||
for (const key of Object.keys(ast)) { | ||
await (typeof ast[key] === 'object' && walk(ast[key], visitors)); | ||
} | ||
} | ||
await ((_a = visitors[ast.type]) === null || _a === void 0 ? void 0 : _a.call(visitors, ast)); | ||
} | ||
exports.walk = walk; | ||
walk.sync = function walkSync(ast, visitors) { | ||
var _a; | ||
if (!ast) | ||
return; | ||
if (Array.isArray(ast)) { | ||
for (const element of ast) { | ||
walk.sync(element, visitors); | ||
} | ||
} | ||
else { | ||
for (const key of Object.keys(ast)) { | ||
typeof ast[key] === 'object' && walk.sync(ast[key], visitors); | ||
} | ||
} | ||
(_a = visitors[ast.type]) === null || _a === void 0 ? void 0 : _a.call(visitors, ast); | ||
}; |
{ | ||
"name": "vite-plugin-utils", | ||
"description": "A collection of opinionated Vite plugin utils", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
9823
294
0