magic-string-ast
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -42,2 +42,4 @@ "use strict"; | ||
removeNode(node, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return this; | ||
super.remove(...getNodePos(node, offset)); | ||
@@ -47,2 +49,4 @@ return this; | ||
moveNode(node, index, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return this; | ||
super.move(...getNodePos(node, offset), index); | ||
@@ -52,5 +56,9 @@ return this; | ||
sliceNode(node, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return ""; | ||
return super.slice(...getNodePos(node, offset)); | ||
} | ||
overwriteNode(node, content, { offset = 0, ...options } = {}) { | ||
if (isEmptyNodes(node)) | ||
return this; | ||
const _content = typeof content === "string" ? content : this.sliceNode(content); | ||
@@ -61,2 +69,7 @@ super.overwrite(...getNodePos(node, offset), _content, options); | ||
snipNode(node, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return new import_magic_string.default("", { | ||
// @ts-expect-error | ||
filename: super.filename | ||
}); | ||
return super.snip(...getNodePos(node, offset)); | ||
@@ -71,2 +84,5 @@ } | ||
} | ||
function isEmptyNodes(nodes) { | ||
return Array.isArray(nodes) && nodes.length === 0; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -73,0 +89,0 @@ 0 && (module.exports = { |
@@ -42,2 +42,4 @@ "use strict"; | ||
removeNode(node, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return this; | ||
super.remove(...getNodePos(node, offset)); | ||
@@ -47,2 +49,4 @@ return this; | ||
moveNode(node, index, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return this; | ||
super.move(...getNodePos(node, offset), index); | ||
@@ -52,5 +56,9 @@ return this; | ||
sliceNode(node, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return ""; | ||
return super.slice(...getNodePos(node, offset)); | ||
} | ||
overwriteNode(node, content, { offset = 0, ...options } = {}) { | ||
if (isEmptyNodes(node)) | ||
return this; | ||
const _content = typeof content === "string" ? content : this.sliceNode(content); | ||
@@ -61,2 +69,7 @@ super.overwrite(...getNodePos(node, offset), _content, options); | ||
snipNode(node, { offset = 0 } = {}) { | ||
if (isEmptyNodes(node)) | ||
return new import_magic_string.default("", { | ||
// @ts-expect-error | ||
filename: super.filename | ||
}); | ||
return super.snip(...getNodePos(node, offset)); | ||
@@ -71,2 +84,5 @@ } | ||
} | ||
function isEmptyNodes(nodes) { | ||
return Array.isArray(nodes) && nodes.length === 0; | ||
} | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -73,0 +89,0 @@ 0 && (module.exports = { |
{ | ||
"name": "magic-string-ast", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"packageManager": "pnpm@7.29.3", | ||
@@ -5,0 +5,0 @@ "description": "Extend magic-string for Babel AST.", |
Sorry, the diff of this file is not supported yet
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
12198
244