yaml 2.0.0-10 → 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.
Files changed (112) hide show
  1. package/browser/dist/compose/compose-doc.js +1 -2
  2. package/browser/dist/compose/compose-node.js +1 -10
  3. package/browser/dist/compose/compose-scalar.js +10 -17
  4. package/browser/dist/compose/composer.js +2 -3
  5. package/browser/dist/compose/resolve-block-map.js +5 -22
  6. package/browser/dist/compose/resolve-block-scalar.js +2 -2
  7. package/browser/dist/compose/resolve-block-seq.js +1 -6
  8. package/browser/dist/compose/resolve-end.js +2 -2
  9. package/browser/dist/compose/resolve-flow-collection.js +8 -24
  10. package/browser/dist/compose/resolve-flow-scalar.js +7 -19
  11. package/browser/dist/compose/resolve-props.js +7 -32
  12. package/browser/dist/doc/Document.js +12 -58
  13. package/browser/dist/doc/createNode.js +5 -11
  14. package/browser/dist/doc/directives.js +0 -5
  15. package/browser/dist/nodes/Collection.js +15 -28
  16. package/browser/dist/nodes/Node.js +0 -7
  17. package/browser/dist/nodes/Pair.js +1 -9
  18. package/browser/dist/nodes/YAMLMap.js +1 -1
  19. package/browser/dist/nodes/YAMLSeq.js +1 -1
  20. package/browser/dist/nodes/addPairToJSMap.js +3 -4
  21. package/browser/dist/options.js +0 -2
  22. package/browser/dist/parse/cst-scalar.js +6 -2
  23. package/browser/dist/parse/lexer.js +31 -67
  24. package/browser/dist/parse/parser.js +55 -62
  25. package/browser/dist/public-api.js +4 -2
  26. package/browser/dist/schema/Schema.js +3 -14
  27. package/browser/dist/schema/core/float.js +1 -4
  28. package/browser/dist/schema/tags.js +13 -17
  29. package/browser/dist/schema/yaml-1.1/float.js +1 -4
  30. package/browser/dist/stringify/addComment.js +11 -0
  31. package/browser/dist/stringify/stringify.js +17 -47
  32. package/browser/dist/stringify/stringifyCollection.js +72 -116
  33. package/browser/dist/stringify/stringifyDocument.js +9 -16
  34. package/browser/dist/stringify/stringifyPair.js +20 -29
  35. package/browser/dist/stringify/stringifyString.js +41 -39
  36. package/browser/dist/util.js +0 -3
  37. package/dist/compose/compose-doc.js +1 -2
  38. package/dist/compose/compose-node.d.ts +0 -1
  39. package/dist/compose/compose-node.js +1 -10
  40. package/dist/compose/compose-scalar.js +9 -16
  41. package/dist/compose/composer.js +2 -3
  42. package/dist/compose/resolve-block-map.d.ts +1 -2
  43. package/dist/compose/resolve-block-map.js +5 -22
  44. package/dist/compose/resolve-block-scalar.js +2 -2
  45. package/dist/compose/resolve-block-seq.js +1 -6
  46. package/dist/compose/resolve-end.js +2 -2
  47. package/dist/compose/resolve-flow-collection.js +8 -24
  48. package/dist/compose/resolve-flow-scalar.js +7 -19
  49. package/dist/compose/resolve-props.d.ts +4 -3
  50. package/dist/compose/resolve-props.js +7 -32
  51. package/dist/doc/Document.d.ts +5 -16
  52. package/dist/doc/Document.js +11 -57
  53. package/dist/doc/createNode.d.ts +1 -2
  54. package/dist/doc/createNode.js +4 -10
  55. package/dist/doc/directives.d.ts +0 -1
  56. package/dist/doc/directives.js +0 -5
  57. package/dist/errors.d.ts +1 -1
  58. package/dist/index.d.ts +2 -2
  59. package/dist/nodes/Alias.d.ts +3 -7
  60. package/dist/nodes/Collection.d.ts +4 -10
  61. package/dist/nodes/Collection.js +14 -27
  62. package/dist/nodes/Node.d.ts +3 -10
  63. package/dist/nodes/Node.js +0 -7
  64. package/dist/nodes/Pair.d.ts +2 -7
  65. package/dist/nodes/Pair.js +0 -8
  66. package/dist/nodes/Scalar.d.ts +0 -2
  67. package/dist/nodes/YAMLMap.d.ts +0 -2
  68. package/dist/nodes/YAMLMap.js +1 -1
  69. package/dist/nodes/YAMLSeq.d.ts +0 -2
  70. package/dist/nodes/YAMLSeq.js +1 -1
  71. package/dist/nodes/addPairToJSMap.js +2 -3
  72. package/dist/options.d.ts +6 -81
  73. package/dist/options.js +0 -2
  74. package/dist/parse/cst-scalar.d.ts +0 -6
  75. package/dist/parse/cst-scalar.js +6 -2
  76. package/dist/parse/lexer.d.ts +1 -3
  77. package/dist/parse/lexer.js +31 -67
  78. package/dist/parse/parser.d.ts +0 -1
  79. package/dist/parse/parser.js +55 -62
  80. package/dist/public-api.js +4 -2
  81. package/dist/schema/Schema.d.ts +4 -6
  82. package/dist/schema/Schema.js +2 -13
  83. package/dist/schema/core/float.js +1 -4
  84. package/dist/schema/tags.d.ts +2 -1
  85. package/dist/schema/tags.js +13 -17
  86. package/dist/schema/yaml-1.1/float.js +1 -4
  87. package/dist/stringify/addComment.d.ts +2 -0
  88. package/dist/stringify/addComment.js +13 -0
  89. package/dist/stringify/stringify.d.ts +3 -5
  90. package/dist/stringify/stringify.js +17 -47
  91. package/dist/stringify/stringifyCollection.d.ts +7 -3
  92. package/dist/stringify/stringifyCollection.js +72 -116
  93. package/dist/stringify/stringifyDocument.js +9 -16
  94. package/dist/stringify/stringifyPair.js +20 -29
  95. package/dist/stringify/stringifyString.js +41 -39
  96. package/dist/test-events.d.ts +1 -1
  97. package/dist/test-events.js +2 -4
  98. package/dist/util.d.ts +0 -3
  99. package/dist/util.js +0 -6
  100. package/package.json +12 -14
  101. package/browser/dist/compose/util-flow-indent-check.js +0 -15
  102. package/browser/dist/compose/util-map-includes.js +0 -17
  103. package/browser/dist/node_modules/tslib/tslib.es6.js +0 -164
  104. package/browser/dist/stringify/stringifyComment.js +0 -18
  105. package/dist/compose/util-flow-indent-check.d.ts +0 -3
  106. package/dist/compose/util-flow-indent-check.js +0 -17
  107. package/dist/compose/util-map-includes.d.ts +0 -4
  108. package/dist/compose/util-map-includes.js +0 -19
  109. package/dist/node_modules/tslib/tslib.es6.js +0 -76
  110. package/dist/stringify/stringifyComment.d.ts +0 -10
  111. package/dist/stringify/stringifyComment.js +0 -22
  112. package/util.d.ts +0 -3
