persona-community-5/.pnpm-store/v3/files/06/894eef8c453e6f3d204a0000f886b04c3fea883c36918bd9a232d0bf61090f48b16e073d0a7b92b0591461c5e004ddf27935e60436775809fb5a924c3f7a70
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

73 lines
1.7 KiB
Plaintext

'use strict';
import YAMLException = require('./exception');
var TYPE_CONSTRUCTOR_OPTIONS = [
'kind',
'resolve',
'construct',
'instanceOf',
'predicate',
'represent',
'defaultStyle',
'styleAliases'
];
var YAML_NODE_KINDS = [
'scalar',
'sequence',
'mapping'
];
function compileStyleAliases(map) {
var result = {};
if (null !== map) {
Object.keys(map).forEach(function (style) {
map[style].forEach(function (alias) {
result[String(alias)] = style;
});
});
}
return result;
}
export class Type {
tag;
kind;
resolve;
construct;
instanceOf;
predicate;
represent;
defaultStyle;
styleAliases;
loadKind;
constructor(tag, options) {
options = options || {};
Object.keys(options).forEach(function (name) {
if (-1 === TYPE_CONSTRUCTOR_OPTIONS.indexOf(name)) {
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
}
});
// TODO: Add tag format check.
this.tag = tag;
this.kind = options['kind'] || null;
this.resolve = options['resolve'] || function () { return true; };
this.construct = options['construct'] || function (data) { return data; };
this.instanceOf = options['instanceOf'] || null;
this.predicate = options['predicate'] || null;
this.represent = options['represent'] || null;
this.defaultStyle = options['defaultStyle'] || null;
this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
if (-1 === YAML_NODE_KINDS.indexOf(this.kind)) {
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
}
}
}