diff --git a/lib/js-yaml/loader.js b/lib/js-yaml/loader.js index da757ee7..2a244aaf 100644 --- a/lib/js-yaml/loader.js +++ b/lib/js-yaml/loader.js @@ -1,6 +1,6 @@ 'use strict'; -/*eslint-disable max-len,no-use-before-define,no-unused-vars*/ +/*eslint-disable max-len,no-use-before-define*/ var common = require('./common'); var YAMLException = require('./exception'); @@ -949,7 +949,7 @@ function readBlockScalar(state, nodeIndent) { function readBlockSequence(state, nodeIndent) { var _line, - _pos, + //_pos, _tag = state.tag, _anchor = state.anchor, _result = [], @@ -987,7 +987,7 @@ function readBlockSequence(state, nodeIndent) { } _line = state.line; - _pos = state.position; + //_pos = state.position; composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); //addMetaInformation(state, _result, keyNode, _line, _pos); _result.push(state.result); @@ -1478,8 +1478,6 @@ function readDocument(state) { var _position, iterator, doc, - index, - length, directiveName, directiveArgs, hasDirectives = false, @@ -1574,6 +1572,9 @@ function readDocument(state) { iterator = state.documentListener; var expectAnotherYamlChunk = false; if (iterator) { + if (typeof iterator !== 'function') { + throwError(state, 'document listener (iterator) must be a FUNCTION or NULL, not a ' + typeof iterator); + } expectAnotherYamlChunk = !!iterator(doc, state.documents.length - 1, state); if (expectAnotherYamlChunk) { skipSeparationSpace(state, true, -1); @@ -1581,7 +1582,6 @@ function readDocument(state) { } if (state.position === state.lineStart && testDocumentSeparator(state)) { - if (state.input.charCodeAt(state.position) === 0x2E/* . */) { state.position += 3; skipSeparationSpace(state, true, -1); @@ -1651,11 +1651,8 @@ function load(input, options) { } -function safeLoadAll(input, output, options) { - if (typeof output !== 'function') { - output = null; - } - return loadAll(input, output, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); +function safeLoadAll(input, iterator, options) { + return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options)); }