@@ -2,11 +2,11 @@
2
2
 
3
3
  var Node = require('../nodes/Node.js');
4
4
  var Scalar = require('../nodes/Scalar.js');
5
+ var addComment = require('./addComment.js');
5
6
  var stringify = require('./stringify.js');
6
- var stringifyComment = require('./stringifyComment.js');
7
7
 
8
8
  function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
9
- const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
9
+ const { allNullValues, doc, indent, indentStep, options: { indentSeq, simpleKeys } } = ctx;
10
10
  let keyComment = (Node.isNode(key) && key.comment) || null;
11
11
  if (simpleKeys) {
12
12
  if (keyComment) {
@@ -45,34 +45,25 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
45
45
  }
46
46
  }
47
47
  else if ((allNullValues && !simpleKeys) || (value == null && explicitKey)) {
48
- str = `? ${str}`;
49
- if (keyComment && !keyCommentDone) {
50
- str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
51
- }
52
- else if (chompKeep && onChompKeep)
48
+ if (keyCommentDone)
49
+ keyComment = null;
50
+ if (chompKeep && !keyComment && onChompKeep)
53
51
  onChompKeep();
54
- return str;
52
+ return addComment.addComment(`? ${str}`, ctx.indent, keyComment);
55
53
  }
56
54
  if (keyCommentDone)
