node_modules: upgrade

This commit is contained in:
Dawid Dziurla
2024-01-17 10:08:10 +01:00
parent 9ff0bc8d99
commit 00765f79cf
320 changed files with 31840 additions and 1039 deletions

36
node_modules/yaml/dist/visit.js generated vendored
View File

@@ -1,6 +1,6 @@
'use strict';
var Node = require('./nodes/Node.js');
var identity = require('./nodes/identity.js');
const BREAK = Symbol('break visit');
const SKIP = Symbol('skip children');
@@ -37,7 +37,7 @@ const REMOVE = Symbol('remove node');
*/
function visit(node, visitor) {
const visitor_ = initVisitor(visitor);
if (Node.isDocument(node)) {
if (identity.isDocument(node)) {
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
if (cd === REMOVE)
node.contents = null;
@@ -56,12 +56,12 @@ visit.SKIP = SKIP;
visit.REMOVE = REMOVE;
function visit_(key, node, visitor, path) {
const ctrl = callVisitor(key, node, visitor, path);
if (Node.isNode(ctrl) || Node.isPair(ctrl)) {
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
replaceNode(key, path, ctrl);
return visit_(key, ctrl, visitor, path);
}
if (typeof ctrl !== 'symbol') {
if (Node.isCollection(node)) {
if (identity.isCollection(node)) {
path = Object.freeze(path.concat(node));
for (let i = 0; i < node.items.length; ++i) {
const ci = visit_(i, node.items[i], visitor, path);
@@ -75,7 +75,7 @@ function visit_(key, node, visitor, path) {
}
}
}
else if (Node.isPair(node)) {
else if (identity.isPair(node)) {
path = Object.freeze(path.concat(node));
const ck = visit_('key', node.key, visitor, path);
if (ck === BREAK)
@@ -124,7 +124,7 @@ function visit_(key, node, visitor, path) {
*/
async function visitAsync(node, visitor) {
const visitor_ = initVisitor(visitor);
if (Node.isDocument(node)) {
if (identity.isDocument(node)) {
const cd = await visitAsync_(null, node.contents, visitor_, Object.freeze([node]));
if (cd === REMOVE)
node.contents = null;
@@ -143,12 +143,12 @@ visitAsync.SKIP = SKIP;
visitAsync.REMOVE = REMOVE;
async function visitAsync_(key, node, visitor, path) {
const ctrl = await callVisitor(key, node, visitor, path);
if (Node.isNode(ctrl) || Node.isPair(ctrl)) {
if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
replaceNode(key, path, ctrl);
return visitAsync_(key, ctrl, visitor, path);
}
if (typeof ctrl !== 'symbol') {
if (Node.isCollection(node)) {
if (identity.isCollection(node)) {
path = Object.freeze(path.concat(node));
for (let i = 0; i < node.items.length; ++i) {
const ci = await visitAsync_(i, node.items[i], visitor, path);
@@ -162,7 +162,7 @@ async function visitAsync_(key, node, visitor, path) {
}
}
}
else if (Node.isPair(node)) {
else if (identity.isPair(node)) {
path = Object.freeze(path.concat(node));
const ck = await visitAsync_('key', node.key, visitor, path);
if (ck === BREAK)
@@ -200,34 +200,34 @@ function initVisitor(visitor) {
function callVisitor(key, node, visitor, path) {
if (typeof visitor === 'function')
return visitor(key, node, path);
if (Node.isMap(node))
if (identity.isMap(node))
return visitor.Map?.(key, node, path);
if (Node.isSeq(node))
if (identity.isSeq(node))
return visitor.Seq?.(key, node, path);
if (Node.isPair(node))
if (identity.isPair(node))
return visitor.Pair?.(key, node, path);
if (Node.isScalar(node))
if (identity.isScalar(node))
return visitor.Scalar?.(key, node, path);
if (Node.isAlias(node))
if (identity.isAlias(node))
return visitor.Alias?.(key, node, path);
return undefined;
}
function replaceNode(key, path, node) {
const parent = path[path.length - 1];
if (Node.isCollection(parent)) {
if (identity.isCollection(parent)) {
parent.items[key] = node;
}
else if (Node.isPair(parent)) {
else if (identity.isPair(parent)) {
if (key === 'key')
parent.key = node;
else
parent.value = node;
}
else if (Node.isDocument(parent)) {
else if (identity.isDocument(parent)) {
parent.contents = node;
}
else {
const pt = Node.isAlias(parent) ? 'alias' : 'scalar';
const pt = identity.isAlias(parent) ? 'alias' : 'scalar';
throw new Error(`Cannot replace node with ${pt} parent`);
}
}