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

View File

@@ -2,11 +2,13 @@
var anchors = require('../doc/anchors.js');
var visit = require('../visit.js');
var identity = require('./identity.js');
var Node = require('./Node.js');
var toJS = require('./toJS.js');
class Alias extends Node.NodeBase {
constructor(source) {
super(Node.ALIAS);
super(identity.ALIAS);
this.source = source;
Object.defineProperty(this, 'tag', {
set() {
@@ -39,7 +41,12 @@ class Alias extends Node.NodeBase {
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
throw new ReferenceError(msg);
}
const data = anchors.get(source);
let data = anchors.get(source);
if (!data) {
// Resolve anchors for Node.prototype.toJS()
toJS.toJS(source, null, ctx);
data = anchors.get(source);
}
/* istanbul ignore if */
if (!data || data.res === undefined) {
const msg = 'This should not happen: Alias anchor was not resolved?';
@@ -71,12 +78,12 @@ class Alias extends Node.NodeBase {
}
}
function getAliasCount(doc, node, anchors) {
if (Node.isAlias(node)) {
if (identity.isAlias(node)) {
const source = node.resolve(doc);
const anchor = anchors && source && anchors.get(source);
return anchor ? anchor.count * anchor.aliasCount : 0;
}
else if (Node.isCollection(node)) {
else if (identity.isCollection(node)) {
let count = 0;
for (const item of node.items) {
const c = getAliasCount(doc, item, anchors);
@@ -85,7 +92,7 @@ function getAliasCount(doc, node, anchors) {
}
return count;
}
else if (Node.isPair(node)) {
else if (identity.isPair(node)) {
const kc = getAliasCount(doc, node.key, anchors);
const vc = getAliasCount(doc, node.value, anchors);
return Math.max(kc, vc);