57
55
  keyComment = null;
58
- if (explicitKey) {
59
- if (keyComment)
60
- str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
61
- str = `? ${str}\n${indent}:`;
62
- }
63
- else {
64
- str = `${str}:`;
65
- if (keyComment)
66
- str += stringifyComment.lineComment(str, ctx.indent, commentString(keyComment));
67
- }
56
+ str = explicitKey
57
+ ? `? ${addComment.addComment(str, ctx.indent, keyComment)}\n${indent}:`
58
+ : addComment.addComment(`${str}:`, ctx.indent, keyComment);
68
59
  let vcb = '';
69
60
  let valueComment = null;
70
61
  if (Node.isNode(value)) {
71
62
  if (value.spaceBefore)
72
63
  vcb = '\n';
73
64
  if (value.commentBefore) {
74
- const cs = commentString(value.commentBefore);
75
- vcb += `\n${stringifyComment.indentComment(cs, ctx.indent)}`;
65
+ const cs = value.commentBefore.replace(/^/gm, `${ctx.indent}#`);
66
+ vcb += `\n${cs}`;
76
67
  }
77
68
  valueComment = value.comment;
78
69
  }
@@ -98,27 +89,27 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
98
89
  const valueStr = stringify.stringify(value, ctx, () => (valueCommentDone = true), () => (chompKeep = true));
99
90
  let ws = ' ';
100
91
  if (vcb || keyComment) {
101
- ws = valueStr === '' && !ctx.inFlow ? vcb : `${vcb}\n${ctx.indent}`;
92
+ ws = `${vcb}\n${ctx.indent}`;
102
93
  }
103
94
  else if (!explicitKey && Node.isCollection(value)) {
104
95
  const flow = valueStr[0] === '[' || valueStr[0] === '{';
105
96
  if (!flow || valueStr.includes('\n'))
106
97
  ws = `\n${ctx.indent}`;
107
98
  }
108
- else if (valueStr === '' || valueStr[0] === '\n')
99
+ else if (valueStr[0] === '\n')
109
100
  ws = '';
110
- str += ws + valueStr;
111
101
  if (ctx.inFlow) {
112
102
  if (valueCommentDone && onComment)
113
103
  onComment();
104
+ return str + ws + valueStr;
114
105
  }
115
- else if (valueComment && !valueCommentDone) {
116
- str += stringifyComment.lineComment(str, ctx.indent, commentString(valueComment));
117
- }
118
- else if (chompKeep && onChompKeep) {
119
- onChompKeep();
106
+ else {
107
+ if (valueCommentDone)
108
+ valueComment = null;
109
+ if (chompKeep && !valueComment && onChompKeep)
110
+ onChompKeep();
111
+ return addComment.addComment(str + ws + valueStr, ctx.indent, valueComment);
120
112
  }
121
- return str;
122
113
  }
123
114
 
124
115
  exports.stringifyPair = stringifyPair;
@@ -120,50 +120,34 @@ function doubleQuotedString(value, ctx) {
120
120
  : foldFlowLines.foldFlowLines(str, indent, foldFlowLines.FOLD_QUOTED, getFoldOptions(ctx));
121
121
  }
