yaml 1.9.2 → 1.10.0
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 +4 -4
- package/browser/dist/PlainValue-ff5147c6.js +1277 -0
- package/browser/dist/Schema-2bf2c74e.js +679 -0
- package/browser/dist/index.js +869 -34
- package/browser/dist/legacy-exports.js +3 -0
- package/browser/dist/parse-cst.js +1904 -0
- package/browser/dist/resolveSeq-04825f30.js +2373 -0
- package/browser/dist/types.js +4 -0
- package/browser/dist/util.js +2 -0
- package/browser/dist/warnings-0e4b70d3.js +499 -0
- package/browser/index.js +1 -1
- package/browser/map.js +2 -4
- package/browser/pair.js +2 -4
- package/browser/parse-cst.js +1 -1
- package/browser/scalar.js +2 -4
- package/browser/schema.js +7 -10
- package/browser/seq.js +2 -4
- package/browser/types/binary.js +7 -5
- package/browser/types/omap.js +3 -4
- package/browser/types/pairs.js +3 -4
- package/browser/types/set.js +3 -4
- package/browser/types/timestamp.js +9 -5
- package/browser/types.js +1 -13
- package/browser/util.js +1 -18
- package/dist/Document-2cf6b08c.js +757 -0
- package/dist/PlainValue-ec8e588e.js +876 -0
- package/dist/Schema-42e9705c.js +522 -0
- package/dist/index.js +20 -84
- package/dist/legacy-exports.js +16 -0
- package/dist/parse-cst.js +1747 -0
- package/dist/resolveSeq-4a68b39b.js +2115 -0
- package/dist/test-events.js +11 -9
- package/dist/types.js +23 -0
- package/dist/util.js +19 -0
- package/dist/warnings-39684f17.js +416 -0
- package/index.d.ts +22 -8
- package/map.js +2 -2
- package/package.json +22 -39
- package/pair.js +2 -2
- package/parse-cst.js +1 -1
- package/scalar.js +2 -2
- package/schema.js +8 -6
- package/seq.js +2 -2
- package/types/binary.js +3 -2
- package/types/omap.js +3 -2
- package/types/pairs.js +3 -2
- package/types/set.js +3 -2
- package/types/timestamp.js +6 -6
- package/types.d.ts +113 -99
- package/types.js +16 -11
- package/types.mjs +15 -19
- package/util.js +14 -14
- package/util.mjs +13 -20
- package/browser/dist/Anchors.js +0 -130
- package/browser/dist/Document.js +0 -824
- package/browser/dist/addComment.js +0 -8
- package/browser/dist/constants.js +0 -26
- package/browser/dist/cst/Alias.js +0 -46
- package/browser/dist/cst/BlankLine.js +0 -52
- package/browser/dist/cst/BlockValue.js +0 -251
- package/browser/dist/cst/Collection.js +0 -278
- package/browser/dist/cst/CollectionItem.js +0 -140
- package/browser/dist/cst/Comment.js +0 -44
- package/browser/dist/cst/Directive.js +0 -76
- package/browser/dist/cst/Document.js +0 -286
- package/browser/dist/cst/FlowCollection.js +0 -220
- package/browser/dist/cst/Node.js +0 -386
- package/browser/dist/cst/ParseContext.js +0 -246
- package/browser/dist/cst/PlainValue.js +0 -170
- package/browser/dist/cst/QuoteDouble.js +0 -245
- package/browser/dist/cst/QuoteSingle.js +0 -120
- package/browser/dist/cst/Range.js +0 -64
- package/browser/dist/cst/parse.js +0 -48
- package/browser/dist/cst/source-utils.js +0 -168
- package/browser/dist/errors.js +0 -127
- package/browser/dist/foldFlowLines.js +0 -138
- package/browser/dist/listTagNames.js +0 -28
- package/browser/dist/schema/Alias.js +0 -135
- package/browser/dist/schema/Collection.js +0 -260
- package/browser/dist/schema/Map.js +0 -161
- package/browser/dist/schema/Merge.js +0 -118
- package/browser/dist/schema/Node.js +0 -4
- package/browser/dist/schema/Pair.js +0 -194
- package/browser/dist/schema/Scalar.js +0 -42
- package/browser/dist/schema/Seq.js +0 -116
- package/browser/dist/schema/index.js +0 -368
- package/browser/dist/schema/parseMap.js +0 -312
- package/browser/dist/schema/parseSeq.js +0 -168
- package/browser/dist/schema/parseUtils.js +0 -106
- package/browser/dist/stringify.js +0 -332
- package/browser/dist/tags/core.js +0 -141
- package/browser/dist/tags/failsafe/index.js +0 -4
- package/browser/dist/tags/failsafe/map.js +0 -53
- package/browser/dist/tags/failsafe/seq.js +0 -39
- package/browser/dist/tags/failsafe/string.js +0 -28
- package/browser/dist/tags/index.js +0 -36
- package/browser/dist/tags/json.js +0 -77
- package/browser/dist/tags/options.js +0 -26
- package/browser/dist/tags/yaml-1.1/binary.js +0 -87
- package/browser/dist/tags/yaml-1.1/index.js +0 -189
- package/browser/dist/tags/yaml-1.1/omap.js +0 -137
- package/browser/dist/tags/yaml-1.1/pairs.js +0 -78
- package/browser/dist/tags/yaml-1.1/set.js +0 -118
- package/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
- package/browser/dist/test-events.js +0 -163
- package/browser/dist/toJSON.js +0 -19
- package/browser/dist/warnings.js +0 -39
- package/dist/Anchors.js +0 -120
- package/dist/Document.js +0 -714
- package/dist/addComment.js +0 -14
- package/dist/constants.js +0 -31
- package/dist/cst/Alias.js +0 -33
- package/dist/cst/BlankLine.js +0 -40
- package/dist/cst/BlockValue.js +0 -243
- package/dist/cst/Collection.js +0 -266
- package/dist/cst/CollectionItem.js +0 -135
- package/dist/cst/Comment.js +0 -33
- package/dist/cst/Directive.js +0 -59
- package/dist/cst/Document.js +0 -276
- package/dist/cst/FlowCollection.js +0 -213
- package/dist/cst/Node.js +0 -360
- package/dist/cst/ParseContext.js +0 -253
- package/dist/cst/PlainValue.js +0 -156
- package/dist/cst/QuoteDouble.js +0 -232
- package/dist/cst/QuoteSingle.js +0 -108
- package/dist/cst/Range.js +0 -60
- package/dist/cst/parse.js +0 -50
- package/dist/cst/source-utils.js +0 -175
- package/dist/errors.js +0 -97
- package/dist/foldFlowLines.js +0 -143
- package/dist/listTagNames.js +0 -33
- package/dist/schema/Alias.js +0 -105
- package/dist/schema/Collection.js +0 -184
- package/dist/schema/Map.js +0 -98
- package/dist/schema/Merge.js +0 -75
- package/dist/schema/Node.js +0 -7
- package/dist/schema/Pair.js +0 -174
- package/dist/schema/Scalar.js +0 -26
- package/dist/schema/Seq.js +0 -73
- package/dist/schema/index.js +0 -310
- package/dist/schema/parseMap.js +0 -334
- package/dist/schema/parseSeq.js +0 -175
- package/dist/schema/parseUtils.js +0 -101
- package/dist/stringify.js +0 -352
- package/dist/tags/core.js +0 -121
- package/dist/tags/failsafe/index.js +0 -12
- package/dist/tags/failsafe/map.js +0 -32
- package/dist/tags/failsafe/seq.js +0 -29
- package/dist/tags/failsafe/string.js +0 -37
- package/dist/tags/index.js +0 -53
- package/dist/tags/json.js +0 -64
- package/dist/tags/options.js +0 -36
- package/dist/tags/yaml-1.1/binary.js +0 -94
- package/dist/tags/yaml-1.1/index.js +0 -162
- package/dist/tags/yaml-1.1/omap.js +0 -100
- package/dist/tags/yaml-1.1/pairs.js +0 -75
- package/dist/tags/yaml-1.1/set.js +0 -82
- package/dist/tags/yaml-1.1/timestamp.js +0 -90
- package/dist/toJSON.js +0 -21
- package/dist/warnings.js +0 -48
package/pair.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
2
|
-
require('./dist/
|
|
1
|
+
module.exports = require('./dist/types').Pair
|
|
2
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/parse-cst.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('./dist/cst
|
|
1
|
+
module.exports = require('./dist/parse-cst').parse
|
package/scalar.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
2
|
-
require('./dist/
|
|
1
|
+
module.exports = require('./dist/types').Scalar
|
|
2
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/schema.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
module.exports.nullOptions = opt.nullOptions
|
|
4
|
-
module.exports.strOptions = opt.strOptions
|
|
5
|
-
module.exports.stringify = require('./dist/stringify').stringifyString
|
|
1
|
+
const types = require('./dist/types')
|
|
2
|
+
const util = require('./dist/util')
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
module.exports = types.Schema
|
|
5
|
+
module.exports.nullOptions = types.nullOptions
|
|
6
|
+
module.exports.strOptions = types.strOptions
|
|
7
|
+
module.exports.stringify = util.stringifyString
|
|
8
|
+
|
|
9
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/seq.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
module.exports = require('./dist/
|
|
2
|
-
require('./dist/
|
|
1
|
+
module.exports = require('./dist/types').YAMLSeq
|
|
2
|
+
require('./dist/legacy-exports').warnFileDeprecation(__filename)
|
package/types/binary.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const legacy = require('../dist/legacy-exports')
|
|
5
|
+
exports.binary = legacy.binary
|
|
5
6
|
exports.default = [exports.binary]
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/omap.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const legacy = require('../dist/legacy-exports')
|
|
2
|
+
module.exports = legacy.omap
|
|
3
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/pairs.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const legacy = require('../dist/legacy-exports')
|
|
2
|
+
module.exports = legacy.pairs
|
|
3
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/set.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const legacy = require('../dist/legacy-exports')
|
|
2
|
+
module.exports = legacy.set
|
|
3
|
+
legacy.warnFileDeprecation(__filename)
|
package/types/timestamp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
Object.defineProperty(exports, '__esModule', { value: true })
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
exports.default = [
|
|
6
|
-
exports.floatTime =
|
|
7
|
-
exports.intTime =
|
|
8
|
-
exports.timestamp =
|
|
4
|
+
const legacy = require('../dist/legacy-exports')
|
|
5
|
+
exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp]
|
|
6
|
+
exports.floatTime = legacy.floatTime
|
|
7
|
+
exports.intTime = legacy.intTime
|
|
8
|
+
exports.timestamp = legacy.timestamp
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
legacy.warnFileDeprecation(__filename)
|
package/types.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export class Schema {
|
|
|
22
22
|
constructor(options: Schema.Options)
|
|
23
23
|
/**
|
|
24
24
|
* Convert any value into a `Node` using this schema, recursively turning
|
|
25
|
-
* objects into
|
|
25
|
+
* objects into collections.
|
|
26
26
|
*
|
|
27
27
|
* @param wrapScalars If `true`, also wraps plain values in `Scalar` objects;
|
|
28
28
|
* if undefined or `false` and `value` is not an object, it will be returned
|
|
@@ -35,7 +35,14 @@ export class Schema {
|
|
|
35
35
|
wrapScalars?: boolean,
|
|
36
36
|
tag?: string,
|
|
37
37
|
ctx?: Schema.CreateNodeContext
|
|
38
|
-
):
|
|
38
|
+
): Node
|
|
39
|
+
/**
|
|
40
|
+
* Convert a key and a value into a `Pair` using this schema, recursively
|
|
41
|
+
* wrapping all values as `Scalar` or `Collection` nodes.
|
|
42
|
+
*
|
|
43
|
+
* @param ctx To not wrap scalars, use a context `{ wrapScalars: false }`
|
|
44
|
+
*/
|
|
45
|
+
createPair(key: any, value: any, ctx?: Schema.CreateNodeContext): Pair
|
|
39
46
|
merge: boolean
|
|
40
47
|
name: Schema.Name
|
|
41
48
|
sortMapEntries: ((a: Pair, b: Pair) => number) | null
|
|
@@ -147,7 +154,7 @@ export namespace Schema {
|
|
|
147
154
|
* type with the `+` chomping indicator.
|
|
148
155
|
*/
|
|
149
156
|
stringify?: (
|
|
150
|
-
item:
|
|
157
|
+
item: Node,
|
|
151
158
|
ctx: Schema.StringifyContext,
|
|
152
159
|
onComment?: () => void,
|
|
153
160
|
onChompKeep?: () => void
|
|
@@ -170,7 +177,7 @@ export namespace Schema {
|
|
|
170
177
|
* Turns a CST node into an AST node. If returning a non-`Node` value, the
|
|
171
178
|
* output will be wrapped as a `Scalar`.
|
|
172
179
|
*/
|
|
173
|
-
resolve(doc: Document, cstNode: CST.Node):
|
|
180
|
+
resolve(doc: Document, cstNode: CST.Node): Node | any
|
|
174
181
|
}
|
|
175
182
|
|
|
176
183
|
interface DefaultTag extends BaseTag {
|
|
@@ -183,7 +190,7 @@ export namespace Schema {
|
|
|
183
190
|
/**
|
|
184
191
|
* Alternative form used by default tags; called with `test` match results.
|
|
185
192
|
*/
|
|
186
|
-
resolve(...match: string[]):
|
|
193
|
+
resolve(...match: string[]): Node | any
|
|
187
194
|
/**
|
|
188
195
|
* Together with `default` allows for values to be stringified without an
|
|
189
196
|
* explicit tag and detected using a regular expression. For most cases, it's
|
|
@@ -194,9 +201,30 @@ export namespace Schema {
|
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
203
|
|
|
197
|
-
export class
|
|
204
|
+
export class Node {
|
|
205
|
+
/** A comment on or immediately after this */
|
|
206
|
+
comment?: string | null
|
|
207
|
+
/** A comment before this */
|
|
208
|
+
commentBefore?: string | null
|
|
209
|
+
/** Only available when `keepCstNodes` is set to `true` */
|
|
210
|
+
cstNode?: CST.Node
|
|
211
|
+
/**
|
|
212
|
+
* The [start, end] range of characters of the source parsed
|
|
213
|
+
* into this node (undefined for pairs or if not parsed)
|
|
214
|
+
*/
|
|
215
|
+
range?: [number, number] | null
|
|
216
|
+
/** A blank line before this node and its commentBefore */
|
|
217
|
+
spaceBefore?: boolean
|
|
218
|
+
/** A fully qualified tag, if required */
|
|
219
|
+
tag?: string
|
|
220
|
+
/** A plain JS representation of this node */
|
|
221
|
+
toJSON(arg?: any): any
|
|
222
|
+
/** The type of this node */
|
|
223
|
+
type?: Type | Pair.Type
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export class Scalar extends Node {
|
|
198
227
|
constructor(value: any)
|
|
199
|
-
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any
|
|
200
228
|
type?: Scalar.Type
|
|
201
229
|
/**
|
|
202
230
|
* By default (undefined), numbers use decimal notation.
|
|
@@ -204,6 +232,8 @@ export class Scalar extends AST.Node {
|
|
|
204
232
|
*/
|
|
205
233
|
format?: 'BIN' | 'HEX' | 'OCT' | 'TIME'
|
|
206
234
|
value: any
|
|
235
|
+
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any
|
|
236
|
+
toString(): string
|
|
207
237
|
}
|
|
208
238
|
export namespace Scalar {
|
|
209
239
|
type Type =
|
|
@@ -214,15 +244,27 @@ export namespace Scalar {
|
|
|
214
244
|
| Type.QUOTE_SINGLE
|
|
215
245
|
}
|
|
216
246
|
|
|
217
|
-
export class
|
|
247
|
+
export class Alias extends Node {
|
|
248
|
+
type: Type.ALIAS
|
|
249
|
+
source: Node
|
|
250
|
+
cstNode?: CST.Alias
|
|
251
|
+
toString(ctx: Schema.StringifyContext): string
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export class Pair extends Node {
|
|
218
255
|
constructor(key: any, value?: any)
|
|
219
|
-
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
|
|
220
256
|
type: Pair.Type.PAIR | Pair.Type.MERGE_PAIR
|
|
221
257
|
/** Always Node or null when parsed, but can be set to anything. */
|
|
222
258
|
key: any
|
|
223
259
|
/** Always Node or null when parsed, but can be set to anything. */
|
|
224
260
|
value: any
|
|
225
261
|
cstNode?: never // no corresponding cstNode
|
|
262
|
+
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
|
|
263
|
+
toString(
|
|
264
|
+
ctx?: Schema.StringifyContext,
|
|
265
|
+
onComment?: () => void,
|
|
266
|
+
onChompKeep?: () => void
|
|
267
|
+
): string
|
|
226
268
|
}
|
|
227
269
|
export namespace Pair {
|
|
228
270
|
enum Type {
|
|
@@ -231,14 +273,66 @@ export namespace Pair {
|
|
|
231
273
|
}
|
|
232
274
|
}
|
|
233
275
|
|
|
234
|
-
export class
|
|
276
|
+
export class Merge extends Pair {
|
|
277
|
+
type: Pair.Type.MERGE_PAIR
|
|
278
|
+
/** Always Scalar('<<'), defined by the type specification */
|
|
279
|
+
key: AST.PlainValue
|
|
280
|
+
/** Always YAMLSeq<Alias(Map)>, stringified as *A if length = 1 */
|
|
281
|
+
value: YAMLSeq
|
|
282
|
+
toString(ctx?: Schema.StringifyContext, onComment?: () => void): string
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export class Collection extends Node {
|
|
286
|
+
type?: Type.MAP | Type.FLOW_MAP | Type.SEQ | Type.FLOW_SEQ | Type.DOCUMENT
|
|
287
|
+
items: any[]
|
|
288
|
+
schema?: Schema
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
292
|
+
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
293
|
+
* that already exists in the map.
|
|
294
|
+
*/
|
|
295
|
+
add(value: any): void
|
|
296
|
+
addIn(path: Iterable<any>, value: any): void
|
|
297
|
+
/**
|
|
298
|
+
* Removes a value from the collection.
|
|
299
|
+
* @returns `true` if the item was found and removed.
|
|
300
|
+
*/
|
|
301
|
+
delete(key: any): boolean
|
|
302
|
+
deleteIn(path: Iterable<any>): boolean
|
|
303
|
+
/**
|
|
304
|
+
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
305
|
+
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
306
|
+
* `true` (collections are always returned intact).
|
|
307
|
+
*/
|
|
308
|
+
get(key: any, keepScalar?: boolean): any
|
|
309
|
+
getIn(path: Iterable<any>, keepScalar?: boolean): any
|
|
310
|
+
/**
|
|
311
|
+
* Checks if the collection includes a value with the key `key`.
|
|
312
|
+
*/
|
|
313
|
+
has(key: any): boolean
|
|
314
|
+
hasIn(path: Iterable<any>): boolean
|
|
315
|
+
/**
|
|
316
|
+
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
317
|
+
* boolean to add/remove the item from the set.
|
|
318
|
+
*/
|
|
319
|
+
set(key: any, value: any): void
|
|
320
|
+
setIn(path: Iterable<any>, value: any): void
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export class YAMLMap extends Collection {
|
|
235
324
|
type?: Type.FLOW_MAP | Type.MAP
|
|
236
|
-
items: Array<Pair
|
|
325
|
+
items: Array<Pair>
|
|
237
326
|
hasAllNullValues(): boolean
|
|
238
327
|
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): object | Map<any, any>
|
|
328
|
+
toString(
|
|
329
|
+
ctx?: Schema.StringifyContext,
|
|
330
|
+
onComment?: () => void,
|
|
331
|
+
onChompKeep?: () => void
|
|
332
|
+
): string
|
|
239
333
|
}
|
|
240
334
|
|
|
241
|
-
export class YAMLSeq extends
|
|
335
|
+
export class YAMLSeq extends Collection {
|
|
242
336
|
type?: Type.FLOW_SEQ | Type.SEQ
|
|
243
337
|
delete(key: number | string | Scalar): boolean
|
|
244
338
|
get(key: number | string | Scalar, keepScalar?: boolean): any
|
|
@@ -246,80 +340,14 @@ export class YAMLSeq extends AST.Collection {
|
|
|
246
340
|
set(key: number | string | Scalar, value: any): void
|
|
247
341
|
hasAllNullValues(): boolean
|
|
248
342
|
toJSON(arg?: any, ctx?: AST.NodeToJsonContext): any[]
|
|
343
|
+
toString(
|
|
344
|
+
ctx?: Schema.StringifyContext,
|
|
345
|
+
onComment?: () => void,
|
|
346
|
+
onChompKeep?: () => void
|
|
347
|
+
): string
|
|
249
348
|
}
|
|
250
349
|
|
|
251
350
|
export namespace AST {
|
|
252
|
-
type AstNode = ScalarNode | CollectionNode | Alias
|
|
253
|
-
|
|
254
|
-
type ScalarNode =
|
|
255
|
-
| BlockFolded
|
|
256
|
-
| BlockLiteral
|
|
257
|
-
| PlainValue
|
|
258
|
-
| QuoteDouble
|
|
259
|
-
| QuoteSingle
|
|
260
|
-
|
|
261
|
-
type CollectionNode = FlowMap | BlockMap | FlowSeq | BlockSeq
|
|
262
|
-
|
|
263
|
-
class Node {
|
|
264
|
-
/** A comment on or immediately after this */
|
|
265
|
-
comment?: string | null
|
|
266
|
-
/** A comment before this */
|
|
267
|
-
commentBefore?: string | null
|
|
268
|
-
/** Only available when `keepCstNodes` is set to `true` */
|
|
269
|
-
cstNode?: CST.Node
|
|
270
|
-
/**
|
|
271
|
-
* The [start, end] range of characters of the source parsed
|
|
272
|
-
* into this node (undefined for pairs or if not parsed)
|
|
273
|
-
*/
|
|
274
|
-
range?: [number, number] | null
|
|
275
|
-
/** A blank line before this node and its commentBefore */
|
|
276
|
-
spaceBefore?: boolean
|
|
277
|
-
/** A fully qualified tag, if required */
|
|
278
|
-
tag?: string
|
|
279
|
-
/** A plain JS representation of this node */
|
|
280
|
-
toJSON(arg?: any): any
|
|
281
|
-
/** The type of this node */
|
|
282
|
-
type?: Type | Pair.Type
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
class Collection extends Node {
|
|
286
|
-
type?: Type.MAP | Type.FLOW_MAP | Type.SEQ | Type.FLOW_SEQ | Type.DOCUMENT
|
|
287
|
-
items: any[]
|
|
288
|
-
schema?: Schema
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
292
|
-
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
293
|
-
* that already exists in the map.
|
|
294
|
-
*/
|
|
295
|
-
add(value: any): void
|
|
296
|
-
addIn(path: Iterable<any>, value: any): void
|
|
297
|
-
/**
|
|
298
|
-
* Removes a value from the collection.
|
|
299
|
-
* @returns `true` if the item was found and removed.
|
|
300
|
-
*/
|
|
301
|
-
delete(key: any): boolean
|
|
302
|
-
deleteIn(path: Iterable<any>): boolean
|
|
303
|
-
/**
|
|
304
|
-
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
305
|
-
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
306
|
-
* `true` (collections are always returned intact).
|
|
307
|
-
*/
|
|
308
|
-
get(key: any, keepScalar?: boolean): any
|
|
309
|
-
getIn(path: Iterable<any>, keepScalar?: boolean): any
|
|
310
|
-
/**
|
|
311
|
-
* Checks if the collection includes a value with the key `key`.
|
|
312
|
-
*/
|
|
313
|
-
has(key: any): boolean
|
|
314
|
-
hasIn(path: Iterable<any>): boolean
|
|
315
|
-
/**
|
|
316
|
-
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
317
|
-
* boolean to add/remove the item from the set.
|
|
318
|
-
*/
|
|
319
|
-
set(key: any, value: any): void
|
|
320
|
-
setIn(path: Iterable<any>, value: any): void
|
|
321
|
-
}
|
|
322
|
-
|
|
323
351
|
interface NodeToJsonContext {
|
|
324
352
|
anchors?: any[]
|
|
325
353
|
doc: Document
|
|
@@ -355,20 +383,6 @@ export namespace AST {
|
|
|
355
383
|
cstNode?: CST.QuoteSingle
|
|
356
384
|
}
|
|
357
385
|
|
|
358
|
-
interface Alias extends Node {
|
|
359
|
-
type: Type.ALIAS
|
|
360
|
-
source: AstNode
|
|
361
|
-
cstNode?: CST.Alias
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
interface Merge extends Pair {
|
|
365
|
-
type: Pair.Type.MERGE_PAIR
|
|
366
|
-
/** Always Scalar('<<'), defined by the type specification */
|
|
367
|
-
key: PlainValue
|
|
368
|
-
/** Always YAMLSeq<Alias(Map)>, stringified as *A if length = 1 */
|
|
369
|
-
value: YAMLSeq
|
|
370
|
-
}
|
|
371
|
-
|
|
372
386
|
interface FlowMap extends YAMLMap {
|
|
373
387
|
type: Type.FLOW_MAP
|
|
374
388
|
cstNode?: CST.FlowMap
|
|
@@ -381,13 +395,13 @@ export namespace AST {
|
|
|
381
395
|
|
|
382
396
|
interface FlowSeq extends YAMLSeq {
|
|
383
397
|
type: Type.FLOW_SEQ
|
|
384
|
-
items: Array<
|
|
398
|
+
items: Array<Node>
|
|
385
399
|
cstNode?: CST.FlowSeq
|
|
386
400
|
}
|
|
387
401
|
|
|
388
402
|
interface BlockSeq extends YAMLSeq {
|
|
389
403
|
type: Type.SEQ
|
|
390
|
-
items: Array<
|
|
404
|
+
items: Array<Node | null>
|
|
391
405
|
cstNode?: CST.Seq
|
|
392
406
|
}
|
|
393
407
|
}
|
package/types.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
exports.binaryOptions = opt.binaryOptions
|
|
3
|
-
exports.boolOptions = opt.boolOptions
|
|
4
|
-
exports.intOptions = opt.intOptions
|
|
5
|
-
exports.nullOptions = opt.nullOptions
|
|
6
|
-
exports.strOptions = opt.strOptions
|
|
1
|
+
const types = require('./dist/types')
|
|
7
2
|
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
3
|
+
exports.binaryOptions = types.binaryOptions
|
|
4
|
+
exports.boolOptions = types.boolOptions
|
|
5
|
+
exports.intOptions = types.intOptions
|
|
6
|
+
exports.nullOptions = types.nullOptions
|
|
7
|
+
exports.strOptions = types.strOptions
|
|
8
|
+
|
|
9
|
+
exports.Schema = types.Schema
|
|
10
|
+
exports.Alias = types.Alias
|
|
11
|
+
exports.Collection = types.Collection
|
|
12
|
+
exports.Merge = types.Merge
|
|
13
|
+
exports.Node = types.Node
|
|
14
|
+
exports.Pair = types.Pair
|
|
15
|
+
exports.Scalar = types.Scalar
|
|
16
|
+
exports.YAMLMap = types.YAMLMap
|
|
17
|
+
exports.YAMLSeq = types.YAMLSeq
|
package/types.mjs
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const binaryOptions = opt.binaryOptions
|
|
3
|
-
export const boolOptions = opt.boolOptions
|
|
4
|
-
export const intOptions = opt.intOptions
|
|
5
|
-
export const nullOptions = opt.nullOptions
|
|
6
|
-
export const strOptions = opt.strOptions
|
|
1
|
+
import types from './dist/types.js'
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
export const
|
|
3
|
+
export const binaryOptions = types.binaryOptions
|
|
4
|
+
export const boolOptions = types.boolOptions
|
|
5
|
+
export const intOptions = types.intOptions
|
|
6
|
+
export const nullOptions = types.nullOptions
|
|
7
|
+
export const strOptions = types.strOptions
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
export const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
import scalar from './dist/schema/Scalar.js'
|
|
21
|
-
export const Scalar = scalar.Scalar
|
|
9
|
+
export const Schema = types.Schema
|
|
10
|
+
export const Alias = types.Alias
|
|
11
|
+
export const Collection = types.Collection
|
|
12
|
+
export const Merge = types.Merge
|
|
13
|
+
export const Node = types.Node
|
|
14
|
+
export const Pair = types.Pair
|
|
15
|
+
export const Scalar = types.Scalar
|
|
16
|
+
export const YAMLMap = types.YAMLMap
|
|
17
|
+
export const YAMLSeq = types.YAMLSeq
|
package/util.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
exports.parseMap = require('./dist/schema/parseMap').parseMap
|
|
3
|
-
exports.parseSeq = require('./dist/schema/parseSeq').parseSeq
|
|
1
|
+
const util = require('./dist/util')
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.Type = require('./dist/constants').Type
|
|
3
|
+
exports.findPair = util.findPair
|
|
4
|
+
exports.toJSON = util.toJSON
|
|
5
|
+
exports.parseMap = util.parseMap
|
|
6
|
+
exports.parseSeq = util.parseSeq
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
8
|
+
exports.stringifyNumber = util.stringifyNumber
|
|
9
|
+
exports.stringifyString = util.stringifyString
|
|
10
|
+
exports.Type = util.Type
|
|
11
|
+
|
|
12
|
+
exports.YAMLError = util.YAMLError
|
|
13
|
+
exports.YAMLReferenceError = util.YAMLReferenceError
|
|
14
|
+
exports.YAMLSemanticError = util.YAMLSemanticError
|
|
15
|
+
exports.YAMLSyntaxError = util.YAMLSyntaxError
|
|
16
|
+
exports.YAMLWarning = util.YAMLWarning
|
package/util.mjs
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
export const findPair = map.findPair
|
|
1
|
+
import util from './dist/util.js'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
export const
|
|
3
|
+
export const findPair = util.findPair
|
|
4
|
+
export const toJSON = util.toJSON
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
export const parseSeq =
|
|
6
|
+
export const parseMap = util.parseMap
|
|
7
|
+
export const parseSeq = util.parseSeq
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
export const
|
|
12
|
-
export const stringifyString = str.stringifyString
|
|
9
|
+
export const stringifyNumber = util.stringifyNumber
|
|
10
|
+
export const stringifyString = util.stringifyString
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
export const toJSON = toJsonPkg.toJSON
|
|
12
|
+
export const Type = util.Type
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
export const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const
|
|
22
|
-
export const YAMLReferenceError = err.YAMLReferenceError
|
|
23
|
-
export const YAMLSemanticError = err.YAMLSemanticError
|
|
24
|
-
export const YAMLSyntaxError = err.YAMLSyntaxError
|
|
25
|
-
export const YAMLWarning = err.YAMLWarning
|
|
14
|
+
export const YAMLError = util.YAMLError
|
|
15
|
+
export const YAMLReferenceError = util.YAMLReferenceError
|
|
16
|
+
export const YAMLSemanticError = util.YAMLSemanticError
|
|
17
|
+
export const YAMLSyntaxError = util.YAMLSyntaxError
|
|
18
|
+
export const YAMLWarning = util.YAMLWarning
|
package/browser/dist/Anchors.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import { Alias } from './schema/Alias';
|
|
5
|
-
import { YAMLMap } from './schema/Map';
|
|
6
|
-
import { Merge } from './schema/Merge';
|
|
7
|
-
import { Scalar } from './schema/Scalar';
|
|
8
|
-
import { YAMLSeq } from './schema/Seq';
|
|
9
|
-
export var Anchors = /*#__PURE__*/function () {
|
|
10
|
-
_createClass(Anchors, null, [{
|
|
11
|
-
key: "validAnchorNode",
|
|
12
|
-
value: function validAnchorNode(node) {
|
|
13
|
-
return node instanceof Scalar || node instanceof YAMLSeq || node instanceof YAMLMap;
|
|
14
|
-
}
|
|
15
|
-
}]);
|
|
16
|
-
|
|
17
|
-
function Anchors(prefix) {
|
|
18
|
-
_classCallCheck(this, Anchors);
|
|
19
|
-
|
|
20
|
-
_defineProperty(this, "map", {});
|
|
21
|
-
|
|
22
|
-
this.prefix = prefix;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
_createClass(Anchors, [{
|
|
26
|
-
key: "createAlias",
|
|
27
|
-
value: function createAlias(node, name) {
|
|
28
|
-
this.setAnchor(node, name);
|
|
29
|
-
return new Alias(node);
|
|
30
|
-
}
|
|
31
|
-
}, {
|
|
32
|
-
key: "createMergePair",
|
|
33
|
-
value: function createMergePair() {
|
|
34
|
-
var _this = this;
|
|
35
|
-
|
|
36
|
-
var merge = new Merge();
|
|
37
|
-
|
|
38
|
-
for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
39
|
-
sources[_key] = arguments[_key];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
merge.value.items = sources.map(function (s) {
|
|
43
|
-
if (s instanceof Alias) {
|
|
44
|
-
if (s.source instanceof YAMLMap) return s;
|
|
45
|
-
} else if (s instanceof YAMLMap) {
|
|
46
|
-
return _this.createAlias(s);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
throw new Error('Merge sources must be Map nodes or their Aliases');
|
|
50
|
-
});
|
|
51
|
-
return merge;
|
|
52
|
-
}
|
|
53
|
-
}, {
|
|
54
|
-
key: "getName",
|
|
55
|
-
value: function getName(node) {
|
|
56
|
-
var map = this.map;
|
|
57
|
-
return Object.keys(map).find(function (a) {
|
|
58
|
-
return map[a] === node;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: "getNode",
|
|
63
|
-
value: function getNode(name) {
|
|
64
|
-
return this.map[name];
|
|
65
|
-
}
|
|
66
|
-
}, {
|
|
67
|
-
key: "newName",
|
|
68
|
-
value: function newName(prefix) {
|
|
69
|
-
if (!prefix) prefix = this.prefix;
|
|
70
|
-
var names = Object.keys(this.map);
|
|
71
|
-
|
|
72
|
-
for (var i = 1; true; ++i) {
|
|
73
|
-
var name = "".concat(prefix).concat(i);
|
|
74
|
-
if (!names.includes(name)) return name;
|
|
75
|
-
}
|
|
76
|
-
} // During parsing, map & aliases contain CST nodes
|
|
77
|
-
|
|
78
|
-
}, {
|
|
79
|
-
key: "resolveNodes",
|
|
80
|
-
value: function resolveNodes() {
|
|
81
|
-
var map = this.map,
|
|
82
|
-
_cstAliases = this._cstAliases;
|
|
83
|
-
Object.keys(map).forEach(function (a) {
|
|
84
|
-
map[a] = map[a].resolved;
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
_cstAliases.forEach(function (a) {
|
|
88
|
-
a.source = a.source.resolved;
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
delete this._cstAliases;
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "setAnchor",
|
|
95
|
-
value: function setAnchor(node, name) {
|
|
96
|
-
if (node != null && !Anchors.validAnchorNode(node)) {
|
|
97
|
-
throw new Error('Anchors may only be set for Scalar, Seq and Map nodes');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (name && /[\x00-\x19\s,[\]{}]/.test(name)) {
|
|
101
|
-
throw new Error('Anchor names must not contain whitespace or control characters');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
var map = this.map;
|
|
105
|
-
var prev = node && Object.keys(map).find(function (a) {
|
|
106
|
-
return map[a] === node;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
if (prev) {
|
|
110
|
-
if (!name) {
|
|
111
|
-
return prev;
|
|
112
|
-
} else if (prev !== name) {
|
|
113
|
-
delete map[prev];
|
|
114
|
-
map[name] = node;
|
|
115
|
-
}
|
|
116
|
-
} else {
|
|
117
|
-
if (!name) {
|
|
118
|
-
if (!node) return null;
|
|
119
|
-
name = this.newName();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
map[name] = node;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return name;
|
|
126
|
-
}
|
|
127
|
-
}]);
|
|
128
|
-
|
|
129
|
-
return Anchors;
|
|
130
|
-
}();
|