@pnpm/yaml.document-sync 1000.0.0-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/LICENSE +22 -0
- package/README.md +169 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/lib/patchDocument.d.ts +23 -0
- package/lib/patchDocument.js +182 -0
- package/lib/patchDocument.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2026 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# @pnpm/yaml.document-sync
|
|
2
|
+
|
|
3
|
+
> Update a YAML document to match the contents of an in-memory object.
|
|
4
|
+
|
|
5
|
+
<!--@shields('npm')-->
|
|
6
|
+
[](https://www.npmjs.com/package/@pnpm/yaml.document-sync)
|
|
7
|
+
<!--/@-->
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add @pnpm/yaml.document-sync
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Given a "_source_" document such as:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
foo:
|
|
21
|
+
bar:
|
|
22
|
+
# 25 is better than 24
|
|
23
|
+
baz: 25
|
|
24
|
+
|
|
25
|
+
qux:
|
|
26
|
+
# He was number 1
|
|
27
|
+
- 1
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
And a "_target_" object in-memory:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import fs from 'node:fs'
|
|
34
|
+
import { patchDocument } from '@pnpm/yaml.document-sync'
|
|
35
|
+
import yaml from 'yaml'
|
|
36
|
+
|
|
37
|
+
const source = await fs.promises.readFile('source.yaml', 'utf8')
|
|
38
|
+
const document = yaml.parseDocument(source)
|
|
39
|
+
|
|
40
|
+
const target = {
|
|
41
|
+
foo: { bar: { baz: 25 } },
|
|
42
|
+
qux: [1, 2, 3]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
patchDocument(document, target)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The `patchDocument` function will mutate `document` to match the `target`'s contents, retaining comments along the way. In the example above, the final rendered document will be:
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
foo:
|
|
52
|
+
bar:
|
|
53
|
+
# 25 is better than 24
|
|
54
|
+
baz: 25
|
|
55
|
+
|
|
56
|
+
qux:
|
|
57
|
+
# He was number 1
|
|
58
|
+
- 1
|
|
59
|
+
- 2
|
|
60
|
+
- 3
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Purpose
|
|
64
|
+
|
|
65
|
+
This package is useful when your codebase:
|
|
66
|
+
|
|
67
|
+
1. Uses the [yaml](https://www.npmjs.com/package/yaml) library.
|
|
68
|
+
2. Calls `.toJSON()` on the parse result and performs changes to it.
|
|
69
|
+
3. Needs to "sync" those changes back to the source document.
|
|
70
|
+
|
|
71
|
+
Instead of this package, consider performing mutations directly on the `yaml.Document` returned from `yaml.parseDocument()` instead. Directly modifying will be faster and more accurate. This package exists as a workaround for codebases that make changes to a JSON object instead and need to reconcile changes back into the source `yaml.Document`.
|
|
72
|
+
|
|
73
|
+
## Caveats
|
|
74
|
+
|
|
75
|
+
There are several cases where comment preservation is inherently ambiguous. If the caveats outlined below are problematic, consider modifying the source `yaml.Document` before running the patch function in this package.
|
|
76
|
+
|
|
77
|
+
### Key Renames
|
|
78
|
+
|
|
79
|
+
For example, renames of a key are ambiguous. Given:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
- foo:
|
|
83
|
+
# Test
|
|
84
|
+
bar: 1
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
And a target object to match:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"baz": {
|
|
92
|
+
"bar": 1
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The comment on `bar` won't be retained.
|
|
98
|
+
|
|
99
|
+
### List Reconciliation
|
|
100
|
+
|
|
101
|
+
For simple lists (e.g. lists with only primitives), items will be uniquely matched using their contents. However, updates to complex lists are inherently ambiguous.
|
|
102
|
+
|
|
103
|
+
For example, given a source list with objects as elements:
|
|
104
|
+
|
|
105
|
+
```yaml
|
|
106
|
+
- foo: 1
|
|
107
|
+
# Comment
|
|
108
|
+
- bar: 2
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
And a target:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
[
|
|
115
|
+
{ "foo": 1 },
|
|
116
|
+
{ "baz": 3 },
|
|
117
|
+
{ "bar": 2 }
|
|
118
|
+
]
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The result will erase the comment:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
- foo: 1
|
|
125
|
+
- baz: 3
|
|
126
|
+
- bar: 2
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
It's not trivial to detect that the object with `bar` as a field moved down. Detecting this case would require a diffing algorithm, which would be best effort anyway.
|
|
130
|
+
|
|
131
|
+
Virtual DOM libraries such as React have the same problem. In React, list elements need to specify a `key` prop to uniquely identify each item. This library may take a similar approach in the future if needed. This is not a problem for primitive lists since their values can be compared using simple equality checks.
|
|
132
|
+
|
|
133
|
+
### Aliases
|
|
134
|
+
|
|
135
|
+
Given:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
foo: &config
|
|
139
|
+
- 1
|
|
140
|
+
- 2
|
|
141
|
+
|
|
142
|
+
bar: *config
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
And a target object:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"foo": [1, 2],
|
|
150
|
+
"bar": [1, 2, 3]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For correctness, the YAML alias needs to be removed.
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
foo: &config
|
|
158
|
+
- 1
|
|
159
|
+
- 2
|
|
160
|
+
|
|
161
|
+
bar:
|
|
162
|
+
- 1
|
|
163
|
+
- 2
|
|
164
|
+
- 3
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { patchDocument } from './patchDocument.js';
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import yaml from 'yaml';
|
|
2
|
+
export interface PatchDocumentOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Updating aliases is inherently ambiguous since they're not a concept in
|
|
5
|
+
* JSON. The default is to unwrap and remove aliases since that's the most
|
|
6
|
+
* correct behavior.
|
|
7
|
+
*
|
|
8
|
+
* Aliases can be configured to "follow", which updates the anchor node.
|
|
9
|
+
* However, this can result in surprising behavior when values in the target
|
|
10
|
+
* JSON between the anchor and the alias don't match.
|
|
11
|
+
*
|
|
12
|
+
* @default 'unwrap'
|
|
13
|
+
*/
|
|
14
|
+
readonly aliases?: 'unwrap' | 'follow';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Recursively update a YAML document (in-place) to match the contents of a
|
|
18
|
+
* target value.
|
|
19
|
+
*
|
|
20
|
+
* Comments are preserved on a best-effort basis. There are several cases where
|
|
21
|
+
* ambiguity arises. See this package's README.md for details.
|
|
22
|
+
*/
|
|
23
|
+
export declare function patchDocument(document: yaml.Document, target: unknown, options?: PatchDocumentOptions): void;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import yaml from 'yaml';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively update a YAML document (in-place) to match the contents of a
|
|
4
|
+
* target value.
|
|
5
|
+
*
|
|
6
|
+
* Comments are preserved on a best-effort basis. There are several cases where
|
|
7
|
+
* ambiguity arises. See this package's README.md for details.
|
|
8
|
+
*/
|
|
9
|
+
export function patchDocument(document, target, options) {
|
|
10
|
+
// Documents with errors can't be stringified and have unpredictable ASTs.
|
|
11
|
+
if (document.errors.length > 0) {
|
|
12
|
+
throw new Error('Document with errors cannot be patched');
|
|
13
|
+
}
|
|
14
|
+
document.contents = patchNode(document.contents, target, {
|
|
15
|
+
document,
|
|
16
|
+
aliases: options?.aliases ?? 'unwrap',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function patchNode(node, target, ctx) {
|
|
20
|
+
if (node == null) {
|
|
21
|
+
return ctx.document.createNode(target);
|
|
22
|
+
}
|
|
23
|
+
if (target == null) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (yaml.isAlias(node)) {
|
|
27
|
+
return patchAlias(node, target, ctx);
|
|
28
|
+
}
|
|
29
|
+
if (yaml.isScalar(node)) {
|
|
30
|
+
return patchScalar(node, target, ctx);
|
|
31
|
+
}
|
|
32
|
+
if (yaml.isMap(node)) {
|
|
33
|
+
return patchMap(node, target, ctx);
|
|
34
|
+
}
|
|
35
|
+
if (yaml.isSeq(node)) {
|
|
36
|
+
return patchSeq(node, target, ctx);
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
+
const _never = node;
|
|
40
|
+
throw new Error('Unrecognized yaml node: ' + String(node));
|
|
41
|
+
}
|
|
42
|
+
function patchAlias(alias, target, ctx) {
|
|
43
|
+
const resolved = alias.resolve(ctx.document);
|
|
44
|
+
// This should only happen if the document was corrupted after it was parsed.
|
|
45
|
+
// Unresolved aliases should fail at the parsing stage.
|
|
46
|
+
if (resolved == null) {
|
|
47
|
+
throw new Error('Failed to resolve yaml alias: ' + alias.source);
|
|
48
|
+
}
|
|
49
|
+
switch (ctx.aliases) {
|
|
50
|
+
case 'follow': {
|
|
51
|
+
// This can result in surprising behavior since the anchor node will end up
|
|
52
|
+
// with the contents of the last encountered alias. The default is to
|
|
53
|
+
// "unwrap" for this reason.
|
|
54
|
+
patchNode(resolved, target, ctx);
|
|
55
|
+
return alias;
|
|
56
|
+
}
|
|
57
|
+
case 'unwrap': {
|
|
58
|
+
const copy = resolved.clone();
|
|
59
|
+
copy.anchor = undefined;
|
|
60
|
+
patchNode(copy, target, ctx);
|
|
61
|
+
return copy;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function patchScalar(scalar, target, ctx) {
|
|
66
|
+
if (scalar.value === target) {
|
|
67
|
+
return scalar;
|
|
68
|
+
}
|
|
69
|
+
if (typeof target === 'boolean' || typeof target === 'string' || typeof target === 'number') {
|
|
70
|
+
scalar.value = target;
|
|
71
|
+
return scalar;
|
|
72
|
+
}
|
|
73
|
+
return ctx.document.createNode(target);
|
|
74
|
+
}
|
|
75
|
+
function patchMap(map, target, ctx) {
|
|
76
|
+
if (!isRecord(target)) {
|
|
77
|
+
return ctx.document.createNode(target);
|
|
78
|
+
}
|
|
79
|
+
// Intentionally return null on empty maps as well. This recursively clears
|
|
80
|
+
// empty maps in the final document.
|
|
81
|
+
if (target == null || Object.keys(target).length === 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const mapKeyToExistingPair = new Map();
|
|
85
|
+
for (const pair of map.items) {
|
|
86
|
+
// We can't update non-node types. Pairs should only contain values that are
|
|
87
|
+
// non-nodes if the yaml document was modified manually after parsing.
|
|
88
|
+
if (!yaml.isScalar(pair.key) || typeof pair.key.value !== 'string') {
|
|
89
|
+
throw new Error('Encountered unexpected non-node value: ' + String(pair.key));
|
|
90
|
+
}
|
|
91
|
+
mapKeyToExistingPair.set(pair.key.value, pair);
|
|
92
|
+
}
|
|
93
|
+
map.items = Object.entries(target)
|
|
94
|
+
.map(([key, value]) => {
|
|
95
|
+
const existingPair = mapKeyToExistingPair.get(key);
|
|
96
|
+
if (existingPair == null) {
|
|
97
|
+
return ctx.document.createPair(key, value);
|
|
98
|
+
}
|
|
99
|
+
if (!yaml.isNode(existingPair.value)) {
|
|
100
|
+
throw new Error('Encountered unexpected non-node value: ' + String(existingPair.value));
|
|
101
|
+
}
|
|
102
|
+
existingPair.value = patchNode(existingPair.value, value, ctx);
|
|
103
|
+
return existingPair;
|
|
104
|
+
})
|
|
105
|
+
.filter((pair) => pair.value != null);
|
|
106
|
+
return map;
|
|
107
|
+
}
|
|
108
|
+
function patchSeq(seq, target, ctx) {
|
|
109
|
+
if (!Array.isArray(target)) {
|
|
110
|
+
return ctx.document.createNode(target);
|
|
111
|
+
}
|
|
112
|
+
// Primitive lists can benefit from a more correct reconciliation process
|
|
113
|
+
// since it's possible to uniquely identify items.
|
|
114
|
+
//
|
|
115
|
+
// Reconciling lists with objects is more complex since we don't know which
|
|
116
|
+
// objects in the source list semantically correspond to the same object in
|
|
117
|
+
// the target list. This is the same problem that virtual DOM frameworks (e.g.
|
|
118
|
+
// React) have. We have to go by indexes in the complex case. If solving this
|
|
119
|
+
// problem becomes important in the future, it may be worth making callers to
|
|
120
|
+
// pass in a getKeyForNode() function.
|
|
121
|
+
return isPrimitiveList(target)
|
|
122
|
+
? patchSeqPrimitive(seq, target)
|
|
123
|
+
: patchSeqComplex(seq, target, ctx);
|
|
124
|
+
}
|
|
125
|
+
function patchSeqPrimitive(seq, target) {
|
|
126
|
+
// Keep track of existing nodes to reuse when building up the final list from
|
|
127
|
+
// the target list. These nodes will have comments attached to them, so it's
|
|
128
|
+
// important to reuse them when possible.
|
|
129
|
+
const valueToNodesMap = new Map();
|
|
130
|
+
for (const item of seq.items) {
|
|
131
|
+
if (item != null && !yaml.isNode(item)) {
|
|
132
|
+
throw new Error('Encountered unexpected non-node value: ' + String(item));
|
|
133
|
+
}
|
|
134
|
+
// We know all items in the target list are scalars. If there's a non-scalar
|
|
135
|
+
// in the source list, it needs to be removed. Skip over this item so it's
|
|
136
|
+
// not added to the final list.
|
|
137
|
+
if (!yaml.isScalar(item) || !isPrimitive(item.value) || item.value == null) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
const nodeList = valueToNodesMap.get(item.value) ?? [];
|
|
141
|
+
nodeList.push(item);
|
|
142
|
+
valueToNodesMap.set(item.value, nodeList);
|
|
143
|
+
}
|
|
144
|
+
seq.items = target.filter(item => item != null).map((item) => {
|
|
145
|
+
const existingNodesList = valueToNodesMap.get(item);
|
|
146
|
+
const firstExistingItem = existingNodesList?.shift();
|
|
147
|
+
// If the list is now empty as a result of removing the first item, clean up
|
|
148
|
+
// the map.
|
|
149
|
+
if (existingNodesList?.length === 0) {
|
|
150
|
+
valueToNodesMap.delete(item);
|
|
151
|
+
}
|
|
152
|
+
return firstExistingItem ?? new yaml.Scalar(item);
|
|
153
|
+
});
|
|
154
|
+
return seq;
|
|
155
|
+
}
|
|
156
|
+
function patchSeqComplex(seq, target, ctx) {
|
|
157
|
+
const nextItems = [];
|
|
158
|
+
for (let i = 0; i < Math.max(seq.items.length, target.length); i++) {
|
|
159
|
+
const existingItem = seq.items[i];
|
|
160
|
+
const targetItem = target[i];
|
|
161
|
+
if (existingItem != null && !yaml.isNode(existingItem)) {
|
|
162
|
+
throw new Error('Encountered unexpected non-node value: ' + String(existingItem));
|
|
163
|
+
}
|
|
164
|
+
const nextItem = patchNode(existingItem, targetItem, ctx);
|
|
165
|
+
if (nextItem == null) {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
nextItems.push(nextItem);
|
|
169
|
+
}
|
|
170
|
+
seq.items = nextItems;
|
|
171
|
+
return seq;
|
|
172
|
+
}
|
|
173
|
+
function isRecord(value) {
|
|
174
|
+
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
175
|
+
}
|
|
176
|
+
function isPrimitiveList(arr) {
|
|
177
|
+
return arr.every(isPrimitive);
|
|
178
|
+
}
|
|
179
|
+
function isPrimitive(value) {
|
|
180
|
+
return value == null || typeof value === 'boolean' || typeof value === 'string' || typeof value === 'number';
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=patchDocument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patchDocument.js","sourceRoot":"","sources":["../src/patchDocument.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CA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1
|
+
{
|
|
2
|
+
"name": "@pnpm/yaml.document-sync",
|
|
3
|
+
"version": "1000.0.0-0",
|
|
4
|
+
"description": "Update a YAML document to match the contents of an in-memory object.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm11",
|
|
8
|
+
"patch",
|
|
9
|
+
"yaml"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"funding": "https://opencollective.com/pnpm",
|
|
13
|
+
"repository": "https://github.com/pnpm/pnpm/tree/main/yaml/document-sync",
|
|
14
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/yaml/document-sync#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "lib/index.js",
|
|
20
|
+
"types": "lib/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"lib",
|
|
26
|
+
"!*.map"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"yaml": "^2.8.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@pnpm/yaml.document-sync": "1000.0.0-0"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20.19"
|
|
36
|
+
},
|
|
37
|
+
"jest": {
|
|
38
|
+
"preset": "@pnpm/jest-config"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
42
|
+
"compile": "tsc --build && pnpm run lint --fix",
|
|
43
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
44
|
+
"_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
|
|
45
|
+
}
|
|
46
|
+
}
|