aboutsummaryrefslogtreecommitdiff
path: root/node_modules/braces/lib/stringify.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/braces/lib/stringify.js')
-rw-r--r--node_modules/braces/lib/stringify.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/braces/lib/stringify.js b/node_modules/braces/lib/stringify.js
new file mode 100644
index 0000000..414b7bc
--- /dev/null
+++ b/node_modules/braces/lib/stringify.js
@@ -0,0 +1,32 @@
+'use strict';
+
+const utils = require('./utils');
+
+module.exports = (ast, options = {}) => {
+ let stringify = (node, parent = {}) => {
+ let invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
+ let invalidNode = node.invalid === true && options.escapeInvalid === true;
+ let output = '';
+
+ if (node.value) {
+ if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) {
+ return '\\' + node.value;
+ }
+ return node.value;
+ }
+
+ if (node.value) {
+ return node.value;
+ }
+
+ if (node.nodes) {
+ for (let child of node.nodes) {
+ output += stringify(child);
+ }
+ }
+ return output;
+ };
+
+ return stringify(ast);
+};
+