yaml 1.6.0 → 1.8.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/browser/dist/Anchors.js +24 -39
- package/browser/dist/Document.js +99 -111
- package/browser/dist/addComment.js +2 -11
- package/browser/dist/constants.js +3 -11
- package/browser/dist/cst/Alias.js +19 -36
- package/browser/dist/cst/BlankLine.js +25 -38
- package/browser/dist/cst/BlockValue.js +29 -51
- package/browser/dist/cst/Collection.js +42 -65
- package/browser/dist/cst/CollectionItem.js +57 -58
- package/browser/dist/cst/Comment.js +19 -35
- package/browser/dist/cst/Directive.js +20 -56
- package/browser/dist/cst/Document.js +47 -71
- package/browser/dist/cst/FlowCollection.js +38 -61
- package/browser/dist/cst/Node.js +30 -47
- package/browser/dist/cst/ParseContext.js +100 -140
- package/browser/dist/cst/PlainValue.js +22 -39
- package/browser/dist/cst/QuoteDouble.js +26 -42
- package/browser/dist/cst/QuoteSingle.js +25 -41
- package/browser/dist/cst/Range.js +9 -19
- package/browser/dist/cst/parse.js +5 -16
- package/browser/dist/cst/source-utils.js +168 -0
- package/browser/dist/errors.js +71 -74
- package/browser/dist/foldFlowLines.js +4 -15
- package/browser/dist/index.js +26 -45
- package/browser/dist/listTagNames.js +10 -24
- package/browser/dist/schema/Alias.js +33 -50
- package/browser/dist/schema/Collection.js +54 -65
- package/browser/dist/schema/Map.js +39 -49
- package/browser/dist/schema/Merge.js +33 -53
- package/browser/dist/schema/Node.js +3 -12
- package/browser/dist/schema/Pair.js +53 -56
- package/browser/dist/schema/Scalar.js +18 -33
- package/browser/dist/schema/Seq.js +23 -40
- package/browser/dist/schema/index.js +67 -81
- package/browser/dist/schema/parseMap.js +63 -70
- package/browser/dist/schema/parseSeq.js +45 -44
- package/browser/dist/schema/parseUtils.js +47 -11
- package/browser/dist/stringify.js +43 -48
- package/browser/dist/tags/core.js +30 -37
- package/browser/dist/tags/failsafe/index.js +4 -17
- package/browser/dist/tags/failsafe/map.js +17 -26
- package/browser/dist/tags/failsafe/seq.js +7 -18
- package/browser/dist/tags/failsafe/string.js +7 -19
- package/browser/dist/tags/index.js +35 -49
- package/browser/dist/tags/json.js +11 -38
- package/browser/dist/tags/options.js +8 -20
- package/browser/dist/tags/yaml-1.1/binary.js +16 -29
- package/browser/dist/tags/yaml-1.1/index.js +34 -54
- package/browser/dist/tags/yaml-1.1/omap.js +39 -58
- package/browser/dist/tags/yaml-1.1/pairs.js +15 -34
- package/browser/dist/tags/yaml-1.1/set.js +35 -61
- package/browser/dist/tags/yaml-1.1/timestamp.js +6 -16
- package/browser/dist/test-events.js +7 -19
- package/browser/dist/toJSON.js +1 -8
- package/browser/dist/warnings.js +28 -0
- package/browser/map.js +1 -1
- package/browser/pair.js +1 -1
- package/browser/scalar.js +1 -1
- package/browser/schema.js +1 -1
- package/browser/seq.js +1 -1
- package/browser/types/binary.js +1 -1
- package/browser/types/omap.js +1 -1
- package/browser/types/pairs.js +1 -1
- package/browser/types/set.js +1 -1
- package/browser/types/timestamp.js +1 -1
- package/dist/Document.js +21 -9
- package/dist/cst/BlankLine.js +4 -0
- package/dist/cst/BlockValue.js +1 -1
- package/dist/cst/CollectionItem.js +27 -6
- package/dist/cst/Directive.js +0 -16
- package/dist/cst/Node.js +7 -9
- package/dist/cst/ParseContext.js +41 -55
- package/dist/cst/PlainValue.js +1 -1
- package/dist/cst/source-utils.js +178 -0
- package/dist/errors.js +37 -3
- package/dist/index.js +5 -4
- package/dist/schema/Alias.js +2 -1
- package/dist/schema/Collection.js +22 -5
- package/dist/schema/Map.js +12 -5
- package/dist/schema/Merge.js +4 -5
- package/dist/schema/Pair.js +20 -2
- package/dist/schema/index.js +14 -8
- package/dist/schema/parseMap.js +20 -5
- package/dist/schema/parseSeq.js +19 -6
- package/dist/schema/parseUtils.js +54 -6
- package/dist/stringify.js +21 -11
- package/dist/tags/core.js +27 -10
- package/dist/tags/failsafe/map.js +5 -1
- package/dist/tags/failsafe/seq.js +1 -1
- package/dist/tags/index.js +13 -1
- package/dist/tags/json.js +2 -9
- package/dist/tags/yaml-1.1/index.js +6 -6
- package/dist/tags/yaml-1.1/omap.js +3 -5
- package/dist/tags/yaml-1.1/pairs.js +1 -1
- package/dist/tags/yaml-1.1/set.js +3 -1
- package/dist/{deprecation.js → warnings.js} +12 -7
- package/map.js +1 -1
- package/package.json +35 -17
- package/pair.js +1 -1
- package/scalar.js +1 -1
- package/schema.js +1 -1
- package/seq.js +1 -1
- package/types/binary.js +1 -1
- package/types/omap.js +1 -1
- package/types/pairs.js +1 -1
- package/types/set.js +1 -1
- package/types/timestamp.js +1 -1
- package/types.mjs +20 -0
- package/util.mjs +24 -0
- package/browser/dist/cst/getLinePos.js +0 -79
- package/browser/dist/deprecation.js +0 -34
- package/dist/cst/getLinePos.js +0 -79
|
@@ -25,6 +25,10 @@ var _timestamp = require("./timestamp");
|
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
|
|
28
|
+
const boolStringify = ({
|
|
29
|
+
value
|
|
30
|
+
}) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr;
|
|
31
|
+
|
|
28
32
|
var _default = _failsafe.default.concat([{
|
|
29
33
|
identify: value => value == null,
|
|
30
34
|
createNode: (schema, value, ctx) => ctx.wrapScalars ? new _Scalar.default(null) : null,
|
|
@@ -41,9 +45,7 @@ var _default = _failsafe.default.concat([{
|
|
|
41
45
|
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
42
46
|
resolve: () => true,
|
|
43
47
|
options: _options.boolOptions,
|
|
44
|
-
stringify:
|
|
45
|
-
value
|
|
46
|
-
}) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr
|
|
48
|
+
stringify: boolStringify
|
|
47
49
|
}, {
|
|
48
50
|
identify: value => typeof value === 'boolean',
|
|
49
51
|
default: true,
|
|
@@ -51,9 +53,7 @@ var _default = _failsafe.default.concat([{
|
|
|
51
53
|
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
|
|
52
54
|
resolve: () => false,
|
|
53
55
|
options: _options.boolOptions,
|
|
54
|
-
stringify:
|
|
55
|
-
value
|
|
56
|
-
}) => value ? _options.boolOptions.trueStr : _options.boolOptions.falseStr
|
|
56
|
+
stringify: boolStringify
|
|
57
57
|
}, {
|
|
58
58
|
identify: value => typeof value === 'number',
|
|
59
59
|
default: true,
|
|
@@ -71,11 +71,9 @@ function parseOMap(doc, cst) {
|
|
|
71
71
|
const pairs = (0, _pairs.parsePairs)(doc, cst);
|
|
72
72
|
const seenKeys = [];
|
|
73
73
|
|
|
74
|
-
for (const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} = _ref;
|
|
78
|
-
|
|
74
|
+
for (const {
|
|
75
|
+
key
|
|
76
|
+
} of pairs.items) {
|
|
79
77
|
if (key instanceof _Scalar.default) {
|
|
80
78
|
if (seenKeys.includes(key.value)) {
|
|
81
79
|
const msg = 'Ordered maps must not include duplicate keys';
|
|
@@ -17,7 +17,9 @@ var _Scalar = _interopRequireDefault(require("../../schema/Scalar"));
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
23
|
|
|
22
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
25
|
|
|
@@ -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(
|
|
11
|
-
if (global && global.
|
|
12
|
-
|
|
13
|
-
|
|
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(
|
|
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/
|
|
2
|
+
require('./dist/warnings').warnFileDeprecation(__filename)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaml",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": "Eemeli Aro <eemeli@gmail.com>",
|
|
6
6
|
"repository": "github:eemeli/yaml",
|
|
@@ -16,8 +16,10 @@
|
|
|
16
16
|
"dist/",
|
|
17
17
|
"types/",
|
|
18
18
|
"*.js",
|
|
19
|
+
"*.mjs",
|
|
19
20
|
"!.*.js"
|
|
20
21
|
],
|
|
22
|
+
"type": "commonjs",
|
|
21
23
|
"main": "./index.js",
|
|
22
24
|
"browser": {
|
|
23
25
|
"./index.js": "./browser/index.js",
|
|
@@ -35,9 +37,22 @@
|
|
|
35
37
|
"./types/timestamp.js": "./browser/types/timestamp.js",
|
|
36
38
|
"./util.js": "./browser/util.js"
|
|
37
39
|
},
|
|
40
|
+
"exports": {
|
|
41
|
+
".": "./index.js",
|
|
42
|
+
"./parse-cst": "./parse-cst.js",
|
|
43
|
+
"./types": {
|
|
44
|
+
"require": "./types.js",
|
|
45
|
+
"import": "./types.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./util": {
|
|
48
|
+
"require": "./util.js",
|
|
49
|
+
"import": "./util.mjs"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
38
52
|
"scripts": {
|
|
39
53
|
"browser:build": "BABEL_ENV=browser babel src/ --out-dir browser/dist/",
|
|
40
54
|
"browser:copy": "cpy '*.js' '!*.config.js' types/ browser/ --parents",
|
|
55
|
+
"clean": "git clean -fdxe node_modules",
|
|
41
56
|
"dist:build": "babel src/ --out-dir dist/",
|
|
42
57
|
"build": "npm run dist:build && npm run browser:build && npm run browser:copy",
|
|
43
58
|
"prettier": "prettier --write \"{src,tests}/**/*.js\"",
|
|
@@ -49,10 +64,13 @@
|
|
|
49
64
|
"docs:deploy": "cd docs/ && ./deploy.sh",
|
|
50
65
|
"docs": "cd docs/ && bundle exec middleman server",
|
|
51
66
|
"preversion": "npm test && npm run build",
|
|
52
|
-
"prepublishOnly": "npm test && npm run build"
|
|
67
|
+
"prepublishOnly": "npm run clean && npm test && npm run build"
|
|
53
68
|
},
|
|
54
69
|
"browserslist": "> 0.5%, not dead",
|
|
55
70
|
"jest": {
|
|
71
|
+
"collectCoverageFrom": [
|
|
72
|
+
"src/**/*.js"
|
|
73
|
+
],
|
|
56
74
|
"testMatch": [
|
|
57
75
|
"**/tests/**/*.js"
|
|
58
76
|
],
|
|
@@ -66,25 +84,25 @@
|
|
|
66
84
|
"singleQuote": true
|
|
67
85
|
},
|
|
68
86
|
"devDependencies": {
|
|
69
|
-
"@babel/cli": "^7.
|
|
70
|
-
"@babel/core": "^7.
|
|
71
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
72
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
73
|
-
"@babel/preset-env": "^7.
|
|
74
|
-
"babel-eslint": "^10.0
|
|
75
|
-
"babel-jest": "^
|
|
87
|
+
"@babel/cli": "^7.8.4",
|
|
88
|
+
"@babel/core": "^7.8.7",
|
|
89
|
+
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
|
90
|
+
"@babel/plugin-transform-runtime": "^7.8.3",
|
|
91
|
+
"@babel/preset-env": "^7.8.7",
|
|
92
|
+
"babel-eslint": "^10.1.0",
|
|
93
|
+
"babel-jest": "^25.1.0",
|
|
76
94
|
"babel-plugin-trace": "^1.1.0",
|
|
77
95
|
"common-tags": "^1.8.0",
|
|
78
|
-
"cpy-cli": "^
|
|
79
|
-
"eslint": "^
|
|
80
|
-
"eslint-config-prettier": "^
|
|
81
|
-
"eslint-plugin-prettier": "^3.1.
|
|
82
|
-
"fast-check": "^1.
|
|
83
|
-
"jest": "^
|
|
84
|
-
"prettier": "^1.
|
|
96
|
+
"cpy-cli": "^3.1.0",
|
|
97
|
+
"eslint": "^6.8.0",
|
|
98
|
+
"eslint-config-prettier": "^6.10.0",
|
|
99
|
+
"eslint-plugin-prettier": "^3.1.2",
|
|
100
|
+
"fast-check": "^1.23.0",
|
|
101
|
+
"jest": "^25.1.0",
|
|
102
|
+
"prettier": "^1.19.1"
|
|
85
103
|
},
|
|
86
104
|
"dependencies": {
|
|
87
|
-
"@babel/runtime": "^7.
|
|
105
|
+
"@babel/runtime": "^7.8.7"
|
|
88
106
|
},
|
|
89
107
|
"engines": {
|
|
90
108
|
"node": ">= 6"
|
package/pair.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
module.exports = require('./dist/schema/Pair').default
|
|
2
|
-
require('./dist/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
2
|
+
require('../dist/warnings').warnFileDeprecation(__filename)
|
package/types/timestamp.js
CHANGED
package/types.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import opt from './dist/tags/options.js'
|
|
2
|
+
export const binaryOptions = opt.binaryOptions
|
|
3
|
+
export const boolOptions = opt.boolOptions
|
|
4
|
+
export const nullOptions = opt.nullOptions
|
|
5
|
+
export const strOptions = opt.strOptions
|
|
6
|
+
|
|
7
|
+
import schema from './dist/schema/index.js'
|
|
8
|
+
export const Schema = schema.default
|
|
9
|
+
|
|
10
|
+
import map from './dist/schema/Map.js'
|
|
11
|
+
export const YAMLMap = map.default
|
|
12
|
+
|
|
13
|
+
import seq from './dist/schema/Seq.js'
|
|
14
|
+
export const YAMLSeq = seq.default
|
|
15
|
+
|
|
16
|
+
import pair from './dist/schema/Pair.js'
|
|
17
|
+
export const Pair = pair.default
|
|
18
|
+
|
|
19
|
+
import scalar from './dist/schema/Scalar.js'
|
|
20
|
+
export const Scalar = scalar.default
|
package/util.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import map from './dist/schema/Map.js'
|
|
2
|
+
export const findPair = map.findPair
|
|
3
|
+
|
|
4
|
+
import parseMapPkg from './dist/schema/parseMap.js'
|
|
5
|
+
export const parseMap = parseMapPkg.default
|
|
6
|
+
|
|
7
|
+
import parseSeqPkg from './dist/schema/parseSeq.js'
|
|
8
|
+
export const parseSeq = parseSeqPkg.default
|
|
9
|
+
|
|
10
|
+
import str from './dist/stringify.js'
|
|
11
|
+
export const stringifyNumber = str.stringifyNumber
|
|
12
|
+
export const stringifyString = str.stringifyString
|
|
13
|
+
|
|
14
|
+
import toJsonPkg from './dist/toJSON.js'
|
|
15
|
+
export const toJSON = toJsonPkg.default
|
|
16
|
+
|
|
17
|
+
import constants from './dist/constants.js'
|
|
18
|
+
export const Type = constants.Type
|
|
19
|
+
|
|
20
|
+
import err from './dist/errors.js'
|
|
21
|
+
export const YAMLReferenceError = err.YAMLReferenceError
|
|
22
|
+
export const YAMLSemanticError = err.YAMLSemanticError
|
|
23
|
+
export const YAMLSyntaxError = err.YAMLSyntaxError
|
|
24
|
+
export const YAMLWarning = err.YAMLWarning
|
|
@@ -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,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.warnFileDeprecation = warnFileDeprecation;
|
|
7
|
-
exports.warnOptionDeprecation = warnOptionDeprecation;
|
|
8
|
-
|
|
9
|
-
/* global global, console */
|
|
10
|
-
function warn(msg) {
|
|
11
|
-
if (global && global.process && global.process.emitWarning) {
|
|
12
|
-
global.process.emitWarning(msg, 'DeprecationWarning');
|
|
13
|
-
} else {
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.warn("DeprecationWarning: ".concat(msg));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function warnFileDeprecation(filename) {
|
|
20
|
-
if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
|
|
21
|
-
var path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/');
|
|
22
|
-
warn("The endpoint 'yaml/".concat(path, "' will be removed in a future release."));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var warned = {};
|
|
26
|
-
|
|
27
|
-
function warnOptionDeprecation(name, alternative) {
|
|
28
|
-
if (global && global._YAML_SILENCE_DEPRECATION_WARNINGS) return;
|
|
29
|
-
if (warned[name]) return;
|
|
30
|
-
warned[name] = true;
|
|
31
|
-
var msg = "The option '".concat(name, "' will be removed in a future release");
|
|
32
|
-
msg += alternative ? ", use '".concat(alternative, "' instead.") : '.';
|
|
33
|
-
warn(msg);
|
|
34
|
-
}
|
package/dist/cst/getLinePos.js
DELETED
|
@@ -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
|
-
}
|