Packages
moon
2.90.1
2.90.5
retired
2.90.4
2.90.3
2.90.2
2.90.1
2.90.0
2.89.4
2.89.1
2.89.0
2.88.0
2.87.11
2.87.10
2.87.9
2.87.8
2.87.7
2.87.6
2.87.5
2.87.4
2.87.3
2.87.2
2.87.1
2.87.0
2.86.1
2.86.0
2.85.1
2.85.0
2.84.0
2.83.0
2.82.0
2.81.4
2.81.3
2.81.2
2.81.1
2.81.0
2.80.2
2.80.1
2.80.0
2.79.13
2.79.12
2.79.11
2.79.10
2.79.9
2.79.8
2.79.7
2.79.6
2.79.5
2.79.4
2.79.3
2.79.2
2.79.1
2.79.0
2.78.4
2.78.3
2.78.2
2.78.1
2.78.0
2.77.0
2.76.5
2.76.4
2.76.3
2.76.2
2.76.1
2.76.0
2.75.0
2.74.1
2.74.0
2.73.8
2.73.7
2.73.6
2.73.5
2.73.4
2.73.3
2.73.2
2.73.1
2.73.0
2.72.5
2.72.4
2.72.3
2.72.2
2.72.1
2.72.0
2.71.1
2.71.0
2.70.0
2.69.2
2.69.1
2.69.0
2.68.11
2.68.10
Components-based design system written in elixir
Current section
Files
Jump to
Current section
Files
assets/node_modules/yaml/dist/test-events.js
'use strict';
var identity = require('./nodes/identity.js');
var publicApi = require('./public-api.js');
var visit = require('./visit.js');
const scalarChar = {
BLOCK_FOLDED: '>',
BLOCK_LITERAL: '|',
PLAIN: ':',
QUOTE_DOUBLE: '"',
QUOTE_SINGLE: "'"
};
function anchorExists(doc, anchor) {
let found = false;
visit.visit(doc, {
Value(_key, node) {
if (node.anchor === anchor) {
found = true;
return visit.visit.BREAK;
}
}
});
return found;
}
// test harness for yaml-test-suite event tests
function testEvents(src) {
const docs = publicApi.parseAllDocuments(src);
const errDoc = docs.find(doc => doc.errors.length > 0);
const error = errDoc ? errDoc.errors[0].message : null;
const events = ['+STR'];
try {
for (let i = 0; i < docs.length; ++i) {
const doc = docs[i];
let root = doc.contents;
if (Array.isArray(root))
root = root[0];
const [rootStart] = doc.range || [0];
const error = doc.errors[0];
if (error && (!error.pos || error.pos[0] < rootStart))
throw new Error();
let docStart = '+DOC';
if (doc.directives.docStart)
docStart += ' ---';
else if (doc.contents &&
doc.contents.range[2] === doc.contents.range[0] &&
!doc.contents.anchor &&
!doc.contents.tag)
continue;
events.push(docStart);
addEvents(events, doc, error?.pos[0] ?? -1, root);
let docEnd = '-DOC';
if (doc.directives.docEnd)
docEnd += ' ...';
events.push(docEnd);
}
}
catch (e) {
return { events, error: error ?? e };
}
events.push('-STR');
return { events, error };
}
function addEvents(events, doc, errPos, node) {
if (!node) {
events.push('=VAL :');
return;
}
if (errPos !== -1 && identity.isNode(node) && node.range[0] >= errPos)
throw new Error();
let props = '';
let anchor = identity.isScalar(node) || identity.isCollection(node) ? node.anchor : undefined;
if (anchor) {
if (/\d$/.test(anchor)) {
const alt = anchor.replace(/\d$/, '');
if (anchorExists(doc, alt))
anchor = alt;
}
props = ` &${anchor}`;
}
if (identity.isNode(node) && node.tag)
props += ` <${node.tag}>`;
if (identity.isMap(node)) {
const ev = node.flow ? '+MAP {}' : '+MAP';
events.push(`${ev}${props}`);
node.items.forEach(({ key, value }) => {
addEvents(events, doc, errPos, key);
addEvents(events, doc, errPos, value);
});
events.push('-MAP');
}
else if (identity.isSeq(node)) {
const ev = node.flow ? '+SEQ []' : '+SEQ';
events.push(`${ev}${props}`);
node.items.forEach(item => {
addEvents(events, doc, errPos, item);
});
events.push('-SEQ');
}
else if (identity.isPair(node)) {
events.push(`+MAP${props}`);
addEvents(events, doc, errPos, node.key);
addEvents(events, doc, errPos, node.value);
events.push('-MAP');
}
else if (identity.isAlias(node)) {
let alias = node.source;
if (alias && /\d$/.test(alias)) {
const alt = alias.replace(/\d$/, '');
if (anchorExists(doc, alt))
alias = alt;
}
events.push(`=ALI${props} *${alias}`);
}
else {
const scalar = scalarChar[String(node.type)];
if (!scalar)
throw new Error(`Unexpected node type ${node.type}`);
const value = node.source
.replace(/\\/g, '\\\\')
.replace(/\0/g, '\\0')
.replace(/\x07/g, '\\a')
.replace(/\x08/g, '\\b')
.replace(/\t/g, '\\t')
.replace(/\n/g, '\\n')
.replace(/\v/g, '\\v')
.replace(/\f/g, '\\f')
.replace(/\r/g, '\\r')
.replace(/\x1b/g, '\\e');
events.push(`=VAL${props} ${scalar}${value}`);
}
}
exports.testEvents = testEvents;