yaml 2.0.0-4 → 2.0.0-5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/browser/dist/compose/compose-collection.js +12 -9
- package/browser/dist/compose/compose-doc.js +23 -6
- package/browser/dist/compose/compose-node.js +20 -17
- package/browser/dist/compose/compose-scalar.js +20 -23
- package/browser/dist/compose/composer.js +105 -76
- package/browser/dist/compose/resolve-block-map.js +38 -29
- package/browser/dist/compose/resolve-block-scalar.js +14 -17
- package/browser/dist/compose/resolve-block-seq.js +21 -17
- package/browser/dist/compose/resolve-end.js +6 -7
- package/browser/dist/compose/resolve-flow-collection.js +153 -199
- package/browser/dist/compose/resolve-flow-scalar.js +49 -25
- package/browser/dist/compose/resolve-props.js +47 -35
- package/browser/dist/compose/util-contains-newline.js +15 -12
- package/browser/dist/doc/Document.js +50 -99
- package/browser/dist/doc/anchors.js +72 -0
- package/browser/dist/doc/createNode.js +27 -17
- package/browser/dist/errors.js +16 -12
- package/browser/dist/index.js +3 -3
- package/browser/dist/nodes/Alias.js +51 -28
- package/browser/dist/nodes/Collection.js +5 -83
- package/browser/dist/nodes/Node.js +2 -1
- package/browser/dist/nodes/Pair.js +9 -232
- package/browser/dist/nodes/YAMLMap.js +8 -4
- package/browser/dist/nodes/YAMLSeq.js +7 -4
- package/browser/dist/nodes/addPairToJSMap.js +103 -0
- package/browser/dist/nodes/toJS.js +12 -10
- package/browser/dist/options.js +0 -2
- package/browser/dist/parse/cst-scalar.js +219 -0
- package/browser/dist/parse/cst-stringify.js +61 -0
- package/browser/dist/parse/cst-visit.js +97 -0
- package/{dist/parse/tokens.js → browser/dist/parse/cst.js} +12 -7
- package/browser/dist/parse/lexer.js +99 -105
- package/browser/dist/parse/parser.js +219 -144
- package/browser/dist/public-api.js +11 -14
- package/browser/dist/schema/Schema.js +23 -0
- package/browser/dist/{tags/failsafe → schema/common}/map.js +0 -0
- package/browser/dist/schema/common/null.js +13 -0
- package/browser/dist/{tags/failsafe → schema/common}/seq.js +1 -1
- package/browser/dist/{tags/failsafe → schema/common}/string.js +0 -0
- package/browser/dist/schema/core/bool.js +19 -0
- package/browser/dist/schema/core/float.js +40 -0
- package/browser/dist/schema/core/int.js +38 -0
- package/browser/dist/schema/core/schema.js +23 -0
- package/browser/dist/{tags/json.js → schema/json/schema.js} +5 -6
- package/browser/dist/schema/tags.js +79 -0
- package/browser/dist/{tags → schema}/yaml-1.1/binary.js +0 -0
- package/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/browser/dist/schema/yaml-1.1/float.js +43 -0
- package/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/browser/dist/{tags → schema}/yaml-1.1/omap.js +0 -0
- package/browser/dist/{tags → schema}/yaml-1.1/pairs.js +9 -6
- package/browser/dist/schema/yaml-1.1/schema.js +37 -0
- package/browser/dist/{tags → schema}/yaml-1.1/set.js +0 -0
- package/browser/dist/{tags → schema}/yaml-1.1/timestamp.js +0 -0
- package/browser/dist/stringify/addComment.js +1 -7
- package/browser/dist/stringify/stringify.js +8 -6
- package/browser/dist/stringify/stringifyCollection.js +108 -0
- package/browser/dist/stringify/stringifyDocument.js +61 -0
- package/browser/dist/stringify/stringifyPair.js +113 -0
- package/browser/dist/stringify/stringifyString.js +53 -52
- package/browser/dist/visit.js +20 -1
- package/dist/compose/compose-collection.d.ts +4 -4
- package/dist/compose/compose-collection.js +12 -9
- package/dist/compose/compose-doc.d.ts +4 -3
- package/dist/compose/compose-doc.js +23 -6
- package/dist/compose/compose-node.d.ts +15 -7
- package/dist/compose/compose-node.js +20 -17
- package/dist/compose/compose-scalar.d.ts +4 -3
- package/dist/compose/compose-scalar.js +19 -22
- package/dist/compose/composer.d.ts +28 -23
- package/dist/compose/composer.js +106 -77
- package/dist/compose/resolve-block-map.d.ts +4 -4
- package/dist/compose/resolve-block-map.js +38 -29
- package/dist/compose/resolve-block-scalar.d.ts +5 -3
- package/dist/compose/resolve-block-scalar.js +14 -17
- package/dist/compose/resolve-block-seq.d.ts +4 -4
- package/dist/compose/resolve-block-seq.js +21 -17
- package/dist/compose/resolve-end.d.ts +3 -2
- package/dist/compose/resolve-end.js +6 -7
- package/dist/compose/resolve-flow-collection.d.ts +4 -5
- package/dist/compose/resolve-flow-collection.js +152 -198
- package/dist/compose/resolve-flow-scalar.d.ts +5 -3
- package/dist/compose/resolve-flow-scalar.js +49 -25
- package/dist/compose/resolve-props.d.ts +17 -10
- package/dist/compose/resolve-props.js +47 -35
- package/dist/compose/util-contains-newline.d.ts +1 -1
- package/dist/compose/util-contains-newline.js +15 -12
- package/dist/compose/util-empty-scalar-position.d.ts +1 -1
- package/dist/doc/Document.d.ts +27 -15
- package/dist/doc/Document.js +48 -97
- package/dist/doc/anchors.d.ts +24 -0
- package/dist/doc/anchors.js +77 -0
- package/dist/doc/createNode.d.ts +8 -10
- package/dist/doc/createNode.js +26 -16
- package/dist/errors.d.ts +11 -8
- package/dist/errors.js +16 -12
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -3
- package/dist/nodes/Alias.d.ts +19 -9
- package/dist/nodes/Alias.js +51 -28
- package/dist/nodes/Collection.d.ts +3 -17
- package/dist/nodes/Collection.js +4 -82
- package/dist/nodes/Node.d.ts +6 -4
- package/dist/nodes/Node.js +2 -0
- package/dist/nodes/Pair.d.ts +6 -11
- package/dist/nodes/Pair.js +8 -231
- package/dist/nodes/Scalar.d.ts +6 -3
- package/dist/nodes/YAMLMap.d.ts +3 -3
- package/dist/nodes/YAMLMap.js +8 -4
- package/dist/nodes/YAMLSeq.d.ts +3 -3
- package/dist/nodes/YAMLSeq.js +7 -4
- package/dist/nodes/addPairToJSMap.d.ts +3 -0
- package/dist/nodes/addPairToJSMap.js +105 -0
- package/dist/nodes/toJS.d.ts +4 -5
- package/dist/nodes/toJS.js +12 -10
- package/dist/options.d.ts +20 -26
- package/dist/options.js +0 -2
- package/dist/parse/cst-scalar.d.ts +58 -0
- package/dist/parse/cst-scalar.js +223 -0
- package/dist/parse/cst-stringify.d.ts +8 -0
- package/dist/parse/cst-stringify.js +63 -0
- package/dist/parse/cst-visit.d.ts +39 -0
- package/dist/parse/cst-visit.js +99 -0
- package/dist/parse/{tokens.d.ts → cst.d.ts} +23 -7
- package/{browser/dist/parse/tokens.js → dist/parse/cst.js} +27 -1
- package/dist/parse/lexer.d.ts +4 -13
- package/dist/parse/lexer.js +100 -106
- package/dist/parse/parser.d.ts +30 -24
- package/dist/parse/parser.js +221 -146
- package/dist/public-api.d.ts +7 -7
- package/dist/public-api.js +11 -14
- package/dist/{doc → schema}/Schema.d.ts +5 -3
- package/dist/schema/Schema.js +25 -0
- package/dist/{tags/failsafe → schema/common}/map.d.ts +0 -0
- package/dist/{tags/failsafe → schema/common}/map.js +0 -0
- package/dist/schema/common/null.d.ts +4 -0
- package/dist/schema/common/null.js +15 -0
- package/dist/{tags/failsafe → schema/common}/seq.d.ts +0 -0
- package/dist/{tags/failsafe → schema/common}/seq.js +1 -1
- package/dist/{tags/failsafe → schema/common}/string.d.ts +0 -0
- package/dist/{tags/failsafe → schema/common}/string.js +0 -0
- package/dist/schema/core/bool.d.ts +4 -0
- package/dist/schema/core/bool.js +21 -0
- package/dist/schema/core/float.d.ts +4 -0
- package/dist/schema/core/float.js +44 -0
- package/dist/schema/core/int.d.ts +4 -0
- package/dist/schema/core/int.js +42 -0
- package/dist/schema/core/schema.d.ts +1 -0
- package/dist/schema/core/schema.js +25 -0
- package/dist/schema/json/schema.d.ts +2 -0
- package/dist/{tags/json.js → schema/json/schema.js} +5 -6
- package/dist/schema/tags.d.ts +41 -0
- package/dist/schema/tags.js +82 -0
- package/dist/{tags → schema}/types.d.ts +3 -7
- package/dist/{tags → schema}/yaml-1.1/binary.d.ts +0 -0
- package/dist/{tags → schema}/yaml-1.1/binary.js +0 -0
- package/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/dist/schema/yaml-1.1/bool.js +29 -0
- package/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/dist/schema/yaml-1.1/float.js +47 -0
- package/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/dist/schema/yaml-1.1/int.js +76 -0
- package/dist/{tags → schema}/yaml-1.1/omap.d.ts +0 -0
- package/dist/{tags → schema}/yaml-1.1/omap.js +0 -0
- package/dist/{tags → schema}/yaml-1.1/pairs.d.ts +3 -2
- package/dist/{tags → schema}/yaml-1.1/pairs.js +9 -6
- package/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/dist/schema/yaml-1.1/schema.js +39 -0
- package/dist/{tags → schema}/yaml-1.1/set.d.ts +1 -1
- package/dist/{tags → schema}/yaml-1.1/set.js +0 -0
- package/dist/{tags → schema}/yaml-1.1/timestamp.d.ts +0 -0
- package/dist/{tags → schema}/yaml-1.1/timestamp.js +0 -0
- package/dist/stringify/addComment.js +0 -7
- package/dist/stringify/stringify.d.ts +1 -2
- package/dist/stringify/stringify.js +8 -6
- package/dist/stringify/stringifyCollection.d.ts +21 -0
- package/dist/stringify/stringifyCollection.js +110 -0
- package/dist/stringify/stringifyDocument.d.ts +3 -0
- package/dist/stringify/stringifyDocument.js +63 -0
- package/dist/stringify/stringifyPair.d.ts +3 -0
- package/dist/stringify/stringifyPair.js +115 -0
- package/dist/stringify/stringifyString.js +53 -52
- package/dist/test-events.d.ts +1 -2
- package/dist/test-events.js +25 -12
- package/dist/util.d.ts +1 -1
- package/dist/visit.d.ts +10 -1
- package/dist/visit.js +20 -1
- package/package.json +4 -3
- package/browser/dist/doc/Anchors.js +0 -102
- package/browser/dist/doc/Schema.js +0 -27
- package/browser/dist/doc/getSchemaTags.js +0 -30
- package/browser/dist/tags/core.js +0 -109
- package/browser/dist/tags/failsafe/index.js +0 -7
- package/browser/dist/tags/index.js +0 -34
- package/browser/dist/tags/yaml-1.1/index.js +0 -152
- package/dist/doc/Anchors.d.ts +0 -36
- package/dist/doc/Anchors.js +0 -104
- package/dist/doc/Schema.js +0 -29
- package/dist/doc/getSchemaTags.d.ts +0 -3
- package/dist/doc/getSchemaTags.js +0 -32
- package/dist/tags/core.d.ts +0 -14
- package/dist/tags/core.js +0 -119
- package/dist/tags/failsafe/index.d.ts +0 -1
- package/dist/tags/failsafe/index.js +0 -9
- package/dist/tags/index.d.ts +0 -31
- package/dist/tags/index.js +0 -37
- package/dist/tags/json.d.ts +0 -2
- package/dist/tags/yaml-1.1/index.d.ts +0 -2
- package/dist/tags/yaml-1.1/index.js +0 -154
package/dist/doc/Anchors.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Alias } from '../nodes/Alias.js';
|
|
2
|
-
import { Node } from '../nodes/Node.js';
|
|
3
|
-
import { Pair } from '../nodes/Pair.js';
|
|
4
|
-
import { Scalar } from '../nodes/Scalar.js';
|
|
5
|
-
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
6
|
-
export declare class Anchors {
|
|
7
|
-
map: Record<string, Node>;
|
|
8
|
-
private prefix;
|
|
9
|
-
constructor(prefix: string);
|
|
10
|
-
/**
|
|
11
|
-
* Create a new `Alias` node, adding the required anchor for `node`.
|
|
12
|
-
* If `name` is empty, a new anchor name will be generated.
|
|
13
|
-
*/
|
|
14
|
-
createAlias(node: Node, name?: string): Alias<Node>;
|
|
15
|
-
/**
|
|
16
|
-
* Create a new merge `Pair` with the given source nodes.
|
|
17
|
-
* Non-`Alias` sources will be automatically wrapped.
|
|
18
|
-
*/
|
|
19
|
-
createMergePair(...sources: Node[]): Pair<Scalar<string>, Alias<Node>> | Pair<Scalar<string>, YAMLSeq<Alias<Node>>>;
|
|
20
|
-
/** The anchor name associated with `node`, if set. */
|
|
21
|
-
getName(node: Node): string | undefined;
|
|
22
|
-
/** List of all defined anchor names. */
|
|
23
|
-
getNames(): string[];
|
|
24
|
-
/** The node associated with the anchor `name`, if set. */
|
|
25
|
-
getNode(name: string): Node;
|
|
26
|
-
/**
|
|
27
|
-
* Find an available anchor name with the given `prefix` and a
|
|
28
|
-
* numerical suffix.
|
|
29
|
-
*/
|
|
30
|
-
newName(prefix?: string): string;
|
|
31
|
-
/**
|
|
32
|
-
* Associate an anchor with `node`. If `name` is empty, a new name will be generated.
|
|
33
|
-
* To remove an anchor, use `setAnchor(null, name)`.
|
|
34
|
-
*/
|
|
35
|
-
setAnchor(node: Node | null, name?: string): string | null;
|
|
36
|
-
}
|
package/dist/doc/Anchors.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Alias = require('../nodes/Alias.js');
|
|
4
|
-
var Node = require('../nodes/Node.js');
|
|
5
|
-
var Pair = require('../nodes/Pair.js');
|
|
6
|
-
var Scalar = require('../nodes/Scalar.js');
|
|
7
|
-
var YAMLSeq = require('../nodes/YAMLSeq.js');
|
|
8
|
-
|
|
9
|
-
class Anchors {
|
|
10
|
-
constructor(prefix) {
|
|
11
|
-
this.map = Object.create(null);
|
|
12
|
-
this.prefix = prefix;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Create a new `Alias` node, adding the required anchor for `node`.
|
|
16
|
-
* If `name` is empty, a new anchor name will be generated.
|
|
17
|
-
*/
|
|
18
|
-
createAlias(node, name) {
|
|
19
|
-
this.setAnchor(node, name);
|
|
20
|
-
return new Alias.Alias(node);
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Create a new merge `Pair` with the given source nodes.
|
|
24
|
-
* Non-`Alias` sources will be automatically wrapped.
|
|
25
|
-
*/
|
|
26
|
-
createMergePair(...sources) {
|
|
27
|
-
const key = new Scalar.Scalar(Pair.Pair.MERGE_KEY);
|
|
28
|
-
const items = sources.map(s => {
|
|
29
|
-
if (Node.isAlias(s)) {
|
|
30
|
-
if (Node.isMap(s.source))
|
|
31
|
-
return s;
|
|
32
|
-
}
|
|
33
|
-
else if (Node.isMap(s)) {
|
|
34
|
-
return this.createAlias(s);
|
|
35
|
-
}
|
|
36
|
-
throw new Error('Merge sources must be Map nodes or their Aliases');
|
|
37
|
-
});
|
|
38
|
-
if (items.length === 1)
|
|
39
|
-
return new Pair.Pair(key, items[0]);
|
|
40
|
-
const seq = new YAMLSeq.YAMLSeq();
|
|
41
|
-
seq.items = items;
|
|
42
|
-
return new Pair.Pair(key, seq);
|
|
43
|
-
}
|
|
44
|
-
/** The anchor name associated with `node`, if set. */
|
|
45
|
-
getName(node) {
|
|
46
|
-
return Object.keys(this.map).find(a => this.map[a] === node);
|
|
47
|
-
}
|
|
48
|
-
/** List of all defined anchor names. */
|
|
49
|
-
getNames() {
|
|
50
|
-
return Object.keys(this.map);
|
|
51
|
-
}
|
|
52
|
-
/** The node associated with the anchor `name`, if set. */
|
|
53
|
-
getNode(name) {
|
|
54
|
-
return this.map[name];
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Find an available anchor name with the given `prefix` and a
|
|
58
|
-
* numerical suffix.
|
|
59
|
-
*/
|
|
60
|
-
newName(prefix) {
|
|
61
|
-
if (!prefix)
|
|
62
|
-
prefix = this.prefix;
|
|
63
|
-
const names = Object.keys(this.map);
|
|
64
|
-
for (let i = 1; true; ++i) {
|
|
65
|
-
const name = `${prefix}${i}`;
|
|
66
|
-
if (!names.includes(name))
|
|
67
|
-
return name;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Associate an anchor with `node`. If `name` is empty, a new name will be generated.
|
|
72
|
-
* To remove an anchor, use `setAnchor(null, name)`.
|
|
73
|
-
*/
|
|
74
|
-
setAnchor(node, name) {
|
|
75
|
-
const { map } = this;
|
|
76
|
-
if (!node) {
|
|
77
|
-
if (!name)
|
|
78
|
-
return null;
|
|
79
|
-
delete map[name];
|
|
80
|
-
return name;
|
|
81
|
-
}
|
|
82
|
-
if (!Node.isScalar(node) && !Node.isCollection(node))
|
|
83
|
-
throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
|
|
84
|
-
if (name) {
|
|
85
|
-
if (/[\x00-\x19\s,[\]{}]/.test(name))
|
|
86
|
-
throw new Error('Anchor names must not contain whitespace or control characters');
|
|
87
|
-
const prevNode = map[name];
|
|
88
|
-
if (prevNode && prevNode !== node)
|
|
89
|
-
map[this.newName(name)] = prevNode;
|
|
90
|
-
}
|
|
91
|
-
const prevName = Object.keys(map).find(a => map[a] === node);
|
|
92
|
-
if (prevName) {
|
|
93
|
-
if (!name || prevName === name)
|
|
94
|
-
return prevName;
|
|
95
|
-
delete map[prevName];
|
|
96
|
-
}
|
|
97
|
-
else if (!name)
|
|
98
|
-
name = this.newName();
|
|
99
|
-
map[name] = node;
|
|
100
|
-
return name;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exports.Anchors = Anchors;
|
package/dist/doc/Schema.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('../tags/index.js');
|
|
4
|
-
var getSchemaTags = require('./getSchemaTags.js');
|
|
5
|
-
|
|
6
|
-
const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
|
|
7
|
-
const coreKnownTags = {
|
|
8
|
-
'tag:yaml.org,2002:binary': index.tags.binary,
|
|
9
|
-
'tag:yaml.org,2002:omap': index.tags.omap,
|
|
10
|
-
'tag:yaml.org,2002:pairs': index.tags.pairs,
|
|
11
|
-
'tag:yaml.org,2002:set': index.tags.set,
|
|
12
|
-
'tag:yaml.org,2002:timestamp': index.tags.timestamp
|
|
13
|
-
};
|
|
14
|
-
class Schema {
|
|
15
|
-
constructor({ customTags, merge, resolveKnownTags, schema, sortMapEntries }) {
|
|
16
|
-
// Used by createNode(), to avoid circular dependencies
|
|
17
|
-
this.map = index.tags.map;
|
|
18
|
-
this.seq = index.tags.seq;
|
|
19
|
-
this.merge = !!merge;
|
|
20
|
-
this.name = schema || 'core';
|
|
21
|
-
this.knownTags = resolveKnownTags ? coreKnownTags : {};
|
|
22
|
-
this.tags = getSchemaTags.getSchemaTags(index.schemas, index.tags, customTags, this.name);
|
|
23
|
-
// Used by createMap()
|
|
24
|
-
this.sortMapEntries =
|
|
25
|
-
sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports.Schema = Schema;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { SchemaId, TagId, TagObj, TagValue } from '../tags/types.js';
|
|
2
|
-
import type { SchemaName } from './Schema.js';
|
|
3
|
-
export declare function getSchemaTags(schemas: Record<SchemaId, TagObj[]>, knownTags: Record<TagId, TagObj>, customTags: TagValue[] | ((tags: TagValue[]) => TagValue[]) | null | undefined, schemaName: SchemaName): TagObj[];
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function getSchemaTags(schemas, knownTags, customTags, schemaName) {
|
|
4
|
-
const schemaId = schemaName.replace(/\W/g, ''); // 'yaml-1.1' -> 'yaml11'
|
|
5
|
-
let tags = schemas[schemaId];
|
|
6
|
-
if (!tags) {
|
|
7
|
-
const keys = Object.keys(schemas)
|
|
8
|
-
.map(key => JSON.stringify(key))
|
|
9
|
-
.join(', ');
|
|
10
|
-
throw new Error(`Unknown schema "${schemaName}"; use one of ${keys}`);
|
|
11
|
-
}
|
|
12
|
-
if (Array.isArray(customTags)) {
|
|
13
|
-
for (const tag of customTags)
|
|
14
|
-
tags = tags.concat(tag);
|
|
15
|
-
}
|
|
16
|
-
else if (typeof customTags === 'function') {
|
|
17
|
-
tags = customTags(tags.slice());
|
|
18
|
-
}
|
|
19
|
-
return tags.map(tag => {
|
|
20
|
-
if (typeof tag !== 'string')
|
|
21
|
-
return tag;
|
|
22
|
-
const tagObj = knownTags[tag];
|
|
23
|
-
if (tagObj)
|
|
24
|
-
return tagObj;
|
|
25
|
-
const keys = Object.keys(knownTags)
|
|
26
|
-
.map(key => JSON.stringify(key))
|
|
27
|
-
.join(', ');
|
|
28
|
-
throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.getSchemaTags = getSchemaTags;
|
package/dist/tags/core.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ScalarTag } from './types.js';
|
|
2
|
-
export declare const nullObj: ScalarTag & {
|
|
3
|
-
test: RegExp;
|
|
4
|
-
};
|
|
5
|
-
export declare const boolObj: ScalarTag & {
|
|
6
|
-
test: RegExp;
|
|
7
|
-
};
|
|
8
|
-
export declare const octObj: ScalarTag;
|
|
9
|
-
export declare const intObj: ScalarTag;
|
|
10
|
-
export declare const hexObj: ScalarTag;
|
|
11
|
-
export declare const nanObj: ScalarTag;
|
|
12
|
-
export declare const expObj: ScalarTag;
|
|
13
|
-
export declare const floatObj: ScalarTag;
|
|
14
|
-
export declare const core: (ScalarTag | import("./types.js").CollectionTag)[];
|
package/dist/tags/core.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Scalar = require('../nodes/Scalar.js');
|
|
4
|
-
var stringifyNumber = require('../stringify/stringifyNumber.js');
|
|
5
|
-
var index = require('./failsafe/index.js');
|
|
6
|
-
|
|
7
|
-
const intIdentify = (value) => typeof value === 'bigint' || Number.isInteger(value);
|
|
8
|
-
const intResolve = (str, offset, radix, { intAsBigInt }) => (intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix));
|
|
9
|
-
function intStringify(node, radix, prefix) {
|
|
10
|
-
const { value } = node;
|
|
11
|
-
if (intIdentify(value) && value >= 0)
|
|
12
|
-
return prefix + value.toString(radix);
|
|
13
|
-
return stringifyNumber.stringifyNumber(node);
|
|
14
|
-
}
|
|
15
|
-
const nullObj = {
|
|
16
|
-
identify: value => value == null,
|
|
17
|
-
createNode: () => new Scalar.Scalar(null),
|
|
18
|
-
default: true,
|
|
19
|
-
tag: 'tag:yaml.org,2002:null',
|
|
20
|
-
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
21
|
-
resolve: () => new Scalar.Scalar(null),
|
|
22
|
-
stringify: ({ source }, ctx) => source && nullObj.test.test(source) ? source : ctx.options.nullStr
|
|
23
|
-
};
|
|
24
|
-
const boolObj = {
|
|
25
|
-
identify: value => typeof value === 'boolean',
|
|
26
|
-
default: true,
|
|
27
|
-
tag: 'tag:yaml.org,2002:bool',
|
|
28
|
-
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
29
|
-
resolve: str => new Scalar.Scalar(str[0] === 't' || str[0] === 'T'),
|
|
30
|
-
stringify({ source, value }, ctx) {
|
|
31
|
-
if (source && boolObj.test.test(source)) {
|
|
32
|
-
const sv = source[0] === 't' || source[0] === 'T';
|
|
33
|
-
if (value === sv)
|
|
34
|
-
return source;
|
|
35
|
-
}
|
|
36
|
-
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
const octObj = {
|
|
40
|
-
identify: value => intIdentify(value) && value >= 0,
|
|
41
|
-
default: true,
|
|
42
|
-
tag: 'tag:yaml.org,2002:int',
|
|
43
|
-
format: 'OCT',
|
|
44
|
-
test: /^0o[0-7]+$/,
|
|
45
|
-
resolve: (str, _onError, opt) => intResolve(str, 2, 8, opt),
|
|
46
|
-
stringify: node => intStringify(node, 8, '0o')
|
|
47
|
-
};
|
|
48
|
-
const intObj = {
|
|
49
|
-
identify: intIdentify,
|
|
50
|
-
default: true,
|
|
51
|
-
tag: 'tag:yaml.org,2002:int',
|
|
52
|
-
test: /^[-+]?[0-9]+$/,
|
|
53
|
-
resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
|
|
54
|
-
stringify: stringifyNumber.stringifyNumber
|
|
55
|
-
};
|
|
56
|
-
const hexObj = {
|
|
57
|
-
identify: value => intIdentify(value) && value >= 0,
|
|
58
|
-
default: true,
|
|
59
|
-
tag: 'tag:yaml.org,2002:int',
|
|
60
|
-
format: 'HEX',
|
|
61
|
-
test: /^0x[0-9a-fA-F]+$/,
|
|
62
|
-
resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
|
|
63
|
-
stringify: node => intStringify(node, 16, '0x')
|
|
64
|
-
};
|
|
65
|
-
const nanObj = {
|
|
66
|
-
identify: value => typeof value === 'number',
|
|
67
|
-
default: true,
|
|
68
|
-
tag: 'tag:yaml.org,2002:float',
|
|
69
|
-
test: /^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/,
|
|
70
|
-
resolve: str => str.slice(-3).toLowerCase() === 'nan'
|
|
71
|
-
? NaN
|
|
72
|
-
: str[0] === '-'
|
|
73
|
-
? Number.NEGATIVE_INFINITY
|
|
74
|
-
: Number.POSITIVE_INFINITY,
|
|
75
|
-
stringify: stringifyNumber.stringifyNumber
|
|
76
|
-
};
|
|
77
|
-
const expObj = {
|
|
78
|
-
identify: value => typeof value === 'number',
|
|
79
|
-
default: true,
|
|
80
|
-
tag: 'tag:yaml.org,2002:float',
|
|
81
|
-
format: 'EXP',
|
|
82
|
-
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
83
|
-
resolve: str => parseFloat(str),
|
|
84
|
-
stringify: ({ value }) => Number(value).toExponential()
|
|
85
|
-
};
|
|
86
|
-
const floatObj = {
|
|
87
|
-
identify: value => typeof value === 'number',
|
|
88
|
-
default: true,
|
|
89
|
-
tag: 'tag:yaml.org,2002:float',
|
|
90
|
-
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
91
|
-
resolve(str) {
|
|
92
|
-
const node = new Scalar.Scalar(parseFloat(str));
|
|
93
|
-
const dot = str.indexOf('.');
|
|
94
|
-
if (dot !== -1 && str[str.length - 1] === '0')
|
|
95
|
-
node.minFractionDigits = str.length - dot - 1;
|
|
96
|
-
return node;
|
|
97
|
-
},
|
|
98
|
-
stringify: stringifyNumber.stringifyNumber
|
|
99
|
-
};
|
|
100
|
-
const core = index.failsafe.concat([
|
|
101
|
-
nullObj,
|
|
102
|
-
boolObj,
|
|
103
|
-
octObj,
|
|
104
|
-
intObj,
|
|
105
|
-
hexObj,
|
|
106
|
-
nanObj,
|
|
107
|
-
expObj,
|
|
108
|
-
floatObj
|
|
109
|
-
]);
|
|
110
|
-
|
|
111
|
-
exports.boolObj = boolObj;
|
|
112
|
-
exports.core = core;
|
|
113
|
-
exports.expObj = expObj;
|
|
114
|
-
exports.floatObj = floatObj;
|
|
115
|
-
exports.hexObj = hexObj;
|
|
116
|
-
exports.intObj = intObj;
|
|
117
|
-
exports.nanObj = nanObj;
|
|
118
|
-
exports.nullObj = nullObj;
|
|
119
|
-
exports.octObj = octObj;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const failsafe: (import("../types.js").ScalarTag | import("../types.js").CollectionTag)[];
|
package/dist/tags/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare const schemas: {
|
|
2
|
-
core: (import("./types.js").ScalarTag | import("./types.js").CollectionTag)[];
|
|
3
|
-
failsafe: (import("./types.js").ScalarTag | import("./types.js").CollectionTag)[];
|
|
4
|
-
json: (import("./types.js").ScalarTag | import("./types.js").CollectionTag)[];
|
|
5
|
-
yaml11: (import("./types.js").ScalarTag | import("./types.js").CollectionTag)[];
|
|
6
|
-
};
|
|
7
|
-
export declare const tags: {
|
|
8
|
-
binary: import("./types.js").ScalarTag;
|
|
9
|
-
bool: import("./types.js").ScalarTag & {
|
|
10
|
-
test: RegExp;
|
|
11
|
-
};
|
|
12
|
-
float: import("./types.js").ScalarTag;
|
|
13
|
-
floatExp: import("./types.js").ScalarTag;
|
|
14
|
-
floatNaN: import("./types.js").ScalarTag;
|
|
15
|
-
floatTime: import("./types.js").ScalarTag;
|
|
16
|
-
int: import("./types.js").ScalarTag;
|
|
17
|
-
intHex: import("./types.js").ScalarTag;
|
|
18
|
-
intOct: import("./types.js").ScalarTag;
|
|
19
|
-
intTime: import("./types.js").ScalarTag;
|
|
20
|
-
map: import("./types.js").CollectionTag;
|
|
21
|
-
null: import("./types.js").ScalarTag & {
|
|
22
|
-
test: RegExp;
|
|
23
|
-
};
|
|
24
|
-
omap: import("./types.js").CollectionTag;
|
|
25
|
-
pairs: import("./types.js").CollectionTag;
|
|
26
|
-
seq: import("./types.js").CollectionTag;
|
|
27
|
-
set: import("./types.js").CollectionTag;
|
|
28
|
-
timestamp: import("./types.js").ScalarTag & {
|
|
29
|
-
test: RegExp;
|
|
30
|
-
};
|
|
31
|
-
};
|
package/dist/tags/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('./core.js');
|
|
4
|
-
var index = require('./failsafe/index.js');
|
|
5
|
-
var json = require('./json.js');
|
|
6
|
-
var index$1 = require('./yaml-1.1/index.js');
|
|
7
|
-
var map = require('./failsafe/map.js');
|
|
8
|
-
var seq = require('./failsafe/seq.js');
|
|
9
|
-
var binary = require('./yaml-1.1/binary.js');
|
|
10
|
-
var omap = require('./yaml-1.1/omap.js');
|
|
11
|
-
var pairs = require('./yaml-1.1/pairs.js');
|
|
12
|
-
var set = require('./yaml-1.1/set.js');
|
|
13
|
-
var timestamp = require('./yaml-1.1/timestamp.js');
|
|
14
|
-
|
|
15
|
-
const schemas = { core: core.core, failsafe: index.failsafe, json: json.json, yaml11: index$1.yaml11 };
|
|
16
|
-
const tags = {
|
|
17
|
-
binary: binary.binary,
|
|
18
|
-
bool: core.boolObj,
|
|
19
|
-
float: core.floatObj,
|
|
20
|
-
floatExp: core.expObj,
|
|
21
|
-
floatNaN: core.nanObj,
|
|
22
|
-
floatTime: timestamp.floatTime,
|
|
23
|
-
int: core.intObj,
|
|
24
|
-
intHex: core.hexObj,
|
|
25
|
-
intOct: core.octObj,
|
|
26
|
-
intTime: timestamp.intTime,
|
|
27
|
-
map: map.map,
|
|
28
|
-
null: core.nullObj,
|
|
29
|
-
omap: omap.omap,
|
|
30
|
-
pairs: pairs.pairs,
|
|
31
|
-
seq: seq.seq,
|
|
32
|
-
set: set.set,
|
|
33
|
-
timestamp: timestamp.timestamp
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.schemas = schemas;
|
|
37
|
-
exports.tags = tags;
|
package/dist/tags/json.d.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Scalar = require('../../nodes/Scalar.js');
|
|
4
|
-
var stringifyNumber = require('../../stringify/stringifyNumber.js');
|
|
5
|
-
var index = require('../failsafe/index.js');
|
|
6
|
-
var binary = require('./binary.js');
|
|
7
|
-
var omap = require('./omap.js');
|
|
8
|
-
var pairs = require('./pairs.js');
|
|
9
|
-
var set = require('./set.js');
|
|
10
|
-
var timestamp = require('./timestamp.js');
|
|
11
|
-
|
|
12
|
-
const nullObj = {
|
|
13
|
-
identify: value => value == null,
|
|
14
|
-
createNode: () => new Scalar.Scalar(null),
|
|
15
|
-
default: true,
|
|
16
|
-
tag: 'tag:yaml.org,2002:null',
|
|
17
|
-
test: /^(?:~|[Nn]ull|NULL)?$/,
|
|
18
|
-
resolve: () => new Scalar.Scalar(null),
|
|
19
|
-
stringify: ({ source }, ctx) => source && nullObj.test.test(source) ? source : ctx.options.nullStr
|
|
20
|
-
};
|
|
21
|
-
function boolStringify({ value, source }, ctx) {
|
|
22
|
-
const boolObj = value ? trueObj : falseObj;
|
|
23
|
-
if (source && boolObj.test.test(source))
|
|
24
|
-
return source;
|
|
25
|
-
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
26
|
-
}
|
|
27
|
-
const trueObj = {
|
|
28
|
-
identify: value => value === true,
|
|
29
|
-
default: true,
|
|
30
|
-
tag: 'tag:yaml.org,2002:bool',
|
|
31
|
-
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
32
|
-
resolve: () => new Scalar.Scalar(true),
|
|
33
|
-
stringify: boolStringify
|
|
34
|
-
};
|
|
35
|
-
const falseObj = {
|
|
36
|
-
identify: value => value === false,
|
|
37
|
-
default: true,
|
|
38
|
-
tag: 'tag:yaml.org,2002:bool',
|
|
39
|
-
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
|
40
|
-
resolve: () => new Scalar.Scalar(false),
|
|
41
|
-
stringify: boolStringify
|
|
42
|
-
};
|
|
43
|
-
const intIdentify = (value) => typeof value === 'bigint' || Number.isInteger(value);
|
|
44
|
-
function intResolve(str, offset, radix, { intAsBigInt }) {
|
|
45
|
-
const sign = str[0];
|
|
46
|
-
if (sign === '-' || sign === '+')
|
|
47
|
-
offset += 1;
|
|
48
|
-
str = str.substring(offset).replace(/_/g, '');
|
|
49
|
-
if (intAsBigInt) {
|
|
50
|
-
switch (radix) {
|
|
51
|
-
case 2:
|
|
52
|
-
str = `0b${str}`;
|
|
53
|
-
break;
|
|
54
|
-
case 8:
|
|
55
|
-
str = `0o${str}`;
|
|
56
|
-
break;
|
|
57
|
-
case 16:
|
|
58
|
-
str = `0x${str}`;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
const n = BigInt(str);
|
|
62
|
-
return sign === '-' ? BigInt(-1) * n : n;
|
|
63
|
-
}
|
|
64
|
-
const n = parseInt(str, radix);
|
|
65
|
-
return sign === '-' ? -1 * n : n;
|
|
66
|
-
}
|
|
67
|
-
function intStringify(node, radix, prefix) {
|
|
68
|
-
const { value } = node;
|
|
69
|
-
if (intIdentify(value)) {
|
|
70
|
-
const str = value.toString(radix);
|
|
71
|
-
return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
|
|
72
|
-
}
|
|
73
|
-
return stringifyNumber.stringifyNumber(node);
|
|
74
|
-
}
|
|
75
|
-
const yaml11 = index.failsafe.concat([
|
|
76
|
-
nullObj,
|
|
77
|
-
trueObj,
|
|
78
|
-
falseObj,
|
|
79
|
-
{
|
|
80
|
-
identify: intIdentify,
|
|
81
|
-
default: true,
|
|
82
|
-
tag: 'tag:yaml.org,2002:int',
|
|
83
|
-
format: 'BIN',
|
|
84
|
-
test: /^[-+]?0b[0-1_]+$/,
|
|
85
|
-
resolve: (str, _onError, opt) => intResolve(str, 2, 2, opt),
|
|
86
|
-
stringify: node => intStringify(node, 2, '0b')
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
identify: intIdentify,
|
|
90
|
-
default: true,
|
|
91
|
-
tag: 'tag:yaml.org,2002:int',
|
|
92
|
-
format: 'OCT',
|
|
93
|
-
test: /^[-+]?0[0-7_]+$/,
|
|
94
|
-
resolve: (str, _onError, opt) => intResolve(str, 1, 8, opt),
|
|
95
|
-
stringify: node => intStringify(node, 8, '0')
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
identify: intIdentify,
|
|
99
|
-
default: true,
|
|
100
|
-
tag: 'tag:yaml.org,2002:int',
|
|
101
|
-
test: /^[-+]?[0-9][0-9_]*$/,
|
|
102
|
-
resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
|
|
103
|
-
stringify: stringifyNumber.stringifyNumber
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
identify: intIdentify,
|
|
107
|
-
default: true,
|
|
108
|
-
tag: 'tag:yaml.org,2002:int',
|
|
109
|
-
format: 'HEX',
|
|
110
|
-
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
111
|
-
resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
|
|
112
|
-
stringify: node => intStringify(node, 16, '0x')
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
identify: value => typeof value === 'number',
|
|
116
|
-
default: true,
|
|
117
|
-
tag: 'tag:yaml.org,2002:float',
|
|
118
|
-
test: /^[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN)$/,
|
|
119
|
-
resolve: (str) => str.slice(-3).toLowerCase() === 'nan'
|
|
120
|
-
? NaN
|
|
121
|
-
: str[0] === '-'
|
|
122
|
-
? Number.NEGATIVE_INFINITY
|
|
123
|
-
: Number.POSITIVE_INFINITY,
|
|
124
|
-
stringify: stringifyNumber.stringifyNumber
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
identify: value => typeof value === 'number',
|
|
128
|
-
default: true,
|
|
129
|
-
tag: 'tag:yaml.org,2002:float',
|
|
130
|
-
format: 'EXP',
|
|
131
|
-
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
132
|
-
resolve: (str) => parseFloat(str.replace(/_/g, '')),
|
|
133
|
-
stringify: ({ value }) => Number(value).toExponential()
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
identify: value => typeof value === 'number',
|
|
137
|
-
default: true,
|
|
138
|
-
tag: 'tag:yaml.org,2002:float',
|
|
139
|
-
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
140
|
-
resolve(str) {
|
|
141
|
-
const node = new Scalar.Scalar(parseFloat(str.replace(/_/g, '')));
|
|
142
|
-
const dot = str.indexOf('.');
|
|
143
|
-
if (dot !== -1) {
|
|
144
|
-
const f = str.substring(dot + 1).replace(/_/g, '');
|
|
145
|
-
if (f[f.length - 1] === '0')
|
|
146
|
-
node.minFractionDigits = f.length;
|
|
147
|
-
}
|
|
148
|
-
return node;
|
|
149
|
-
},
|
|
150
|
-
stringify: stringifyNumber.stringifyNumber
|
|
151
|
-
}
|
|
152
|
-
], binary.binary, omap.omap, pairs.pairs, set.set, timestamp.intTime, timestamp.floatTime, timestamp.timestamp);
|
|
153
|
-
|
|
154
|
-
exports.yaml11 = yaml11;
|