summaryrefslogtreecommitdiff
path: root/node_modules/yaml/dist/schema/common/seq.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-04-09 18:38:29 +0200
committerMinteck <contact@minteck.org>2022-04-09 18:38:29 +0200
commit457c93328f5b51b3fc0aa1600ce8eb8b45a5c2a9 (patch)
treea899daf11edb7ce6a99700e462a5740e013f5951 /node_modules/yaml/dist/schema/common/seq.js
downloadsnowjail-457c93328f5b51b3fc0aa1600ce8eb8b45a5c2a9.tar.gz
snowjail-457c93328f5b51b3fc0aa1600ce8eb8b45a5c2a9.tar.bz2
snowjail-457c93328f5b51b3fc0aa1600ce8eb8b45a5c2a9.zip
Snowjail v0.1
Diffstat (limited to 'node_modules/yaml/dist/schema/common/seq.js')
-rw-r--r--node_modules/yaml/dist/schema/common/seq.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/node_modules/yaml/dist/schema/common/seq.js b/node_modules/yaml/dist/schema/common/seq.js
new file mode 100644
index 0000000..0c48bde
--- /dev/null
+++ b/node_modules/yaml/dist/schema/common/seq.js
@@ -0,0 +1,35 @@
+'use strict';
+
+var createNode = require('../../doc/createNode.js');
+var Node = require('../../nodes/Node.js');
+var YAMLSeq = require('../../nodes/YAMLSeq.js');
+
+function createSeq(schema, obj, ctx) {
+ const { replacer } = ctx;
+ const seq = new YAMLSeq.YAMLSeq(schema);
+ if (obj && Symbol.iterator in Object(obj)) {
+ let i = 0;
+ for (let it of obj) {
+ if (typeof replacer === 'function') {
+ const key = obj instanceof Set ? it : String(i++);
+ it = replacer.call(obj, key, it);
+ }
+ seq.items.push(createNode.createNode(it, undefined, ctx));
+ }
+ }
+ return seq;
+}
+const seq = {
+ collection: 'seq',
+ createNode: createSeq,
+ default: true,
+ nodeClass: YAMLSeq.YAMLSeq,
+ tag: 'tag:yaml.org,2002:seq',
+ resolve(seq, onError) {
+ if (!Node.isSeq(seq))
+ onError('Expected a sequence for this tag');
+ return seq;
+ }
+};
+
+exports.seq = seq;