js-yaml
Advanced tools
Comparing version 3.2.7 to 3.3.0
@@ -6,3 +6,5 @@ #!/usr/bin/env node | ||
/*eslint-disable no-console*/ | ||
// stdlib | ||
@@ -30,3 +32,3 @@ var fs = require('fs'); | ||
cli.addArgument(['-c', '--compact'], { | ||
cli.addArgument([ '-c', '--compact' ], { | ||
help: 'Display errors in compact mode', | ||
@@ -39,3 +41,3 @@ action: 'storeTrue' | ||
// option suppressed, but not completely removed for compatibility | ||
cli.addArgument(['-j', '--to-json'], { | ||
cli.addArgument([ '-j', '--to-json' ], { | ||
help: argparse.Const.SUPPRESS, | ||
@@ -47,3 +49,3 @@ dest: 'json', | ||
cli.addArgument(['-t', '--trace'], { | ||
cli.addArgument([ '-t', '--trace' ], { | ||
help: 'Show stack trace on error', | ||
@@ -53,3 +55,3 @@ action: 'storeTrue' | ||
cli.addArgument(['file'], { | ||
cli.addArgument([ 'file' ], { | ||
help: 'File to read, utf-8 encoded without BOM', | ||
@@ -75,7 +77,7 @@ nargs: '?', | ||
process.stdin.on('data', function(chunk) { | ||
process.stdin.on('data', function (chunk) { | ||
chunks.push(chunk); | ||
}); | ||
process.stdin.on('end', function() { | ||
process.stdin.on('end', function () { | ||
return callback(null, Buffer.concat(chunks).toString(encoding)); | ||
@@ -92,3 +94,3 @@ }); | ||
if (error) { | ||
if ('ENOENT' === error.code) { | ||
if (error.code === 'ENOENT') { | ||
console.error('File not found: ' + options.file); | ||
@@ -95,0 +97,0 @@ process.exit(2); |
@@ -0,1 +1,8 @@ | ||
3.3.0 / 2015-04-26 | ||
------------------ | ||
- Significantly improved long strings formatting in dumper, thanks to @isaacs. | ||
- Strip BOM if exists. | ||
3.2.7 / 2015-02-19 | ||
@@ -2,0 +9,0 @@ ------------------ |
'use strict'; | ||
/*eslint-disable no-console*/ | ||
@@ -4,0 +5,0 @@ var fs = require('fs'); |
'use strict'; | ||
/*eslint-disable no-console*/ | ||
@@ -4,0 +5,0 @@ var yaml = require('../lib/js-yaml'); |
'use strict'; | ||
/*eslint-disable no-console*/ | ||
@@ -4,0 +5,0 @@ var fs = require('fs'); |
@@ -5,3 +5,3 @@ 'use strict'; | ||
function isNothing(subject) { | ||
return (undefined === subject) || (null === subject); | ||
return (typeof subject === 'undefined') || (null === subject); | ||
} | ||
@@ -11,3 +11,3 @@ | ||
function isObject(subject) { | ||
return ('object' === typeof subject) && (null !== subject); | ||
return (typeof subject === 'object') && (null !== subject); | ||
} | ||
@@ -21,5 +21,4 @@ | ||
return []; | ||
} else { | ||
return [ sequence ]; | ||
} | ||
return [ sequence ]; | ||
} | ||
@@ -26,0 +25,0 @@ |
'use strict'; | ||
/*eslint-disable no-use-before-define*/ | ||
@@ -9,7 +10,5 @@ var common = require('./common'); | ||
var _toString = Object.prototype.toString; | ||
var _hasOwnProperty = Object.prototype.hasOwnProperty; | ||
var CHAR_TAB = 0x09; /* Tab */ | ||
@@ -39,3 +38,2 @@ var CHAR_LINE_FEED = 0x0A; /* LF */ | ||
var ESCAPE_SEQUENCES = {}; | ||
@@ -59,3 +57,2 @@ | ||
var DEPRECATED_BOOLEANS_SYNTAX = [ | ||
@@ -66,3 +63,2 @@ 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', | ||
function compileStyleMap(schema, map) { | ||
@@ -98,3 +94,2 @@ var result, keys, index, length, tag, style, type; | ||
function encodeHex(character) { | ||
@@ -121,3 +116,2 @@ var string, handle, length; | ||
function State(options) { | ||
@@ -140,3 +134,28 @@ this.schema = options['schema'] || DEFAULT_FULL_SCHEMA; | ||
function indentString(string, spaces) { | ||
var ind = common.repeat(' ', spaces), | ||
position = 0, | ||
next = -1, | ||
result = '', | ||
line, | ||
length = string.length; | ||
while (position < length) { | ||
next = string.indexOf('\n', position); | ||
if (next === -1) { | ||
line = string.slice(position); | ||
position = length; | ||
} else { | ||
line = string.slice(position, next + 1); | ||
position = next + 1; | ||
} | ||
if (line.length && line !== '\n') { | ||
result += ind; | ||
} | ||
result += line; | ||
} | ||
return result; | ||
} | ||
function generateNextLine(state, level) { | ||
@@ -160,79 +179,337 @@ return '\n' + common.repeat(' ', state.indent * level); | ||
function writeScalar(state, object) { | ||
var isQuoted, checkpoint, position, length, character, first; | ||
function StringBuilder(source) { | ||
this.source = source; | ||
this.result = ''; | ||
this.checkpoint = 0; | ||
} | ||
state.dump = ''; | ||
isQuoted = false; | ||
checkpoint = 0; | ||
first = object.charCodeAt(0) || 0; | ||
StringBuilder.prototype.takeUpTo = function (position) { | ||
var er; | ||
if (position < this.checkpoint) { | ||
er = new Error('position should be > checkpoint'); | ||
er.position = position; | ||
er.checkpoint = this.checkpoint; | ||
throw er; | ||
} | ||
this.result += this.source.slice(this.checkpoint, position); | ||
this.checkpoint = position; | ||
return this; | ||
}; | ||
StringBuilder.prototype.escapeChar = function () { | ||
var character, esc; | ||
character = this.source.charCodeAt(this.checkpoint); | ||
esc = ESCAPE_SEQUENCES[character] || encodeHex(character); | ||
this.result += esc; | ||
this.checkpoint += 1; | ||
return this; | ||
}; | ||
StringBuilder.prototype.finish = function () { | ||
if (this.source.length > this.checkpoint) { | ||
this.takeUpTo(this.source.length); | ||
} | ||
}; | ||
function writeScalar(state, object, level) { | ||
var simple, first, spaceWrap, folded, literal, single, double, | ||
sawLineFeed, linePosition, longestLine, indent, max, character, | ||
position, escapeSeq, hexEsc, previous, lineLength, modifier, | ||
trailingLineBreaks, result; | ||
if (0 === object.length) { | ||
state.dump = "''"; | ||
return; | ||
} | ||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) { | ||
// Ensure compatibility with YAML 1.0/1.1 loaders. | ||
isQuoted = true; | ||
} else if (0 === object.length) { | ||
// Quote empty string | ||
isQuoted = true; | ||
} else if (CHAR_SPACE === first || | ||
CHAR_SPACE === object.charCodeAt(object.length - 1)) { | ||
isQuoted = true; | ||
} else if (CHAR_MINUS === first || | ||
CHAR_QUESTION === first) { | ||
// Don't check second symbol for simplicity | ||
isQuoted = true; | ||
state.dump = "'" + object + "'"; | ||
return; | ||
} | ||
for (position = 0, length = object.length; position < length; position += 1) { | ||
simple = true; | ||
first = object.length ? object.charCodeAt(0) : 0; | ||
spaceWrap = (CHAR_SPACE === first || | ||
CHAR_SPACE === object.charCodeAt(object.length - 1)); | ||
// Simplified check for restricted first characters | ||
// http://www.yaml.org/spec/1.2/spec.html#ns-plain-first%28c%29 | ||
if (CHAR_MINUS === first || | ||
CHAR_QUESTION === first || | ||
CHAR_COMMERCIAL_AT === first || | ||
CHAR_GRAVE_ACCENT === first) { | ||
simple = false; | ||
} | ||
// can only use > and | if not wrapped in spaces. | ||
if (spaceWrap) { | ||
simple = false; | ||
folded = false; | ||
literal = false; | ||
} else { | ||
folded = true; | ||
literal = true; | ||
} | ||
single = true; | ||
double = new StringBuilder(object); | ||
sawLineFeed = false; | ||
linePosition = 0; | ||
longestLine = 0; | ||
indent = state.indent * level; | ||
max = 80; | ||
if (indent < 40) { | ||
max -= indent; | ||
} else { | ||
max = 40; | ||
} | ||
for (position = 0; position < object.length; position++) { | ||
character = object.charCodeAt(position); | ||
if (simple) { | ||
// Characters that can never appear in the simple scalar | ||
if (!simpleChar(character)) { | ||
simple = false; | ||
} else { | ||
// Still simple. If we make it all the way through like | ||
// this, then we can just dump the string as-is. | ||
continue; | ||
} | ||
} | ||
if (!isQuoted) { | ||
if (CHAR_TAB === character || | ||
CHAR_LINE_FEED === character || | ||
CHAR_CARRIAGE_RETURN === character || | ||
CHAR_COMMA === character || | ||
CHAR_LEFT_SQUARE_BRACKET === character || | ||
CHAR_RIGHT_SQUARE_BRACKET === character || | ||
CHAR_LEFT_CURLY_BRACKET === character || | ||
CHAR_RIGHT_CURLY_BRACKET === character || | ||
CHAR_SHARP === character || | ||
CHAR_AMPERSAND === character || | ||
CHAR_ASTERISK === character || | ||
CHAR_EXCLAMATION === character || | ||
CHAR_VERTICAL_LINE === character || | ||
CHAR_GREATER_THAN === character || | ||
CHAR_SINGLE_QUOTE === character || | ||
CHAR_DOUBLE_QUOTE === character || | ||
CHAR_PERCENT === character || | ||
CHAR_COMMERCIAL_AT === character || | ||
CHAR_COLON === character || | ||
CHAR_GRAVE_ACCENT === character) { | ||
isQuoted = true; | ||
if (single && character === CHAR_SINGLE_QUOTE) { | ||
single = false; | ||
} | ||
escapeSeq = ESCAPE_SEQUENCES[character]; | ||
hexEsc = needsHexEscape(character); | ||
if (!escapeSeq && !hexEsc) { | ||
continue; | ||
} | ||
if (character !== CHAR_LINE_FEED && | ||
character !== CHAR_DOUBLE_QUOTE && | ||
character !== CHAR_SINGLE_QUOTE) { | ||
folded = false; | ||
literal = false; | ||
} else if (character === CHAR_LINE_FEED) { | ||
sawLineFeed = true; | ||
single = false; | ||
if (position > 0) { | ||
previous = object.charCodeAt(position - 1); | ||
if (previous === CHAR_SPACE) { | ||
literal = false; | ||
folded = false; | ||
} | ||
} | ||
if (folded) { | ||
lineLength = position - linePosition; | ||
linePosition = position; | ||
if (lineLength > longestLine) { | ||
longestLine = lineLength; | ||
} | ||
} | ||
} | ||
if (ESCAPE_SEQUENCES[character] || | ||
!((0x00020 <= character && character <= 0x00007E) || | ||
(0x00085 === character) || | ||
(0x000A0 <= character && character <= 0x00D7FF) || | ||
(0x0E000 <= character && character <= 0x00FFFD) || | ||
(0x10000 <= character && character <= 0x10FFFF))) { | ||
state.dump += object.slice(checkpoint, position); | ||
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character); | ||
checkpoint = position + 1; | ||
isQuoted = true; | ||
if (character !== CHAR_DOUBLE_QUOTE) { | ||
single = false; | ||
} | ||
double.takeUpTo(position); | ||
double.escapeChar(); | ||
} | ||
if (checkpoint < position) { | ||
state.dump += object.slice(checkpoint, position); | ||
if (simple && testImplicitResolving(state, object)) { | ||
simple = false; | ||
} | ||
if (!isQuoted && testImplicitResolving(state, state.dump)) { | ||
isQuoted = true; | ||
modifier = ''; | ||
if (folded || literal) { | ||
trailingLineBreaks = 0; | ||
if (object.charCodeAt(object.length - 1) === CHAR_LINE_FEED) { | ||
trailingLineBreaks += 1; | ||
if (object.charCodeAt(object.length - 2) === CHAR_LINE_FEED) { | ||
trailingLineBreaks += 1; | ||
} | ||
} | ||
if (trailingLineBreaks === 0) { | ||
modifier = '-'; | ||
} else if (trailingLineBreaks === 2) { | ||
modifier = '+'; | ||
} | ||
} | ||
if (isQuoted) { | ||
state.dump = '"' + state.dump + '"'; | ||
if (literal && longestLine < max) { | ||
folded = false; | ||
} | ||
// If it's literally one line, then don't bother with the literal. | ||
// We may still want to do a fold, though, if it's a super long line. | ||
if (!sawLineFeed) { | ||
literal = false; | ||
} | ||
if (simple) { | ||
state.dump = object; | ||
} else if (single) { | ||
state.dump = '\'' + object + '\''; | ||
} else if (folded) { | ||
result = fold(object, max); | ||
state.dump = '>' + modifier + '\n' + indentString(result, indent); | ||
} else if (literal) { | ||
if (!modifier) { | ||
object = object.replace(/\n$/, ''); | ||
} | ||
state.dump = '|' + modifier + '\n' + indentString(object, indent); | ||
} else if (double) { | ||
double.finish(); | ||
state.dump = '"' + double.result + '"'; | ||
} else { | ||
throw new Error('Failed to dump scalar value'); | ||
} | ||
return; | ||
} | ||
// The `trailing` var is a regexp match of any trailing `\n` characters. | ||
// | ||
// There are three cases we care about: | ||
// | ||
// 1. One trailing `\n` on the string. Just use `|` or `>`. | ||
// This is the assumed default. (trailing = null) | ||
// 2. No trailing `\n` on the string. Use `|-` or `>-` to "chomp" the end. | ||
// 3. More than one trailing `\n` on the string. Use `|+` or `>+`. | ||
// | ||
// In the case of `>+`, these line breaks are *not* doubled (like the line | ||
// breaks within the string), so it's important to only end with the exact | ||
// same number as we started. | ||
function fold(object, max) { | ||
var result = '', | ||
position = 0, | ||
length = object.length, | ||
trailing = /\n+$/.exec(object), | ||
newLine; | ||
if (trailing) { | ||
length = trailing.index + 1; | ||
} | ||
while (position < length) { | ||
newLine = object.indexOf('\n', position); | ||
if (newLine > length || newLine === -1) { | ||
if (result) { | ||
result += '\n\n'; | ||
} | ||
result += foldLine(object.slice(position, length), max); | ||
position = length; | ||
} else { | ||
if (result) { | ||
result += '\n\n'; | ||
} | ||
result += foldLine(object.slice(position, newLine), max); | ||
position = newLine + 1; | ||
} | ||
} | ||
if (trailing && trailing[0] !== '\n') { | ||
result += trailing[0]; | ||
} | ||
return result; | ||
} | ||
function foldLine(line, max) { | ||
if (line === '') { | ||
return line; | ||
} | ||
var foldRe = /[^\s] [^\s]/g, | ||
result = '', | ||
prevMatch = 0, | ||
foldStart = 0, | ||
match = foldRe.exec(line), | ||
index, | ||
foldEnd, | ||
folded; | ||
while (match) { | ||
index = match.index; | ||
// when we cross the max len, if the previous match would've | ||
// been ok, use that one, and carry on. If there was no previous | ||
// match on this fold section, then just have a long line. | ||
if (index - foldStart > max) { | ||
if (prevMatch !== foldStart) { | ||
foldEnd = prevMatch; | ||
} else { | ||
foldEnd = index; | ||
} | ||
if (result) { | ||
result += '\n'; | ||
} | ||
folded = line.slice(foldStart, foldEnd); | ||
result += folded; | ||
foldStart = foldEnd + 1; | ||
} | ||
prevMatch = index + 1; | ||
match = foldRe.exec(line); | ||
} | ||
if (result) { | ||
result += '\n'; | ||
} | ||
// if we end up with one last word at the end, then the last bit might | ||
// be slightly bigger than we wanted, because we exited out of the loop. | ||
if (foldStart !== prevMatch && line.length - foldStart > max) { | ||
result += line.slice(foldStart, prevMatch) + '\n' + | ||
line.slice(prevMatch + 1); | ||
} else { | ||
result += line.slice(foldStart); | ||
} | ||
return result; | ||
} | ||
// Returns true if character can be found in a simple scalar | ||
function simpleChar(character) { | ||
return CHAR_TAB !== character && | ||
CHAR_LINE_FEED !== character && | ||
CHAR_CARRIAGE_RETURN !== character && | ||
CHAR_COMMA !== character && | ||
CHAR_LEFT_SQUARE_BRACKET !== character && | ||
CHAR_RIGHT_SQUARE_BRACKET !== character && | ||
CHAR_LEFT_CURLY_BRACKET !== character && | ||
CHAR_RIGHT_CURLY_BRACKET !== character && | ||
CHAR_SHARP !== character && | ||
CHAR_AMPERSAND !== character && | ||
CHAR_ASTERISK !== character && | ||
CHAR_EXCLAMATION !== character && | ||
CHAR_VERTICAL_LINE !== character && | ||
CHAR_GREATER_THAN !== character && | ||
CHAR_SINGLE_QUOTE !== character && | ||
CHAR_DOUBLE_QUOTE !== character && | ||
CHAR_PERCENT !== character && | ||
CHAR_COLON !== character && | ||
!ESCAPE_SEQUENCES[character] && | ||
!needsHexEscape(character); | ||
} | ||
// Returns true if the character code needs to be escaped. | ||
function needsHexEscape(character) { | ||
return !((0x00020 <= character && character <= 0x00007E) || | ||
(0x00085 === character) || | ||
(0x000A0 <= character && character <= 0x00D7FF) || | ||
(0x0E000 <= character && character <= 0x00FFFD) || | ||
(0x10000 <= character && character <= 0x10FFFF)); | ||
} | ||
function writeFlowSequence(state, level, object) { | ||
@@ -481,7 +758,8 @@ var _result = '', | ||
if ('?' !== state.tag) { | ||
writeScalar(state, state.dump); | ||
writeScalar(state, state.dump, level); | ||
} | ||
} else if (state.skipInvalid) { | ||
return false; | ||
} else { | ||
if (state.skipInvalid) { | ||
return false; | ||
} | ||
throw new YAMLException('unacceptable kind of an object to dump ' + type); | ||
@@ -526,4 +804,4 @@ } | ||
objects.push(object); | ||
if(Array.isArray(object)) { | ||
if (Array.isArray(object)) { | ||
for (index = 0, length = object.length; index < length; index += 1) { | ||
@@ -552,8 +830,6 @@ inspectNode(object[index], objects, duplicatesIndexes); | ||
return state.dump + '\n'; | ||
} else { | ||
return ''; | ||
} | ||
return ''; | ||
} | ||
function safeDump(input, options) { | ||
@@ -563,4 +839,3 @@ return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); | ||
module.exports.dump = dump; | ||
module.exports.safeDump = safeDump; |
'use strict'; | ||
/*eslint-disable max-len,no-use-before-define*/ | ||
@@ -62,3 +63,5 @@ var common = require('./common'); | ||
/*eslint-disable no-bitwise*/ | ||
lc = c | 0x20; | ||
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { | ||
@@ -87,3 +90,3 @@ return lc - 0x61 + 10; | ||
function simpleEscapeSequence(c) { | ||
return (c === 0x30/* 0 */) ? '\x00' : | ||
return (c === 0x30/* 0 */) ? '\x00' : | ||
(c === 0x61/* a */) ? '\x07' : | ||
@@ -111,8 +114,7 @@ (c === 0x62/* b */) ? '\x08' : | ||
return String.fromCharCode(c); | ||
} else { | ||
// Encode UTF-16 surrogate pair | ||
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF | ||
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, | ||
((c - 0x010000) & 0x03FF) + 0xDC00); | ||
} | ||
// Encode UTF-16 surrogate pair | ||
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF | ||
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800, | ||
((c - 0x010000) & 0x03FF) + 0xDC00); | ||
} | ||
@@ -183,3 +185,3 @@ | ||
'YAML': function handleYamlDirective(state, name, args) { | ||
YAML: function handleYamlDirective(state, name, args) { | ||
@@ -217,3 +219,3 @@ var match, major, minor; | ||
'TAG': function handleTagDirective(state, name, args) { | ||
TAG: function handleTagDirective(state, name, args) { | ||
@@ -378,3 +380,3 @@ var handle, prefix; | ||
state.input.charCodeAt(_position + 1) === ch && | ||
state.input.charCodeAt(_position+ 2) === ch) { | ||
state.input.charCodeAt(_position + 2) === ch) { | ||
@@ -449,3 +451,3 @@ _position += 3; | ||
if (0x3A/* : */ === ch) { | ||
following = state.input.charCodeAt(state.position+1); | ||
following = state.input.charCodeAt(state.position + 1); | ||
@@ -505,7 +507,7 @@ if (is_WS_OR_EOL(following) || | ||
return true; | ||
} else { | ||
state.kind = _kind; | ||
state.result = _result; | ||
return false; | ||
} | ||
state.kind = _kind; | ||
state.result = _result; | ||
return false; | ||
} | ||
@@ -589,3 +591,3 @@ | ||
//TODO: rework to inline fn with no type cast? | ||
// TODO: rework to inline fn with no type cast? | ||
} else if (ch < 256 && simpleEscapeCheck[ch]) { | ||
@@ -656,7 +658,7 @@ state.result += simpleEscapeMap[ch]; | ||
if (ch === 0x5B/* [ */) { | ||
terminator = 0x5D/* ] */; | ||
terminator = 0x5D;/* ] */ | ||
isMapping = false; | ||
_result = []; | ||
} else if (ch === 0x7B/* { */) { | ||
terminator = 0x7D/* } */; | ||
terminator = 0x7D;/* } */ | ||
isMapping = true; | ||
@@ -863,12 +865,7 @@ _result = {}; | ||
// Literal style: just add exact number of line breaks between content lines. | ||
} else if (detectedIndent) { | ||
// If current line isn't the first one - count line break from the last content line. | ||
state.result += common.repeat('\n', emptyLines + 1); | ||
} else { | ||
// If current line isn't the first one - count line break from the last content line. | ||
if (detectedIndent) { | ||
state.result += common.repeat('\n', emptyLines + 1); | ||
// In case of the first content line - count only empty lines. | ||
} else { | ||
state.result += common.repeat('\n', emptyLines); | ||
} | ||
} | ||
@@ -880,4 +877,5 @@ | ||
while (!is_EOL(ch) && (0 !== ch)) | ||
{ ch = state.input.charCodeAt(++state.position); } | ||
while (!is_EOL(ch) && (0 !== ch)) { | ||
ch = state.input.charCodeAt(++state.position); | ||
} | ||
@@ -948,5 +946,4 @@ captureSegment(state, captureStart, state.position, false); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
return false; | ||
} | ||
@@ -1531,6 +1528,14 @@ | ||
if (0 !== input.length && | ||
0x0A/* LF */ !== input.charCodeAt(input.length - 1) && | ||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) { | ||
input += '\n'; | ||
if (input.length !== 0) { | ||
// Add tailing `\n` if not exists | ||
if (0x0A/* LF */ !== input.charCodeAt(input.length - 1) && | ||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) { | ||
input += '\n'; | ||
} | ||
// Strip BOM | ||
if (input.charCodeAt(0) === 0xFEFF) { | ||
input = input.slice(1); | ||
} | ||
} | ||
@@ -1573,8 +1578,8 @@ | ||
if (0 === documents.length) { | ||
/*eslint-disable no-undefined*/ | ||
return undefined; | ||
} else if (1 === documents.length) { | ||
return documents[0]; | ||
} else { | ||
throw new YAMLException('expected a single document in the stream, but found more'); | ||
} | ||
throw new YAMLException('expected a single document in the stream, but found more'); | ||
} | ||
@@ -1581,0 +1586,0 @@ |
'use strict'; | ||
/*eslint-disable max-len*/ | ||
@@ -4,0 +5,0 @@ var common = require('./common'); |
'use strict'; | ||
/*eslint-disable no-bitwise*/ | ||
@@ -22,3 +23,3 @@ // A trick for browserified version. | ||
// Convert one by one. | ||
for (idx = 0; idx < max; idx ++) { | ||
for (idx = 0; idx < max; idx++) { | ||
code = map.indexOf(data.charAt(idx)); | ||
@@ -61,3 +62,3 @@ | ||
tailbits = (max % 4)*6; | ||
tailbits = (max % 4) * 6; | ||
@@ -64,0 +65,0 @@ if (tailbits === 0) { |
@@ -58,5 +58,4 @@ 'use strict'; | ||
} else { | ||
return sign * parseFloat(value, 10); | ||
} | ||
return sign * parseFloat(value, 10); | ||
} | ||
@@ -94,5 +93,4 @@ | ||
return '-0.0'; | ||
} else { | ||
return object.toString(10); | ||
} | ||
return object.toString(10); | ||
} | ||
@@ -99,0 +97,0 @@ |
@@ -41,3 +41,3 @@ 'use strict'; | ||
// 0 | ||
if (index+1 === max) { return true; } | ||
if (index + 1 === max) { return true; } | ||
ch = data[++index]; | ||
@@ -44,0 +44,0 @@ |
@@ -68,3 +68,4 @@ 'use strict'; | ||
// function expressions. So cut them out. | ||
return new Function(params, source.slice(body[0]+1, body[1]-1)); | ||
/*eslint-disable no-new-func*/ | ||
return new Function(params, source.slice(body[0] + 1, body[1] - 1)); | ||
} | ||
@@ -71,0 +72,0 @@ |
@@ -10,2 +10,3 @@ 'use strict'; | ||
function constructJavascriptUndefined() { | ||
/*eslint-disable no-undefined*/ | ||
return undefined; | ||
@@ -12,0 +13,0 @@ } |
{ | ||
"name" : "js-yaml", | ||
"version" : "3.2.7", | ||
"description" : "YAML 1.2 parser and serializer", | ||
"keywords" : ["yaml", "parser", "serializer", "pyyaml"], | ||
"homepage" : "https://github.com/nodeca/js-yaml", | ||
"author" : "Dervus Grim <dervus.grim@gmail.com>", | ||
"contributors" : [ | ||
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)", | ||
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)", | ||
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)" | ||
], | ||
"bugs" : { "url": "https://github.com/nodeca/js-yaml/issues" }, | ||
"license" : { "type": "MIT", "url": "https://github.com/nodeca/js-yaml/blob/master/LICENSE" }, | ||
"repository" : { "type": "git", "url": "git://github.com/nodeca/js-yaml.git" }, | ||
"main" : "./index.js", | ||
"bin" : { "js-yaml": "bin/js-yaml.js" }, | ||
"dependencies" : { "argparse": "~ 1.0.0", | ||
"esprima": "~ 2.0.0" }, | ||
"devDependencies" : { | ||
"ansi": "*", | ||
"benchmark": "*", | ||
"mocha": "*" | ||
}, | ||
"browser" : { | ||
"buffer": false | ||
} | ||
"name": "js-yaml", | ||
"version": "3.3.0", | ||
"description": "YAML 1.2 parser and serializer", | ||
"keywords": [ | ||
"yaml", | ||
"parser", | ||
"serializer", | ||
"pyyaml" | ||
], | ||
"homepage": "https://github.com/nodeca/js-yaml", | ||
"author": "Dervus Grim <dervus.grim@gmail.com>", | ||
"contributors": [ | ||
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)", | ||
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)", | ||
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)" | ||
], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/nodeca/js-yaml.git" | ||
}, | ||
"bin": { | ||
"js-yaml": "bin/js-yaml.js" | ||
}, | ||
"dependencies": { | ||
"argparse": "~1.0.2", | ||
"esprima": "~2.2.0" | ||
}, | ||
"devDependencies": { | ||
"ansi": "*", | ||
"benchmark": "*", | ||
"eslint": "0.18.0", | ||
"eslint-plugin-nodeca": "^1.0.3", | ||
"istanbul": "*", | ||
"mocha": "*" | ||
}, | ||
"browser": { | ||
"buffer": false | ||
}, | ||
"scripts": { | ||
"test": "make test" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
6400
0
5
2
230035
6
43
1
+ Addedesprima@2.2.0(transitive)
- Removedesprima@2.0.0(transitive)
Updatedargparse@~1.0.2
Updatedesprima@~2.2.0