gitea push
This commit is contained in:
+5
-3
@@ -142,7 +142,7 @@ function doubleQuotedValue(source, onError) {
|
||||
next = source[++i + 1];
|
||||
}
|
||||
else if (next === 'x' || next === 'u' || next === 'U') {
|
||||
const length = { x: 2, u: 4, U: 8 }[next];
|
||||
const length = next === 'x' ? 2 : next === 'u' ? 4 : 8;
|
||||
res += parseCharCode(source, i + 1, length, onError);
|
||||
i += length;
|
||||
}
|
||||
@@ -212,12 +212,14 @@ function parseCharCode(source, offset, length, onError) {
|
||||
const cc = source.substr(offset, length);
|
||||
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
||||
const code = ok ? parseInt(cc, 16) : NaN;
|
||||
if (isNaN(code)) {
|
||||
try {
|
||||
return String.fromCodePoint(code);
|
||||
}
|
||||
catch {
|
||||
const raw = source.substr(offset - 2, length + 2);
|
||||
onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`);
|
||||
return raw;
|
||||
}
|
||||
return String.fromCodePoint(code);
|
||||
}
|
||||
|
||||
export { resolveFlowScalar };
|
||||
|
||||
+2
@@ -19,6 +19,8 @@ class Alias extends NodeBase {
|
||||
* instance of the `source` anchor before this node.
|
||||
*/
|
||||
resolve(doc, ctx) {
|
||||
if (ctx?.maxAliasCount === 0)
|
||||
throw new ReferenceError('Alias resolution is disabled');
|
||||
let nodes;
|
||||
if (ctx?.aliasResolveCache) {
|
||||
nodes = ctx.aliasResolveCache;
|
||||
|
||||
+11
-8
@@ -1,4 +1,4 @@
|
||||
import { isScalar, isAlias, isSeq, isMap } from '../../nodes/identity.js';
|
||||
import { isScalar, isSeq, isAlias, isMap } from '../../nodes/identity.js';
|
||||
import { Scalar } from '../../nodes/Scalar.js';
|
||||
|
||||
// If the value associated with a merge key is a single mapping node, each of
|
||||
@@ -26,18 +26,18 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
||||
merge.identify(key.value))) &&
|
||||
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
|
||||
function addMergeToJSMap(ctx, map, value) {
|
||||
value = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (isSeq(value))
|
||||
for (const it of value.items)
|
||||
const source = resolveAliasValue(ctx, value);
|
||||
if (isSeq(source))
|
||||
for (const it of source.items)
|
||||
mergeValue(ctx, map, it);
|
||||
else if (Array.isArray(value))
|
||||
for (const it of value)
|
||||
else if (Array.isArray(source))
|
||||
for (const it of source)
|
||||
mergeValue(ctx, map, it);
|
||||
else
|
||||
mergeValue(ctx, map, value);
|
||||
mergeValue(ctx, map, source);
|
||||
}
|
||||
function mergeValue(ctx, map, value) {
|
||||
const source = ctx && isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
const source = resolveAliasValue(ctx, value);
|
||||
if (!isMap(source))
|
||||
throw new Error('Merge sources must be maps or map aliases');
|
||||
const srcMap = source.toJSON(null, ctx, Map);
|
||||
@@ -60,5 +60,8 @@ function mergeValue(ctx, map, value) {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
function resolveAliasValue(ctx, value) {
|
||||
return ctx && isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
||||
}
|
||||
|
||||
export { addMergeToJSMap, isMergeKey, merge };
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
||||
if (!format &&
|
||||
minFractionDigits &&
|
||||
(!tag || tag === 'tag:yaml.org,2002:float') &&
|
||||
/^\d/.test(n)) {
|
||||
/^-?\d/.test(n) &&
|
||||
!n.includes('e')) {
|
||||
let i = n.indexOf('.');
|
||||
if (i < 0) {
|
||||
i = n.length;
|
||||
|
||||
+5
-3
@@ -144,7 +144,7 @@ function doubleQuotedValue(source, onError) {
|
||||
next = source[++i + 1];
|
||||
}
|
||||
else if (next === 'x' || next === 'u' || next === 'U') {
|
||||
const length = { x: 2, u: 4, U: 8 }[next];
|
||||
const length = next === 'x' ? 2 : next === 'u' ? 4 : 8;
|
||||
res += parseCharCode(source, i + 1, length, onError);
|
||||
i += length;
|
||||
}
|
||||
@@ -214,12 +214,14 @@ function parseCharCode(source, offset, length, onError) {
|
||||
const cc = source.substr(offset, length);
|
||||
const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc);
|
||||
const code = ok ? parseInt(cc, 16) : NaN;
|
||||
if (isNaN(code)) {
|
||||
try {
|
||||
return String.fromCodePoint(code);
|
||||
}
|
||||
catch {
|
||||
const raw = source.substr(offset - 2, length + 2);
|
||||
onError(offset - 2, 'BAD_DQ_ESCAPE', `Invalid escape sequence ${raw}`);
|
||||
return raw;
|
||||
}
|
||||
return String.fromCodePoint(code);
|
||||
}
|
||||
|
||||
exports.resolveFlowScalar = resolveFlowScalar;
|
||||
|
||||
+2
@@ -21,6 +21,8 @@ class Alias extends Node.NodeBase {
|
||||
* instance of the `source` anchor before this node.
|
||||
*/
|
||||
resolve(doc, ctx) {
|
||||
if (ctx?.maxAliasCount === 0)
|
||||
throw new ReferenceError('Alias resolution is disabled');
|
||||
let nodes;
|
||||
if (ctx?.aliasResolveCache) {
|
||||
nodes = ctx.aliasResolveCache;
|
||||
|
||||
+5
-1
@@ -31,7 +31,11 @@ export declare class Scalar<T = unknown> extends NodeBase {
|
||||
* The YAML 1.1 schema also supports 'BIN' and 'TIME'
|
||||
*/
|
||||
format?: string;
|
||||
/** If `value` is a number, use this value when stringifying this node. */
|
||||
/**
|
||||
* If `value` is a number that is serialized as a decimal string
|
||||
* (i.e. not using exponential notation),
|
||||
* use this value when stringifying this node.
|
||||
*/
|
||||
minFractionDigits?: number;
|
||||
/** Set during parsing to the source string value */
|
||||
source?: string;
|
||||
|
||||
+10
-7
@@ -28,18 +28,18 @@ const isMergeKey = (ctx, key) => (merge.identify(key) ||
|
||||
merge.identify(key.value))) &&
|
||||
ctx?.doc.schema.tags.some(tag => tag.tag === merge.tag && tag.default);
|
||||
function addMergeToJSMap(ctx, map, value) {
|
||||
value = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
if (identity.isSeq(value))
|
||||
for (const it of value.items)
|
||||
const source = resolveAliasValue(ctx, value);
|
||||
if (identity.isSeq(source))
|
||||
for (const it of source.items)
|
||||
mergeValue(ctx, map, it);
|
||||
else if (Array.isArray(value))
|
||||
for (const it of value)
|
||||
else if (Array.isArray(source))
|
||||
for (const it of source)
|
||||
mergeValue(ctx, map, it);
|
||||
else
|
||||
mergeValue(ctx, map, value);
|
||||
mergeValue(ctx, map, source);
|
||||
}
|
||||
function mergeValue(ctx, map, value) {
|
||||
const source = ctx && identity.isAlias(value) ? value.resolve(ctx.doc) : value;
|
||||
const source = resolveAliasValue(ctx, value);
|
||||
if (!identity.isMap(source))
|
||||
throw new Error('Merge sources must be maps or map aliases');
|
||||
const srcMap = source.toJSON(null, ctx, Map);
|
||||
@@ -62,6 +62,9 @@ function mergeValue(ctx, map, value) {
|
||||
}
|
||||
return map;
|
||||
}
|
||||
function resolveAliasValue(ctx, value) {
|
||||
return ctx && identity.isAlias(value) ? value.resolve(ctx.doc, ctx) : value;
|
||||
}
|
||||
|
||||
exports.addMergeToJSMap = addMergeToJSMap;
|
||||
exports.isMergeKey = isMergeKey;
|
||||
|
||||
+2
-1
@@ -10,7 +10,8 @@ function stringifyNumber({ format, minFractionDigits, tag, value }) {
|
||||
if (!format &&
|
||||
minFractionDigits &&
|
||||
(!tag || tag === 'tag:yaml.org,2002:float') &&
|
||||
/^\d/.test(n)) {
|
||||
/^-?\d/.test(n) &&
|
||||
!n.includes('e')) {
|
||||
let i = n.indexOf('.');
|
||||
if (i < 0) {
|
||||
i = n.length;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yaml",
|
||||
"version": "2.8.3",
|
||||
"version": "2.8.4",
|
||||
"license": "ISC",
|
||||
"author": "Eemeli Aro <eemeli@gmail.com>",
|
||||
"funding": "https://github.com/sponsors/eemeli",
|
||||
|
||||
Reference in New Issue
Block a user