122
122
  function singleQuotedString(value, ctx) {
123
- if (ctx.options.singleQuote === false ||
124
- (ctx.implicitKey && value.includes('\n')) ||
125
- /[ \t]\n|\n[ \t]/.test(value) // single quoted string can't have leading or trailing whitespace around newline
126
- )
127
- return doubleQuotedString(value, ctx);
123
+ if (ctx.implicitKey) {
124
+ if (/\n/.test(value))
125
+ return doubleQuotedString(value, ctx);
126
+ }
127
+ else {
128
+ // single quoted string can't have leading or trailing whitespace around newline
129
+ if (/[ \t]\n|\n[ \t]/.test(value))
130
+ return doubleQuotedString(value, ctx);
131
+ }
128
132
  const indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : '');
129
133
  const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'";
130
134
  return ctx.implicitKey
131
135
  ? res
132
136
  : foldFlowLines.foldFlowLines(res, indent, foldFlowLines.FOLD_FLOW, getFoldOptions(ctx));
133
137
  }
134
- function quotedString(value, ctx) {
135
- const { singleQuote } = ctx.options;
136
- let qs;
137
- if (singleQuote === false)
138
- qs = doubleQuotedString;
139
- else {
140
- const hasDouble = value.includes('"');
141
- const hasSingle = value.includes("'");
142
- if (hasDouble && !hasSingle)
143
- qs = singleQuotedString;
144
- else if (hasSingle && !hasDouble)
145
- qs = doubleQuotedString;
146
- else
147
- qs = singleQuote ? singleQuotedString : doubleQuotedString;
148
- }
149
- return qs(value, ctx);
150
- }
151
138
  function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
152
- const { blockQuote, commentString, lineWidth } = ctx.options;
153
139
  // 1. Block can't end in whitespace unless the last line is non-empty.
154
140
  // 2. Strings consisting of only whitespace are best rendered explicitly.
155
- if (!blockQuote || /\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
156
- return quotedString(value, ctx);
141
+ if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) {
142
+ return doubleQuotedString(value, ctx);
157
143
  }
158
144
  const indent = ctx.indent ||
159
145
  (ctx.forceBlockIndent || containsDocumentMarker(value) ? ' ' : '');
160
- const literal = blockQuote === 'literal'
161
- ? true
162
- : blockQuote === 'folded' || type === Scalar.Scalar.BLOCK_FOLDED
163
- ? false
164
- : type === Scalar.Scalar.BLOCK_LITERAL
165
- ? true
166
- : !lineLengthOverLimit(value, lineWidth, indent.length);
146
+ const literal = type === Scalar.Scalar.BLOCK_FOLDED
147
+ ? false
148
+ : type === Scalar.Scalar.BLOCK_LITERAL
149
+ ? true
150
+ : !lineLengthOverLimit(value, ctx.options.lineWidth, indent.length);
167
151
  if (!value)
168
152
  return literal ? '|\n' : '>\n';
169
153
  // determine chomping from whitespace at value end
@@ -214,7 +198,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
214
198
  const indentSize = indent ? '2' : '1'; // root is at -1
215
199
  let header = (literal ? '|' : '>') + (startWithSpace ? indentSize : '') + chomp;
216
200
  if (comment) {
217
- header += ' ' + commentString(comment.replace(/ ?[\r\n]+/g, ' '));
201
+ header += ' #' + comment.replace(/ ?[\r\n]+/g, ' ');
218
202
  if (onComment)
219
203
  onComment();
220
204
  }
@@ -231,14 +215,30 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
231
215
  return `${header}\n${indent}${body}`;
232
216
  }
