yaml 1.5.1 → 1.7.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.
Files changed (62) hide show
  1. package/browser/dist/Document.js +25 -5
  2. package/browser/dist/cst/CollectionItem.js +27 -6
  3. package/browser/dist/cst/Document.js +9 -1
  4. package/browser/dist/cst/FlowCollection.js +9 -1
  5. package/browser/dist/cst/Node.js +7 -4
  6. package/browser/dist/cst/PlainValue.js +1 -1
  7. package/browser/dist/cst/source-utils.js +179 -0
  8. package/browser/dist/errors.js +36 -3
  9. package/browser/dist/index.js +5 -4
  10. package/browser/dist/schema/Alias.js +1 -1
  11. package/browser/dist/schema/Merge.js +1 -1
  12. package/browser/dist/schema/Pair.js +17 -2
  13. package/browser/dist/schema/index.js +4 -3
  14. package/browser/dist/schema/parseMap.js +17 -4
  15. package/browser/dist/schema/parseSeq.js +22 -6
  16. package/browser/dist/schema/parseUtils.js +49 -0
  17. package/browser/dist/stringify.js +4 -3
  18. package/browser/dist/tags/failsafe/map.js +2 -2
  19. package/browser/dist/{deprecation.js → warnings.js} +13 -7
  20. package/browser/map.js +1 -1
  21. package/browser/pair.js +1 -1
  22. package/browser/scalar.js +1 -1
  23. package/browser/schema.js +1 -1
  24. package/browser/seq.js +1 -1
  25. package/browser/types/binary.js +1 -1
  26. package/browser/types/omap.js +1 -1
  27. package/browser/types/pairs.js +1 -1
  28. package/browser/types/set.js +1 -1
  29. package/browser/types/timestamp.js +1 -1
  30. package/dist/Document.js +32 -12
  31. package/dist/cst/CollectionItem.js +27 -6
  32. package/dist/cst/Document.js +9 -1
  33. package/dist/cst/FlowCollection.js +9 -1
  34. package/dist/cst/Node.js +7 -4
  35. package/dist/cst/PlainValue.js +1 -1
  36. package/dist/cst/source-utils.js +178 -0
  37. package/dist/errors.js +37 -3
  38. package/dist/index.js +5 -4
  39. package/dist/schema/Alias.js +1 -1
  40. package/dist/schema/Merge.js +4 -5
  41. package/dist/schema/Pair.js +19 -2
  42. package/dist/schema/index.js +4 -3
  43. package/dist/schema/parseMap.js +20 -5
  44. package/dist/schema/parseSeq.js +19 -6
  45. package/dist/schema/parseUtils.js +54 -6
  46. package/dist/stringify.js +7 -4
  47. package/dist/tags/yaml-1.1/omap.js +3 -5
  48. package/dist/tags/yaml-1.1/set.js +3 -1
  49. package/dist/{deprecation.js → warnings.js} +12 -7
  50. package/map.js +1 -1
  51. package/package.json +18 -16
  52. package/pair.js +1 -1
  53. package/scalar.js +1 -1
  54. package/schema.js +1 -1
  55. package/seq.js +1 -1
  56. package/types/binary.js +1 -1
  57. package/types/omap.js +1 -1
  58. package/types/pairs.js +1 -1
  59. package/types/set.js +1 -1
  60. package/types/timestamp.js +1 -1
  61. package/browser/dist/cst/getLinePos.js +0 -79
  62. package/dist/cst/getLinePos.js +0 -79
@@ -3,23 +3,28 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.warn = warn;
6
7
  exports.warnFileDeprecation = warnFileDeprecation;
7
8
  exports.warnOptionDeprecation = warnOptionDeprecation;
8
9
 
9
10
  /* global global, console */
