Comparing version 1.7.0 to 1.7.1
@@ -66,2 +66,5 @@ "use strict"; | ||
var ch = src[offset]; | ||
var inlineComment = ch === '#'; | ||
var comments = []; | ||
var blankLine = null; | ||
@@ -72,3 +75,3 @@ while (ch === '\n' || ch === '#') { | ||
this.props.push(new _Range.default(offset, _end)); | ||
comments.push(new _Range.default(offset, _end)); | ||
offset = _end; | ||
@@ -81,9 +84,7 @@ } else { | ||
if (src[wsEnd] === '\n') { | ||
var blankLine = new _BlankLine.default(); | ||
if (src[wsEnd] === '\n' && comments.length === 0) { | ||
blankLine = new _BlankLine.default(); | ||
lineStart = blankLine.parse({ | ||
src: src | ||
}, lineStart); | ||
var items = context.parent.items || context.parent.contents; | ||
items.push(blankLine); | ||
} | ||
@@ -105,3 +106,2 @@ | ||
}, offset); | ||
if (this.node) offset = this.node.range.end; | ||
} else if (ch && lineStart > start + 1) { | ||
@@ -111,2 +111,23 @@ offset = lineStart - 1; | ||
if (this.node) { | ||
if (blankLine) { | ||
// Only blank lines preceding non-empty nodes are captured. Note that | ||
// this means that collection item range start indices do not always | ||
// increase monotonically. -- eemeli/yaml#126 | ||
var items = context.parent.items || context.parent.contents; | ||
if (items) items.push(blankLine); | ||
} | ||
if (comments.length) Array.prototype.push.apply(this.props, comments); | ||
offset = this.node.range.end; | ||
} else { | ||
if (inlineComment) { | ||
var c = comments[0]; | ||
this.props.push(c); | ||
offset = c.end; | ||
} else { | ||
offset = _Node2.default.endOfLine(src, start + 1); | ||
} | ||
} | ||
var end = this.node ? this.node.valueRange.end : offset; | ||
@@ -113,0 +134,0 @@ this.valueRange = new _Range.default(start, end); |
@@ -208,3 +208,6 @@ "use strict"; | ||
(0, _classCallCheck2.default)(this, Node); | ||
this.context = context || null; | ||
Object.defineProperty(this, 'context', { | ||
value: context || null, | ||
writable: true | ||
}); | ||
this.error = null; | ||
@@ -211,0 +214,0 @@ this.range = null; |
@@ -52,2 +52,5 @@ "use strict"; | ||
let ch = src[offset]; | ||
const inlineComment = ch === '#'; | ||
const comments = []; | ||
let blankLine = null; | ||
@@ -58,3 +61,3 @@ while (ch === '\n' || ch === '#') { | ||
this.props.push(new _Range.default(offset, end)); | ||
comments.push(new _Range.default(offset, end)); | ||
offset = end; | ||
@@ -67,9 +70,7 @@ } else { | ||
if (src[wsEnd] === '\n') { | ||
const blankLine = new _BlankLine.default(); | ||
if (src[wsEnd] === '\n' && comments.length === 0) { | ||
blankLine = new _BlankLine.default(); | ||
lineStart = blankLine.parse({ | ||
src | ||
}, lineStart); | ||
const items = context.parent.items || context.parent.contents; | ||
items.push(blankLine); | ||
} | ||
@@ -91,3 +92,2 @@ | ||
}, offset); | ||
if (this.node) offset = this.node.range.end; | ||
} else if (ch && lineStart > start + 1) { | ||
@@ -97,2 +97,23 @@ offset = lineStart - 1; | ||
if (this.node) { | ||
if (blankLine) { | ||
// Only blank lines preceding non-empty nodes are captured. Note that | ||
// this means that collection item range start indices do not always | ||
// increase monotonically. -- eemeli/yaml#126 | ||
const items = context.parent.items || context.parent.contents; | ||
if (items) items.push(blankLine); | ||
} | ||
if (comments.length) Array.prototype.push.apply(this.props, comments); | ||
offset = this.node.range.end; | ||
} else { | ||
if (inlineComment) { | ||
const c = comments[0]; | ||
this.props.push(c); | ||
offset = c.end; | ||
} else { | ||
offset = _Node.default.endOfLine(src, start + 1); | ||
} | ||
} | ||
const end = this.node ? this.node.valueRange.end : offset; | ||
@@ -99,0 +120,0 @@ this.valueRange = new _Range.default(start, end); |
@@ -174,3 +174,6 @@ "use strict"; | ||
constructor(type, props, context) { | ||
this.context = context || null; | ||
Object.defineProperty(this, 'context', { | ||
value: context || null, | ||
writable: true | ||
}); | ||
this.error = null; | ||
@@ -177,0 +180,0 @@ this.range = null; |
{ | ||
"name": "yaml", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"license": "ISC", | ||
@@ -41,2 +41,3 @@ "author": "Eemeli Aro <eemeli@gmail.com>", | ||
"browser:copy": "cpy '*.js' '!*.config.js' types/ browser/ --parents", | ||
"clean": "git clean -fdxe node_modules", | ||
"dist:build": "babel src/ --out-dir dist/", | ||
@@ -53,3 +54,3 @@ "build": "npm run dist:build && npm run browser:build && npm run browser:copy", | ||
"preversion": "npm test && npm run build", | ||
"prepublishOnly": "npm test && npm run build" | ||
"prepublishOnly": "npm run clean && npm test && npm run build" | ||
}, | ||
@@ -56,0 +57,0 @@ "browserslist": "> 0.5%, not dead", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
475655
141
13060