yaml 2.1.0 → 2.1.2
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 +1 -1
- package/browser/dist/compose/compose-node.js +4 -2
- package/browser/dist/doc/createNode.js +1 -1
- package/browser/dist/schema/yaml-1.1/set.js +2 -1
- package/dist/compose/compose-node.d.ts +2 -1
- package/dist/compose/compose-node.js +4 -2
- package/dist/doc/createNode.js +1 -1
- package/dist/nodes/Alias.d.ts +1 -1
- package/dist/nodes/Node.d.ts +4 -2
- package/dist/nodes/YAMLMap.d.ts +2 -1
- package/dist/nodes/addPairToJSMap.d.ts +2 -1
- package/dist/schema/Schema.d.ts +3 -3
- package/dist/schema/yaml-1.1/set.js +2 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# YAML <a href="https://www.npmjs.com/package/yaml"><img align="right" src="https://badge.fury.io/js/yaml.svg" title="npm package" /></a>
|
|
2
2
|
|
|
3
|
-
`yaml` is a definitive library for [YAML](
|
|
3
|
+
`yaml` is a definitive library for [YAML](https://yaml.org/), the human friendly data serialization standard.
|
|
4
4
|
This library:
|
|
5
5
|
|
|
6
6
|
- Supports both YAML 1.1 and YAML 1.2 and all common data schemas,
|
|
@@ -54,7 +54,7 @@ function composeNode(ctx, token, props, onError) {
|
|
|
54
54
|
node.srcToken = token;
|
|
55
55
|
return node;
|
|
56
56
|
}
|
|
57
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
57
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
58
58
|
const token = {
|
|
59
59
|
type: 'scalar',
|
|
60
60
|
offset: emptyScalarPosition(offset, before, pos),
|
|
@@ -69,8 +69,10 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
69
69
|
}
|
|
70
70
|
if (spaceBefore)
|
|
71
71
|
node.spaceBefore = true;
|
|
72
|
-
if (comment)
|
|
72
|
+
if (comment) {
|
|
73
73
|
node.comment = comment;
|
|
74
|
+
node.range[2] = end;
|
|
75
|
+
}
|
|
74
76
|
return node;
|
|
75
77
|
}
|
|
76
78
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
|
@@ -26,7 +26,7 @@ function createNode(value, tagName, ctx) {
|
|
|
26
26
|
if (value instanceof String ||
|
|
27
27
|
value instanceof Number ||
|
|
28
28
|
value instanceof Boolean ||
|
|
29
|
-
(typeof BigInt
|
|
29
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
30
30
|
) {
|
|
31
31
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
32
32
|
value = value.valueOf();
|
|
@@ -15,6 +15,7 @@ interface Props {
|
|
|
15
15
|
comment: string;
|
|
16
16
|
anchor: SourceToken | null;
|
|
17
17
|
tag: SourceToken | null;
|
|
18
|
+
end: number;
|
|
18
19
|
}
|
|
19
20
|
declare const CN: {
|
|
20
21
|
composeNode: typeof composeNode;
|
|
@@ -22,5 +23,5 @@ declare const CN: {
|
|
|
22
23
|
};
|
|
23
24
|
export declare type ComposeNode = typeof CN;
|
|
24
25
|
export declare function composeNode(ctx: ComposeContext, token: Token, props: Props, onError: ComposeErrorHandler): ParsedNode;
|
|
25
|
-
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
|
|
26
|
+
export declare function composeEmptyNode(ctx: ComposeContext, offset: number, before: Token[] | undefined, pos: number | null, { spaceBefore, comment, anchor, tag, end }: Props, onError: ComposeErrorHandler): import("../index.js").Scalar.Parsed;
|
|
26
27
|
export {};
|
|
@@ -56,7 +56,7 @@ function composeNode(ctx, token, props, onError) {
|
|
|
56
56
|
node.srcToken = token;
|
|
57
57
|
return node;
|
|
58
58
|
}
|
|
59
|
-
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag }, onError) {
|
|
59
|
+
function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anchor, tag, end }, onError) {
|
|
60
60
|
const token = {
|
|
61
61
|
type: 'scalar',
|
|
62
62
|
offset: utilEmptyScalarPosition.emptyScalarPosition(offset, before, pos),
|
|
@@ -71,8 +71,10 @@ function composeEmptyNode(ctx, offset, before, pos, { spaceBefore, comment, anch
|
|
|
71
71
|
}
|
|
72
72
|
if (spaceBefore)
|
|
73
73
|
node.spaceBefore = true;
|
|
74
|
-
if (comment)
|
|
74
|
+
if (comment) {
|
|
75
75
|
node.comment = comment;
|
|
76
|
+
node.range[2] = end;
|
|
77
|
+
}
|
|
76
78
|
return node;
|
|
77
79
|
}
|
|
78
80
|
function composeAlias({ options }, { offset, source, end }, onError) {
|
package/dist/doc/createNode.js
CHANGED
|
@@ -28,7 +28,7 @@ function createNode(value, tagName, ctx) {
|
|
|
28
28
|
if (value instanceof String ||
|
|
29
29
|
value instanceof Number ||
|
|
30
30
|
value instanceof Boolean ||
|
|
31
|
-
(typeof BigInt
|
|
31
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
32
32
|
) {
|
|
33
33
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
34
34
|
value = value.valueOf();
|
package/dist/nodes/Alias.d.ts
CHANGED
|
@@ -23,6 +23,6 @@ export declare class Alias extends NodeBase {
|
|
|
23
23
|
* instance of the `source` anchor before this node.
|
|
24
24
|
*/
|
|
25
25
|
resolve(doc: Document): Scalar | YAMLMap | YAMLSeq | undefined;
|
|
26
|
-
toJSON(_arg?: unknown, ctx?: ToJSContext):
|
|
26
|
+
toJSON(_arg?: unknown, ctx?: ToJSContext): {} | null;
|
|
27
27
|
toString(ctx?: StringifyContext, _onComment?: () => void, _onChompKeep?: () => void): string;
|
|
28
28
|
}
|
package/dist/nodes/Node.d.ts
CHANGED
|
@@ -9,10 +9,12 @@ import type { YAMLSeq } from './YAMLSeq.js';
|
|
|
9
9
|
export declare type Node<T = unknown> = Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>;
|
|
10
10
|
/** Utility type mapper */
|
|
11
11
|
export declare type NodeType<T> = T extends string | number | bigint | boolean | null ? Scalar<T> : T extends Array<any> ? YAMLSeq<NodeType<T[number]>> : T extends {
|
|
12
|
-
[key: string
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
} ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : T extends {
|
|
14
|
+
[key: number]: any;
|
|
13
15
|
} ? YAMLMap<NodeType<keyof T>, NodeType<T[keyof T]>> : Node;
|
|
14
16
|
export declare type ParsedNode = Alias.Parsed | Scalar.Parsed | YAMLMap.Parsed | YAMLSeq.Parsed;
|
|
15
|
-
export declare type Range = [
|
|
17
|
+
export declare type Range = [number, number, number];
|
|
16
18
|
export declare const ALIAS: unique symbol;
|
|
17
19
|
export declare const DOC: unique symbol;
|
|
18
20
|
export declare const MAP: unique symbol;
|
package/dist/nodes/YAMLMap.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ParsedNode, Range } from './Node.js';
|
|
|
6
6
|
import { Pair } from './Pair.js';
|
|
7
7
|
import { Scalar } from './Scalar.js';
|
|
8
8
|
import type { ToJSContext } from './toJS.js';
|
|
9
|
+
export declare type MapLike = Map<unknown, unknown> | Set<unknown> | Record<string | number | symbol, unknown>;
|
|
9
10
|
export declare function findPair<K = unknown, V = unknown>(items: Iterable<Pair<K, V>>, key: unknown): Pair<K, V> | undefined;
|
|
10
11
|
export declare namespace YAMLMap {
|
|
11
12
|
interface Parsed<K extends ParsedNode = ParsedNode, V extends ParsedNode | null = ParsedNode | null> extends YAMLMap<K, V> {
|
|
@@ -39,7 +40,7 @@ export declare class YAMLMap<K = unknown, V = unknown> extends Collection {
|
|
|
39
40
|
* @param {Class} Type - If set, forces the returned collection type
|
|
40
41
|
* @returns Instance of Type, Map, or Object
|
|
41
42
|
*/
|
|
42
|
-
toJSON<T = unknown
|
|
43
|
+
toJSON<T extends MapLike = Map<unknown, unknown>>(_?: unknown, ctx?: ToJSContext, Type?: {
|
|
43
44
|
new (): T;
|
|
44
45
|
}): any;
|
|
45
46
|
toString(ctx?: StringifyContext, onComment?: () => void, onChompKeep?: () => void): string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Pair } from './Pair.js';
|
|
2
2
|
import { ToJSContext } from './toJS.js';
|
|
3
|
-
|
|
3
|
+
import type { MapLike } from './YAMLMap.js';
|
|
4
|
+
export declare function addPairToJSMap(ctx: ToJSContext | undefined, map: MapLike, { key, value }: Pair): MapLike;
|
package/dist/schema/Schema.d.ts
CHANGED
|
@@ -10,9 +10,9 @@ export declare class Schema {
|
|
|
10
10
|
sortMapEntries: ((a: Pair, b: Pair) => number) | null;
|
|
11
11
|
tags: Array<CollectionTag | ScalarTag>;
|
|
12
12
|
toStringOptions: Readonly<ToStringOptions> | null;
|
|
13
|
-
[MAP]: CollectionTag;
|
|
14
|
-
[SCALAR]: ScalarTag;
|
|
15
|
-
[SEQ]: CollectionTag;
|
|
13
|
+
readonly [MAP]: CollectionTag;
|
|
14
|
+
readonly [SCALAR]: ScalarTag;
|
|
15
|
+
readonly [SEQ]: CollectionTag;
|
|
16
16
|
constructor({ compat, customTags, merge, resolveKnownTags, schema, sortMapEntries, toStringDefaults }: SchemaOptions);
|
|
17
17
|
clone(): Schema;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"@rollup/plugin-babel": "^5.2.3",
|
|
73
73
|
"@rollup/plugin-replace": "^4.0.0",
|
|
74
74
|
"@rollup/plugin-typescript": "^8.1.1",
|
|
75
|
-
"@types/jest": "^
|
|
75
|
+
"@types/jest": "^28.1.8",
|
|
76
76
|
"@types/node": "^12.20.47",
|
|
77
77
|
"@typescript-eslint/eslint-plugin": "^5.3.1",
|
|
78
78
|
"@typescript-eslint/parser": "^5.3.1",
|
|
79
|
-
"babel-jest": "^
|
|
79
|
+
"babel-jest": "^29.0.1",
|
|
80
80
|
"cross-env": "^7.0.3",
|
|
81
81
|
"eslint": "^8.2.0",
|
|
82
82
|
"eslint-config-prettier": "^8.1.0",
|
|
83
83
|
"fast-check": "^2.12.0",
|
|
84
|
-
"jest": "^
|
|
84
|
+
"jest": "^29.0.1",
|
|
85
85
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
86
86
|
"prettier": "^2.2.1",
|
|
87
87
|
"rollup": "^2.38.2",
|