10
- function warn(msg) {
11
- if (global && global.process && global.process.emitWarning) {
12
- global.process.emitWarning(msg, 'DeprecationWarning');
13
- } else {
11
+ function warn(warning, type) {
12
+ if (global && global._YAML_SILENCE_WARNINGS) return;
13
+ const {
14
+ emitWarning
15
+ } = global && global.process; // This will throw in Jest if `warning` is an Error instance due to
16
+ // https://github.com/facebook/jest/issues/2549
17
+
18
+ if (emitWarning) emitWarning(warning, type);else {
14
19
  // eslint-disable-next-line no-console
15
- console.warn(`DeprecationWarning: ${msg}`);
20
+ console.warn(type ? `${type}: ${warning}` : warning);
16
21
  }
17
22
  }
18
23
 
19
24
  function warnFileDeprecation(filename) {
20
25
  if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
21
26
  const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
22
- warn(`The endpoint 'yaml/${path}' will be removed in a future release.`);
27
+ warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning');
23
28
  }
24
29
 
25
30
  const warned = {};
@@ -30,5 +35,5 @@ function warnOptionDeprecation(name, alternative) {
30
35
  warned[name] = true;
31
36
  let msg = `The option '${name}' will be removed in a future release`;
32
37
  msg += alternative ? `, use '${alternative}' instead.` : '.';
33
- warn(msg);
38
+ warn(msg, 'DeprecationWarning');
34
39
  }
package/map.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('./dist/schema/Map').default
2
- require('./dist/deprecation').warnFileDeprecation(__filename)
2
+ require('./dist/warnings').warnFileDeprecation(__filename)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yaml",
3
- "version": "1.5.1",
3
+ "version": "1.7.2",
4
4
  "license": "ISC",
5
5
  "author": "Eemeli Aro <eemeli@gmail.com>",
6
6
  "repository": "github:eemeli/yaml",
@@ -38,6 +38,7 @@
38
38
  "scripts": {
39
39
  "browser:build": "BABEL_ENV=browser babel src/ --out-dir browser/dist/",
40
40
  "browser:copy": "cpy '*.js' '!*.config.js' types/ browser/ --parents",
41
+ "clean": "git clean -fdxe node_modules",
41
42
  "dist:build": "babel src/ --out-dir dist/",
42
43
  "build": "npm run dist:build && npm run browser:build && npm run browser:copy",
43
44
  "prettier": "prettier --write \"{src,tests}/**/*.js\"",
@@ -49,7 +50,7 @@
49
50
  "docs:deploy": "cd docs/ && ./deploy.sh",
50
51
  "docs": "cd docs/ && bundle exec middleman server",
51
52
  "preversion": "npm test && npm run build",
52
- "prepublishOnly": "npm test && npm run build"
53
+ "prepublishOnly": "npm run clean && npm test && npm run build"
53
54
  },
54
55
  "browserslist": "> 0.5%, not dead",
55
56
  "jest": {
@@ -66,24 +67,25 @@
66
67
  "singleQuote": true
67
68
  },
68
69
  "devDependencies": {
69
- "@babel/cli": "^7.4.4",
70
- "@babel/core": "^7.4.4",
71
- "@babel/plugin-proposal-class-properties": "^7.4.4",
72
- "@babel/plugin-transform-runtime": "^7.4.4",
73
- "@babel/preset-env": "^7.4.4",
74
- "babel-eslint": "^10.0.1",
75
- "babel-jest": "^24.8.0",
70
+ "@babel/cli": "^7.6.4",
71
+ "@babel/core": "^7.6.4",
72
+ "@babel/plugin-proposal-class-properties": "^7.5.5",
73
+ "@babel/plugin-transform-runtime": "^7.6.2",
74
+ "@babel/preset-env": "^7.6.3",
75
+ "babel-eslint": "^10.0.3",
76
+ "babel-jest": "^24.9.0",
76
77
  "babel-plugin-trace": "^1.1.0",
78
+ "common-tags": "^1.8.0",
77
79
  "cpy-cli": "^2.0.0",
78
- "eslint": "^5.16.0",
79
- "eslint-config-prettier": "^4.2.0",
80
- "eslint-plugin-prettier": "^3.0.1",
81
- "fast-check": "^1.14.0",
82
- "jest": "^24.8.0",
83
- "prettier": "^1.17.0"
80
+ "eslint": "^6.5.1",
81
+ "eslint-config-prettier": "^6.4.0",
82
+ "eslint-plugin-prettier": "^3.1.1",
83
+ "fast-check": "^1.17.0",
84
+ "jest": "^24.9.0",
85
+ "prettier": "^1.18.2"
84
86
  },
85
87
  "dependencies": {
86
- "@babel/runtime": "^7.4.4"
88
+ "@babel/runtime": "^7.6.3"
87
89
  },
88
90
  "engines": {
89
91
  "node": ">= 6"
package/pair.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('./dist/schema/Pair').default
2
- require('./dist/deprecation').warnFileDeprecation(__filename)
2
+ require('./dist/warnings').warnFileDeprecation(__filename)
package/scalar.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('./dist/schema/Scalar').default
2
- require('./dist/deprecation').warnFileDeprecation(__filename)
2
+ require('./dist/warnings').warnFileDeprecation(__filename)
package/schema.js CHANGED
@@ -4,4 +4,4 @@ module.exports.nullOptions = opt.nullOptions
4
4
  module.exports.strOptions = opt.strOptions
5
5
  module.exports.stringify = require('./dist/stringify').stringifyString
6
6
 
7
- require('./dist/deprecation').warnFileDeprecation(__filename)
7
+ require('./dist/warnings').warnFileDeprecation(__filename)
package/seq.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('./dist/schema/Seq').default
2
- require('./dist/deprecation').warnFileDeprecation(__filename)
2
+ require('./dist/warnings').warnFileDeprecation(__filename)
package/types/binary.js CHANGED
@@ -4,4 +4,4 @@ Object.defineProperty(exports, '__esModule', { value: true })
4
4
  exports.binary = require('../dist/tags/yaml-1.1/binary').default
5
5
  exports.default = [exports.binary]
6
6
 
7
- require('../dist/deprecation').warnFileDeprecation(__filename)
7
+ require('../dist/warnings').warnFileDeprecation(__filename)
package/types/omap.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('../dist/tags/yaml-1.1/omap').default
2
- require('../dist/deprecation').warnFileDeprecation(__filename)
2
+ require('../dist/warnings').warnFileDeprecation(__filename)
package/types/pairs.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('../dist/tags/yaml-1.1/pairs').default
2
- require('../dist/deprecation').warnFileDeprecation(__filename)
2
+ require('../dist/warnings').warnFileDeprecation(__filename)
package/types/set.js CHANGED
@@ -1,2 +1,2 @@
1
1
  module.exports = require('../dist/tags/yaml-1.1/set').default
2
- require('../dist/deprecation').warnFileDeprecation(__filename)
2
+ require('../dist/warnings').warnFileDeprecation(__filename)
@@ -7,4 +7,4 @@ exports.floatTime = ts.floatTime
7
7
  exports.intTime = ts.intTime
8
8
  exports.timestamp = ts.timestamp
9
9
 
10
- require('../dist/deprecation').warnFileDeprecation(__filename)
10
+ require('../dist/warnings').warnFileDeprecation(__filename)
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = getLinePos;
7
-
8
- function findLineStarts(src) {
9
- var ls = [0];
10
- var offset = src.indexOf('\n');
11
-
12
- while (offset !== -1) {
13
- offset += 1;
14
- ls.push(offset);
15
- offset = src.indexOf('\n', offset);
16
- }
17
-
18
- return ls;
19
- }
20
- /**
21
- * Determine the line/col position matching a character offset.
22
- *
23
- * Accepts a source string or a CST document as the second parameter. With
24
- * the latter, starting indices for lines are cached in the document as
25
- * `lineStarts: number[]`.
26
- *
27
- * Returns a one-indexed `{ line, col }` location if found, or
28
- * `undefined` otherwise.
29
- *
30
- * @param {number} offset
31
- * @param {string|Document|Document[]} cst
32
- * @returns {{ line: number, col: number }|undefined}
33
- */
34
-
35
-
36
- function getLinePos(offset, cst) {
37
- if (typeof offset === 'number' && offset >= 0) {
38
- var lineStarts, srcLength;
39
-
40
- if (typeof cst === 'string') {
41
- lineStarts = findLineStarts(cst);
42
- srcLength = cst.length;
43
- } else {
44
- if (Array.isArray(cst)) cst = cst[0];
45
-
46
- if (cst) {
47
- if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
48
- lineStarts = cst.lineStarts;
49
- srcLength = cst.context.src.length;
50
- }
51
- }
52
-
53
- if (lineStarts && offset <= srcLength) {
54
- for (var i = 0; i < lineStarts.length; ++i) {
55
- var start = lineStarts[i];
56
-
57
- if (offset < start) {
58
- return {
59
- line: i,
60
- col: offset - lineStarts[i - 1] + 1
61
- };
62
- }
63
-
64
- if (offset === start) return {
65
- line: i + 1,
66
- col: 1
67
- };
68
- }
69
-
70
- var line = lineStarts.length;
71
- return {
72
- line: line,
73
- col: offset - lineStarts[line - 1] + 1
74
- };
75
- }
76
- }
77
-
78
- return undefined;
79
- }
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = getLinePos;
7
-
8
- function findLineStarts(src) {
9
- const ls = [0];
10
- let offset = src.indexOf('\n');
11
-
12
- while (offset !== -1) {
13
- offset += 1;
14
- ls.push(offset);
15
- offset = src.indexOf('\n', offset);
16
- }
17
-
18
- return ls;
19
- }
20
- /**
21
- * Determine the line/col position matching a character offset.
22
- *
23
- * Accepts a source string or a CST document as the second parameter. With
24
- * the latter, starting indices for lines are cached in the document as
25
- * `lineStarts: number[]`.
26
- *
27
- * Returns a one-indexed `{ line, col }` location if found, or
28
- * `undefined` otherwise.
29
- *
30
- * @param {number} offset
31
- * @param {string|Document|Document[]} cst
32
- * @returns {{ line: number, col: number }|undefined}
33
- */
34
-
35
-
36
- function getLinePos(offset, cst) {
37
- if (typeof offset === 'number' && offset >= 0) {
38
- let lineStarts, srcLength;
39
-
40
- if (typeof cst === 'string') {
41
- lineStarts = findLineStarts(cst);
42
- srcLength = cst.length;
43
- } else {
44
- if (Array.isArray(cst)) cst = cst[0];
45
-
46
- if (cst) {
47
- if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src);
48
- lineStarts = cst.lineStarts;
49
- srcLength = cst.context.src.length;
50
- }
51
- }
52
-
53
- if (lineStarts && offset <= srcLength) {
54
- for (let i = 0; i < lineStarts.length; ++i) {
55
- const start = lineStarts[i];
56
-
57
- if (offset < start) {
58
- return {
59
- line: i,
60
- col: offset - lineStarts[i - 1] + 1
61
- };
62
- }
63
-
64
- if (offset === start) return {
65
- line: i + 1,
66
- col: 1
67
- };
68
- }
69
-
70
- const line = lineStarts.length;
71
- return {
72
- line,
73
- col: offset - lineStarts[line - 1] + 1
74
- };
75
- }
76
- }
77
-
78
- return undefined;
79
- }