233
217
  function plainString(item, ctx, onComment, onChompKeep) {
218
+ var _a;
234
219
  const { type, value } = item;
235
220
  const { actualString, implicitKey, indent, inFlow } = ctx;
236
221
  if ((implicitKey && /[\n[\]{},]/.test(value)) ||
237
222
  (inFlow && /[[\]{},]/.test(value))) {
238
- return quotedString(value, ctx);
223
+ return doubleQuotedString(value, ctx);
239
224
  }
240
225
  if (!value ||
241
226
  /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
227
+ const hasDouble = value.indexOf('"') !== -1;
228
+ const hasSingle = value.indexOf("'") !== -1;
229
+ let quotedString;
230
+ if (hasDouble && !hasSingle) {
231
+ quotedString = singleQuotedString;
232
+ }
233
+ else if (hasSingle && !hasDouble) {
234
+ quotedString = doubleQuotedString;
235
+ }
236
+ else if (ctx.options.singleQuote) {
237
+ quotedString = singleQuotedString;
238
+ }
239
+ else {
240
+ quotedString = doubleQuotedString;
241
+ }
242
242
  // not allowed:
243
243
  // - empty string, '-' or '?'
244
244
  // - start with an indicator character (except [?:-]) or /[?-] /
@@ -265,10 +265,12 @@ function plainString(item, ctx, onComment, onChompKeep) {
265
265
  // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'),
266
266
  // and others in v1.1.
267
267
  if (actualString) {
268
- const test = (tag) => { var _a; return tag.default && tag.tag !== 'tag:yaml.org,2002:str' && ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(str)); };
269
- const { compat, tags } = ctx.doc.schema;
270
- if (tags.some(test) || (compat === null || compat === void 0 ? void 0 : compat.some(test)))
271
- return quotedString(value, ctx);
268
+ for (const tag of ctx.doc.schema.tags) {
269
+ if (tag.default &&
270
+ tag.tag !== 'tag:yaml.org,2002:str' &&
271
+ ((_a = tag.test) === null || _a === void 0 ? void 0 : _a.test(str)))
272
+ return doubleQuotedString(value, ctx);
273
+ }
272
274
  }
273
275
  return implicitKey
274
276
  ? str
@@ -290,7 +292,7 @@ function stringifyString(item, ctx, onComment, onChompKeep) {
290
292
  case Scalar.Scalar.BLOCK_FOLDED:
291
293
  case Scalar.Scalar.BLOCK_LITERAL:
292
294
  return implicitKey || inFlow
293
- ? quotedString(ss.value, ctx) // blocks are not valid inside flow containers
295
+ ? doubleQuotedString(ss.value, ctx) // blocks are not valid inside flow containers
294
296
  : blockString(ss, ctx, onComment, onChompKeep);
295
297
  case Scalar.Scalar.QUOTE_DOUBLE:
296
298
  return doubleQuotedString(ss.value, ctx);
@@ -1,4 +1,4 @@
1
1
  export declare function testEvents(src: string): {
2
2
  events: string[];
3
- error: unknown;
3
+ error: any;
4
4
  };
@@ -83,8 +83,7 @@ function addEvents(events, doc, errPos, node) {
83
83
  if (Node.isNode(node) && node.tag)
84
84
  props += ` <${node.tag}>`;
85
85
  if (Node.isMap(node)) {
86
- const ev = node.flow ? '+MAP {}' : '+MAP';
87
- events.push(`${ev}${props}`);
86
+ events.push(`+MAP${props}`);
88
87
  node.items.forEach(({ key, value }) => {
89
88
  addEvents(events, doc, errPos, key);
90
89
  addEvents(events, doc, errPos, value);
@@ -92,8 +91,7 @@ function addEvents(events, doc, errPos, node) {
92
91
  events.push('-MAP');
93
92
  }
94
93
  else if (Node.isSeq(node)) {
95
- const ev = node.flow ? '+SEQ []' : '+SEQ';
96
- events.push(`${ev}${props}`);
94
+ events.push(`+SEQ${props}`);
97
95
  node.items.forEach(item => {
98
96
  addEvents(events, doc, errPos, item);
99
97
  });
package/dist/util.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  export { debug, LogLevelId, warn } from './log.js';
2
2
  export { findPair } from './nodes/YAMLMap.js';
3
3
  export { toJS, ToJSContext } from './nodes/toJS.js';
4
- export { map as mapTag } from './schema/common/map.js';
5
- export { seq as seqTag } from './schema/common/seq.js';
6
- export { string as stringTag } from './schema/common/string.js';
7
4
  export { foldFlowLines } from './stringify/foldFlowLines';
8
5
  export { stringifyNumber } from './stringify/stringifyNumber.js';
9
6
  export { stringifyString } from './stringify/stringifyString.js';
package/dist/util.js CHANGED
@@ -3,9 +3,6 @@
3
3
  var log = require('./log.js');
4
4
  var YAMLMap = require('./nodes/YAMLMap.js');
5
5
  var toJS = require('./nodes/toJS.js');
6
- var map = require('./schema/common/map.js');
7
- var seq = require('./schema/common/seq.js');
8
- var string = require('./schema/common/string.js');
9
6
  var foldFlowLines = require('./stringify/foldFlowLines.js');
10
7
  var stringifyNumber = require('./stringify/stringifyNumber.js');
11
8
  var stringifyString = require('./stringify/stringifyString.js');
@@ -16,9 +13,6 @@ exports.debug = log.debug;
16
13
  exports.warn = log.warn;
17
14
  exports.findPair = YAMLMap.findPair;
18
15
  exports.toJS = toJS.toJS;
19
- exports.mapTag = map.map;
20
- exports.seqTag = seq.seq;
21
- exports.stringTag = string.string;
22
16
  exports.foldFlowLines = foldFlowLines.foldFlowLines;
23
17
  exports.stringifyNumber = stringifyNumber.stringifyNumber;
24
18
  exports.stringifyString = stringifyString.stringifyString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "2.0.0-10",
3
+ "version": "2.0.0-5",
4
4
  "license": "ISC",
5
5
  "author": "Eemeli Aro <eemeli@gmail.com>",
6
6
  "repository": "github:eemeli/yaml",
@@ -14,7 +14,6 @@
14
14
  "files": [
15
15
  "browser/",
16
16
  "dist/",
17
- "util.d.ts",
18
17
  "util.js"
19
18
  ],
20
19
  "type": "commonjs",
@@ -45,10 +44,9 @@
45
44
  "prestart": "npm run build:node",
46
45
  "start": "node -i -e 'YAML=require(\"./dist/index.js\")'",
47
46
  "test": "jest --config config/jest.config.js",
48
- "test:all": "npm test && npm run test:types && npm run test:dist && npm run test:dist:types",
49
47
  "test:browsers": "cd playground && npm test",
50
48
  "test:dist": "npm run build:node && jest --config config/jest.config.js",
51
- "test:dist:types": "tsc --allowJs --moduleResolution node --noEmit --target es5 dist/index.js",
49
+ "test:dist:types": "tsc --allowJs --moduleResolution node --noEmit --target es2017 dist/index.js",
52
50
  "test:types": "tsc --noEmit",
53
51
  "docs:install": "cd docs-slate && bundle install",
54
52
  "docs:deploy": "cd docs-slate && ./deploy.sh",
@@ -70,25 +68,25 @@
70
68
  "@babel/plugin-transform-typescript": "^7.12.17",
71
69
  "@babel/preset-env": "^7.12.11",
72
70
  "@rollup/plugin-babel": "^5.2.3",
73
- "@rollup/plugin-replace": "^3.0.0",
71
+ "@rollup/plugin-replace": "^2.3.4",
74
72
  "@rollup/plugin-typescript": "^8.1.1",
75
- "@types/jest": "^27.0.1",
76
- "@types/node": "^16.9.1",
77
- "@typescript-eslint/eslint-plugin": "^5.3.1",
78
- "@typescript-eslint/parser": "^5.3.1",
79
- "babel-jest": "^27.0.1",
73
+ "@types/jest": "^26.0.20",
74
+ "@types/node": "^14.14.37",
75
+ "@typescript-eslint/eslint-plugin": "^4.15.2",
76
+ "@typescript-eslint/parser": "^4.15.2",
77
+ "babel-jest": "^26.6.3",
80
78
  "cross-env": "^7.0.3",
81
- "eslint": "^8.2.0",
79
+ "eslint": "^7.20.0",
82
80
  "eslint-config-prettier": "^8.1.0",
83
81
  "fast-check": "^2.12.0",
84
- "jest": "^27.0.1",
82
+ "jest": "^26.6.3",
85
83
  "jest-ts-webcompat-resolver": "^1.0.0",
86
84
  "prettier": "^2.2.1",
87
85
  "rollup": "^2.38.2",
88
86
  "tslib": "^2.1.0",
89
- "typescript": "^4.3.5"
87
+ "typescript": "^4.1.3"
90
88
  },
91
89
  "engines": {
92
- "node": ">= 12"
90
+ "node": ">= 10"
93
91
  }
94
92
  }
@@ -1,15 +0,0 @@
1
- import { containsNewline } from './util-contains-newline.js';
2
-
3
- function flowIndentCheck(indent, fc, onError) {
4
- if ((fc === null || fc === void 0 ? void 0 : fc.type) === 'flow-collection') {
5
- const end = fc.end[0];
6
- if (end.indent === indent &&
7
- (end.source === ']' || end.source === '}') &&
8
- containsNewline(fc)) {
9
- const msg = 'Flow end indicator should be more indented than parent';
10
- onError(end, 'BAD_INDENT', msg, true);
11
- }
12
- }
13
- }
14
-
15
- export { flowIndentCheck };
@@ -1,17 +0,0 @@
1
- import { isScalar } from '../nodes/Node.js';
2
-
3
- function mapIncludes(ctx, items, search) {
4
- const { uniqueKeys } = ctx.options;
5
- if (uniqueKeys === false)
6
- return false;
7
- const isEqual = typeof uniqueKeys === 'function'
8
- ? uniqueKeys
9
- : (a, b) => a === b ||
10
- (isScalar(a) &&
11
- isScalar(b) &&
12
- a.value === b.value &&
13
- !(a.value === '<<' && ctx.schema.merge));
14
- return items.some(pair => isEqual(pair.key, search));
15
- }
16
-
17
- export { mapIncludes };
@@ -1,164 +0,0 @@
1
- /*! *****************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
-
16
- /* global Reflect, Promise */
17
- var extendStatics = function (d, b) {
18
- extendStatics = Object.setPrototypeOf || {
19
- __proto__: []
20
- } instanceof Array && function (d, b) {
21
- d.__proto__ = b;
22
- } || function (d, b) {
23
- for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
24
- };
25
-
26
- return extendStatics(d, b);
27
- };
28
-
29
- function __extends(d, b) {
30
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
31
- extendStatics(d, b);
32
-
33
- function __() {
34
- this.constructor = d;
35
- }
36
-
37
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
38
- }
39
- function __generator(thisArg, body) {
40
- var _ = {
41
- label: 0,
42
- sent: function () {
43
- if (t[0] & 1) throw t[1];
44
- return t[1];
45
- },
46
- trys: [],
47
- ops: []
48
- },
49
- f,
50
- y,
51
- t,
52
- g;
53
- return g = {
54
- next: verb(0),
55
- "throw": verb(1),
56
- "return": verb(2)
57
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
58
- return this;
59
- }), g;
60
-
61
- function verb(n) {
62
- return function (v) {
63
- return step([n, v]);
64
- };
65
- }
66
-
67
- function step(op) {
68
- if (f) throw new TypeError("Generator is already executing.");
69
-
70
- while (_) try {
71
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
72
- if (y = 0, t) op = [op[0] & 2, t.value];
73
-
74
- switch (op[0]) {
75
- case 0:
76
- case 1:
77
- t = op;
78
- break;
79
-
80
- case 4:
81
- _.label++;
82
- return {
83
- value: op[1],
84
- done: false
85
- };
86
-
87
- case 5:
88
- _.label++;
89
- y = op[1];
90
- op = [0];
91
- continue;
92
-
93
- case 7:
94
- op = _.ops.pop();
95
-
96
- _.trys.pop();
97
-
98
- continue;
99
-
100
- default:
101
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
102
- _ = 0;
103
- continue;
104
- }
105
-
106
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
107
- _.label = op[1];
108
- break;
109
- }
110
-
111
- if (op[0] === 6 && _.label < t[1]) {
112
- _.label = t[1];
113
- t = op;
114
- break;
115
- }
116
-
117
- if (t && _.label < t[2]) {
118
- _.label = t[2];
119
-
120
- _.ops.push(op);
121
-
122
- break;
123
- }
124
-
125
- if (t[2]) _.ops.pop();
126
-
127
- _.trys.pop();
128
-
129
- continue;
130
- }
131
-
132
- op = body.call(thisArg, _);
133
- } catch (e) {
134
- op = [6, e];
135
- y = 0;
136
- } finally {
137
- f = t = 0;
138
- }
139
-
140
- if (op[0] & 5) throw op[1];
141
- return {
142
- value: op[0] ? op[1] : void 0,
143
- done: true
144
- };
145
- }
146
- }
147
- function __values(o) {
148
- var s = typeof Symbol === "function" && Symbol.iterator,
149
- m = s && o[s],
150
- i = 0;
151
- if (m) return m.call(o);
152
- if (o && typeof o.length === "number") return {
153
- next: function () {
154
- if (o && i >= o.length) o = void 0;
155
- return {
156
- value: o && o[i++],
157
- done: !o
158
- };
159
- }
160
- };
161
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
162
- }
163
-
164
- export { __extends, __generator, __values };
@@ -1,18 +0,0 @@
1
- /**
2
- * Stringifies a comment.
3
- *
4
- * Empty comment lines are left empty,
5
- * lines consisting of a single space are replaced by `#`,
6
- * and all other lines are prefixed with a `#`.
7
- */
8
- const stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, '#');
9
- function indentComment(comment, indent) {
10
- if (/^\n+$/.test(comment))
11
- return comment.substring(1);
12
- return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
13
- }
14
- const lineComment = (str, indent, comment) => comment.includes('\n')
15
- ? '\n' + indentComment(comment, indent)
16
- : (str.endsWith(' ') ? '' : ' ') + comment;
17
-
18
- export { indentComment, lineComment, stringifyComment };
@@ -1,3 +0,0 @@
1
- import { Token } from '../parse/cst';
2
- import { ComposeErrorHandler } from './composer';
3
- export declare function flowIndentCheck(indent: number, fc: Token | null | undefined, onError: ComposeErrorHandler): void;
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- var utilContainsNewline = require('./util-contains-newline.js');
4
-
5
- function flowIndentCheck(indent, fc, onError) {
6
- if ((fc === null || fc === void 0 ? void 0 : fc.type) === 'flow-collection') {
7
- const end = fc.end[0];
8
- if (end.indent === indent &&
9
- (end.source === ']' || end.source === '}') &&
10
- utilContainsNewline.containsNewline(fc)) {
11
- const msg = 'Flow end indicator should be more indented than parent';
12
- onError(end, 'BAD_INDENT', msg, true);
13
- }
14
- }
15
- }
16
-
17
- exports.flowIndentCheck = flowIndentCheck;
@@ -1,4 +0,0 @@
1
- import { ParsedNode } from '../nodes/Node';
2
- import { Pair } from '../nodes/Pair';
3
- import { ComposeContext } from './compose-node';
4
- export declare function mapIncludes(ctx: ComposeContext, items: Pair<ParsedNode>[], search: ParsedNode): boolean;
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var Node = require('../nodes/Node.js');
4
-
5
- function mapIncludes(ctx, items, search) {
6
- const { uniqueKeys } = ctx.options;
7
- if (uniqueKeys === false)
8
- return false;
9
- const isEqual = typeof uniqueKeys === 'function'
10
- ? uniqueKeys
11
- : (a, b) => a === b ||
12
- (Node.isScalar(a) &&
13
- Node.isScalar(b) &&
14
- a.value === b.value &&
15
- !(a.value === '<<' && ctx.schema.merge));
16
- return items.some(pair => isEqual(pair.key, search));
17
- }
18
-
19
- exports.mapIncludes = mapIncludes;