Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoSign in
Socket

yaml

Package Overview
Dependencies
Maintainers
1
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaml - npm Package Compare versions

Comparing version
2.7.1
to
2.8.0
+2
-4
browser/dist/compose/resolve-props.js

@@ -75,4 +75,3 @@ function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {

anchor = token;
if (start === null)
start = token.offset;
start ?? (start = token.offset);
atNewline = false;

@@ -86,4 +85,3 @@ hasSpace = false;

tag = token;
if (start === null)
start = token.offset;
start ?? (start = token.offset);
atNewline = false;

@@ -90,0 +88,0 @@ hasSpace = false;

function emptyScalarPosition(offset, before, pos) {
if (before) {
if (pos === null)
pos = before.length;
pos ?? (pos = before.length);
for (let i = pos - 1; i >= 0; --i) {

@@ -6,0 +5,0 @@ let st = before[i];

@@ -42,4 +42,3 @@ import { isScalar, isCollection } from '../nodes/identity.js';

aliasObjects.push(source);
if (!prevAnchors)
prevAnchors = anchorNames(doc);
prevAnchors ?? (prevAnchors = anchorNames(doc));
const anchor = findNewAnchor(prefix, prevAnchors);

@@ -46,0 +45,0 @@ prevAnchors.add(anchor);

@@ -41,4 +41,3 @@ import { Alias } from '../nodes/Alias.js';

if (ref) {
if (!ref.anchor)
ref.anchor = onAnchor(value);
ref.anchor ?? (ref.anchor = onAnchor(value));
return new Alias(ref.anchor);

@@ -45,0 +44,0 @@ }

@@ -40,2 +40,3 @@ import { warn } from '../log.js';

return '';
// eslint-disable-next-line @typescript-eslint/no-base-to-string
if (typeof jsKey !== 'object')

@@ -42,0 +43,0 @@ return String(jsKey);

import { anchorIsValid } from '../doc/anchors.js';
import { visit } from '../visit.js';
import { ALIAS, isAlias, isCollection, isPair } from './identity.js';
import { ALIAS, isAlias, isCollection, isPair, hasAnchor } from './identity.js';
import { NodeBase } from './Node.js';

@@ -21,12 +21,25 @@ import { toJS } from './toJS.js';

*/
resolve(doc) {
resolve(doc, ctx) {
let nodes;
if (ctx?.aliasResolveCache) {
nodes = ctx.aliasResolveCache;
}
else {
nodes = [];
visit(doc, {
Node: (_key, node) => {
if (isAlias(node) || hasAnchor(node))
nodes.push(node);
}
});
if (ctx)
ctx.aliasResolveCache = nodes;
}
let found = undefined;
visit(doc, {
Node: (_key, node) => {
if (node === this)
return visit.BREAK;
if (node.anchor === this.source)
found = node;
}
});
for (const node of nodes) {
if (node === this)
break;
if (node.anchor === this.source)
found = node;
}
return found;

@@ -38,3 +51,3 @@ }

const { anchors, doc, maxAliasCount } = ctx;
const source = this.resolve(doc);
const source = this.resolve(doc, ctx);
if (!source) {

@@ -41,0 +54,0 @@ const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;

import { stringifyCollection } from '../stringify/stringifyCollection.js';
import { addPairToJSMap } from './addPairToJSMap.js';
import { Collection } from './Collection.js';
import { isPair, isScalar, MAP } from './identity.js';
import { MAP, isPair, isScalar } from './identity.js';
import { Pair, createPair } from './Pair.js';

@@ -6,0 +6,0 @@ import { isScalarValue } from './Scalar.js';

@@ -6,4 +6,4 @@ import { map } from './common/map.js';

import { boolTag } from './core/bool.js';
import { float, floatExp, floatNaN } from './core/float.js';
import { int, intHex, intOct } from './core/int.js';
import { floatNaN, floatExp, float } from './core/float.js';
import { intOct, intHex, int } from './core/int.js';
import { schema } from './core/schema.js';

@@ -17,3 +17,3 @@ import { schema as schema$1 } from './json/schema.js';

import { set } from './yaml-1.1/set.js';
import { timestamp, floatTime, intTime } from './yaml-1.1/timestamp.js';
import { timestamp, intTime, floatTime } from './yaml-1.1/timestamp.js';

@@ -20,0 +20,0 @@ const schemas = new Map([

@@ -44,4 +44,3 @@ import { Scalar } from '../../nodes/Scalar.js';

}
if (!type)
type = Scalar.BLOCK_LITERAL;
type ?? (type = Scalar.BLOCK_LITERAL);
if (type !== Scalar.QUOTE_DOUBLE) {

@@ -48,0 +47,0 @@ const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);

import { isSeq, isPair, isMap } from '../../nodes/identity.js';
import { Pair, createPair } from '../../nodes/Pair.js';
import { createPair, Pair } from '../../nodes/Pair.js';
import { Scalar } from '../../nodes/Scalar.js';

@@ -4,0 +4,0 @@ import { YAMLSeq } from '../../nodes/YAMLSeq.js';

@@ -71,3 +71,3 @@ import { anchorIsValid } from '../doc/anchors.js';

if (!tagObj) {
const name = obj?.constructor?.name ?? typeof obj;
const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
throw new Error(`Tag not resolved for ${name} value`);

@@ -87,3 +87,3 @@ }

}
const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
if (tag)

@@ -114,4 +114,3 @@ props.push(doc.directives.tagString(tag));

: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
if (!tagObj)
tagObj = getTagObject(ctx.doc.schema.tags, node);
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
const props = stringifyProps(node, tagObj, ctx);

@@ -118,0 +117,0 @@ if (props.length > 0)

import { Scalar } from '../nodes/Scalar.js';
import { foldFlowLines, FOLD_QUOTED, FOLD_FLOW, FOLD_BLOCK } from './foldFlowLines.js';
import { foldFlowLines, FOLD_FLOW, FOLD_QUOTED, FOLD_BLOCK } from './foldFlowLines.js';

@@ -256,6 +256,5 @@ const getFoldOptions = (ctx, isBlock) => ({

}
if (!value ||
/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
// not allowed:
// - empty string, '-' or '?'
// - '-' or '?'
// - start with an indicator character (except [?:-]) or /[?-] /

@@ -262,0 +261,0 @@ // - '\n ', ': ' or ' \n' anywhere

@@ -1,2 +0,2 @@

export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
export declare const help = "yaml: A command-line YAML processor and inspector\n\nReads stdin and writes output to stdout and errors & warnings to stderr.\n\nUsage:\n yaml Process a YAML stream, outputting it as YAML\n yaml cst Parse the CST of a YAML stream\n yaml lex Parse the lexical tokens of a YAML stream\n yaml valid Validate a YAML stream, returning 0 on success\n\nOptions:\n --help, -h Show this message.\n --json, -j Output JSON.\n --indent 2 Output pretty-printed data, indented by the given number of spaces.\n --merge, -m Enable support for \"<<\" merge keys.\n\nAdditional options for bare \"yaml\" command:\n --doc, -d Output pretty-printed JS Document objects.\n --single, -1 Require the input to consist of a single YAML document.\n --strict, -s Stop on errors.\n --visit, -v Apply a visitor to each document (requires a path to import)\n --yaml 1.1 Set the YAML version. (default: 1.2)";
export declare class UserError extends Error {

@@ -3,0 +3,0 @@ static ARGS: number;

@@ -1,3 +0,3 @@

import { resolve } from 'node:path';
import { parseArgs } from 'node:util';
import { resolve } from 'path';
import { parseArgs } from 'util';
import { prettyToken } from './parse/cst.js';

@@ -26,2 +26,3 @@ import { Lexer } from './parse/lexer.js';

--indent 2 Output pretty-printed data, indented by the given number of spaces.
--merge, -m Enable support for "<<" merge keys.

@@ -52,2 +53,3 @@ Additional options for bare "yaml" command:

indent: { type: 'string', short: 'i' },
merge: { type: 'boolean', short: 'm' },
json: { type: 'boolean', short: 'j' },

@@ -122,3 +124,3 @@ single: { type: 'boolean', short: '1' },

// @ts-expect-error Version is validated at runtime
const composer = new Composer({ version: opt.yaml });
const composer = new Composer({ version: opt.yaml, merge: opt.merge });
const visitor = opt.visit

@@ -125,0 +127,0 @@ ? (await import(resolve(opt.visit))).default

'use strict';
var node_process = require('node:process');
var node_process = require('process');
var directives = require('../doc/directives.js');

@@ -5,0 +5,0 @@ var Document = require('../doc/Document.js');

@@ -77,4 +77,3 @@ 'use strict';

anchor = token;
if (start === null)
start = token.offset;
start ?? (start = token.offset);
atNewline = false;

@@ -88,4 +87,3 @@ hasSpace = false;

tag = token;
if (start === null)
start = token.offset;
start ?? (start = token.offset);
atNewline = false;

@@ -92,0 +90,0 @@ hasSpace = false;

@@ -5,4 +5,3 @@ 'use strict';

if (before) {
if (pos === null)
pos = before.length;
pos ?? (pos = before.length);
for (let i = pos - 1; i >= 0; --i) {

@@ -9,0 +8,0 @@ let st = before[i];

@@ -44,4 +44,3 @@ 'use strict';

aliasObjects.push(source);
if (!prevAnchors)
prevAnchors = anchorNames(doc);
prevAnchors ?? (prevAnchors = anchorNames(doc));
const anchor = findNewAnchor(prefix, prevAnchors);

@@ -48,0 +47,0 @@ prevAnchors.add(anchor);

@@ -43,4 +43,3 @@ 'use strict';

if (ref) {
if (!ref.anchor)
ref.anchor = onAnchor(value);
ref.anchor ?? (ref.anchor = onAnchor(value));
return new Alias.Alias(ref.anchor);

@@ -47,0 +46,0 @@ }

'use strict';
var node_process = require('node:process');
var node_process = require('process');

@@ -5,0 +5,0 @@ function debug(logLevel, ...messages) {

@@ -42,2 +42,3 @@ 'use strict';

return '';
// eslint-disable-next-line @typescript-eslint/no-base-to-string
if (typeof jsKey !== 'object')

@@ -44,0 +45,0 @@ return String(jsKey);

@@ -26,5 +26,5 @@ import type { Document } from '../doc/Document';

*/
resolve(doc: Document): Scalar | YAMLMap | YAMLSeq | undefined;
resolve(doc: Document, ctx?: ToJSContext): Scalar | YAMLMap | YAMLSeq | undefined;
toJSON(_arg?: unknown, ctx?: ToJSContext): unknown;
toString(ctx?: StringifyContext, _onComment?: () => void, _onChompKeep?: () => void): string;
}

@@ -23,12 +23,25 @@ 'use strict';

*/
resolve(doc) {
resolve(doc, ctx) {
let nodes;
if (ctx?.aliasResolveCache) {
nodes = ctx.aliasResolveCache;
}
else {
nodes = [];
visit.visit(doc, {
Node: (_key, node) => {
if (identity.isAlias(node) || identity.hasAnchor(node))
nodes.push(node);
}
});
if (ctx)
ctx.aliasResolveCache = nodes;
}
let found = undefined;
visit.visit(doc, {
Node: (_key, node) => {
if (node === this)
return visit.visit.BREAK;
if (node.anchor === this.source)
found = node;
}
});
for (const node of nodes) {
if (node === this)
break;
if (node.anchor === this.source)
found = node;
}
return found;

@@ -40,3 +53,3 @@ }

const { anchors, doc, maxAliasCount } = ctx;
const source = this.resolve(doc);
const source = this.resolve(doc, ctx);
if (!source) {

@@ -43,0 +56,0 @@ const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;

@@ -10,2 +10,4 @@ import type { Document } from '../doc/Document';

anchors: Map<Node, AnchorData>;
/** Cached anchor and alias nodes in the order they occur in the document */
aliasResolveCache?: Node[];
doc: Document<Node, boolean>;

@@ -12,0 +14,0 @@ keep: boolean;

'use strict';
var node_process = require('node:process');
var node_process = require('process');
var cst = require('./cst.js');

@@ -5,0 +5,0 @@ var lexer = require('./lexer.js');

'use strict';
var node_buffer = require('node:buffer');
var node_buffer = require('buffer');
var Scalar = require('../../nodes/Scalar.js');

@@ -56,4 +56,3 @@ var stringifyString = require('../../stringify/stringifyString.js');

}
if (!type)
type = Scalar.Scalar.BLOCK_LITERAL;
type ?? (type = Scalar.Scalar.BLOCK_LITERAL);
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {

@@ -60,0 +59,0 @@ const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);

@@ -73,3 +73,3 @@ 'use strict';

if (!tagObj) {
const name = obj?.constructor?.name ?? typeof obj;
const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
throw new Error(`Tag not resolved for ${name} value`);

@@ -89,3 +89,3 @@ }

}
const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
if (tag)

@@ -116,4 +116,3 @@ props.push(doc.directives.tagString(tag));

: ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
if (!tagObj)
tagObj = getTagObject(ctx.doc.schema.tags, node);
tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
const props = stringifyProps(node, tagObj, ctx);

@@ -120,0 +119,0 @@ if (props.length > 0)

@@ -258,6 +258,5 @@ 'use strict';

}
if (!value ||
/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
// not allowed:
// - empty string, '-' or '?'
// - '-' or '?'
// - start with an indicator character (except [?:-]) or /[?-] /

@@ -264,0 +263,0 @@ // - '\n ', ': ' or ' \n' anywhere

{
"name": "yaml",
"version": "2.7.1",
"version": "2.8.0",
"license": "ISC",

@@ -94,4 +94,4 @@ "author": "Eemeli Aro <eemeli@gmail.com>",

"engines": {
"node": ">= 14"
"node": ">= 14.6"
}
}