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,10 @@
var Alias = require('../nodes/Alias.js');
var Collection = require('../nodes/Collection.js');
var Node = require('../nodes/Node.js');
var identity = require('../nodes/identity.js');
var Pair = require('../nodes/Pair.js');
var toJS = require('../nodes/toJS.js');
var Schema = require('../schema/Schema.js');
var stringify = require('../stringify/stringify.js');
var stringifyDocument = require('../stringify/stringifyDocument.js');
var anchors = require('./anchors.js');
var applyReviver = require('./applyReviver.js');
@@ -23,7 +22,7 @@ class Document {
this.errors = [];
/** Warnings encountered during parsing. */
this.warnings = [];
Object.defineProperty(this, Node.NODE_TYPE, { value: Node.DOC });
Object.defineProperty(this, identity.NODE_TYPE, { value: identity.DOC });
let _replacer = null;
if (typeof replacer === 'function' || Array.isArray(replacer)) {
_replacer = replacer;
@@ -51,11 +50,9 @@ class Document {
else
this.directives = new directives.Directives({ version });
this.setSchema(version, options);
if (value === undefined)
this.contents = null;
else {
this.contents = this.createNode(value, _replacer, options);
}
// @ts-expect-error We can't really know that this matches Contents.
this.contents =
value === undefined ? null : this.createNode(value, _replacer, options);
}
/**
* Create a deep copy of this Document and its contents.
@@ -64,7 +61,7 @@ class Document {
*/
clone() {
const copy = Object.create(Document.prototype, {
[Node.NODE_TYPE]: { value: Node.DOC }
[identity.NODE_TYPE]: { value: identity.DOC }
});
copy.commentBefore = this.commentBefore;
copy.comment = this.comment;
@@ -74,7 +71,8 @@ class Document {
if (this.directives)
copy.directives = this.directives.clone();
copy.schema = this.schema.clone();
copy.contents = Node.isNode(this.contents)
// @ts-expect-error We can't really know that this matches Contents.
copy.contents = identity.isNode(this.contents)
? this.contents.clone(copy.schema)
: this.contents;
if (this.range)
@@ -140,7 +138,7 @@ class Document {
sourceObjects
};
const node = createNode.createNode(value, tag, ctx);
if (flow && Node.isCollection(node))
if (flow && identity.isCollection(node))
node.flow = true;
setAnchors();
return node;
@@ -169,6 +167,7 @@ class Document {
if (Collection.isEmptyPath(path)) {
if (this.contents == null)
return false;
// @ts-expect-error Presumed impossible if Strict extends false
this.contents = null;
return true;
}
@@ -182,7 +181,7 @@ class Document {
* `true` (collections are always returned intact).
*/
get(key, keepScalar) {
return Node.isCollection(this.contents)
return identity.isCollection(this.contents)
? this.contents.get(key, keepScalar)
: undefined;
}
@@ -193,10 +192,10 @@ class Document {
*/
getIn(path, keepScalar) {
if (Collection.isEmptyPath(path))
return !keepScalar && Node.isScalar(this.contents)
return !keepScalar && identity.isScalar(this.contents)
? this.contents.value
: this.contents;
return Node.isCollection(this.contents)
return identity.isCollection(this.contents)
? this.contents.getIn(path, keepScalar)
: undefined;
}
@@ -204,7 +203,7 @@ class Document {
* Checks if the document includes a value with the key `key`.
*/
has(key) {
return Node.isCollection(this.contents) ? this.contents.has(key) : false;
return identity.isCollection(this.contents) ? this.contents.has(key) : false;
}
/**
* Checks if the document includes a value at `path`.
@@ -212,7 +211,7 @@ class Document {
hasIn(path) {
if (Collection.isEmptyPath(path))
return this.contents !== undefined;
return Node.isCollection(this.contents) ? this.contents.hasIn(path) : false;
return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
}
/**
* Sets a value in this document. For `!!set`, `value` needs to be a
@@ -220,6 +219,7 @@ class Document {
*/
set(key, value) {
if (this.contents == null) {
// @ts-expect-error We can't really know that this matches Contents.
this.contents = Collection.collectionFromPath(this.schema, [key], value);
}
else if (assertCollection(this.contents)) {
@@ -231,9 +231,12 @@ class Document {
* boolean to add/remove the item from the set.
*/
setIn(path, value) {
if (Collection.isEmptyPath(path))
if (Collection.isEmptyPath(path)) {
// @ts-expect-error We can't really know that this matches Contents.
this.contents = value;
}
else if (this.contents == null) {
// @ts-expect-error We can't really know that this matches Contents.
this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
}
else if (assertCollection(this.contents)) {
@@ -293,8 +296,7 @@ class Document {
keep: !json,
mapAsMap: mapAsMap === true,
mapKeyWarned: false,
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
stringify: stringify.stringify
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
};
const res = toJS.toJS(this.contents, jsonArg ?? '', ctx);
if (typeof onAnchor === 'function')
@@ -326,7 +328,7 @@ class Document {
}
}
function assertCollection(contents) {
if (Node.isCollection(contents))
if (identity.isCollection(contents))
return true;
throw new Error('Expected a YAML collection as document contents');
}