Socket
Socket
Sign inDemoInstall

js-yaml

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-yaml - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

.travis.yml

16

demo/js/base64.js

@@ -80,17 +80,17 @@ // Base64 encoder/decoder with UTF-8 support

function utf8Decode(bytes) {
var chars = [], offset = 0, length = bytes.length, c, c2, c3;
var chars = [], offset = 0, length = bytes.length, c1, c2, c3;
while (offset < length) {
c = bytes[offset];
c1 = bytes[offset];
c2 = bytes[offset + 1];
c3 = bytes[offset + 2];
if (128 > c) {
chars.push(String.fromCharCode(c));
if (128 > c1) {
chars.push(String.fromCharCode(c1));
offset += 1;
} else if (191 < c && c < 224) {
chars.push(String.fromCharCode(((c & 31) << 6) | (c2 & 63)));
} else if (191 < c1 && c1 < 224) {
chars.push(String.fromCharCode(((c1 & 31) << 6) | (c2 & 63)));
offset += 2;
} else {
chars.push(String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
chars.push(String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)));
offset += 3;

@@ -143,3 +143,3 @@ }

// Convert one by one.
for (idx = 0; idx < data.length; idx++) {
for (idx = 0; idx < data.length; idx += 1) {
code = data.charCodeAt(idx);

@@ -146,0 +146,0 @@ value = binTable[code & 0x7F];

window.runDemo = function runDemo() {
'use strict';
var source, result, initial, permalink, timer1, timer2 = null,

@@ -54,3 +56,3 @@ hash = location.hash.toString();

if (evt.type == 'keyup') {
if (evt.type === 'keyup') {
window.clearTimeout(timer1);

@@ -57,0 +59,0 @@ timer1 = window.setTimeout(parse, 500);

@@ -0,3 +1,14 @@

0.3.2 / 2011-12-16
------------------
* Fixes ug with block style scalars. Closes #26.
* All sources are passing JSLint now.
* Fixes bug in Safari. Closes #28.
* Fixes bug in Opers. Closes #29.
* Improves browser support. Closes #20.
* Added jsyaml executable.
* Added !!js/function support. Closes #12.
0.3.1 / 2011-11-18
---------
------------------

@@ -4,0 +15,0 @@ * Added AMD support for browserified version.

'use strict';
var fs = require('fs'),
_loader = require('./js-yaml/loader');
var fs = require('fs');
var _loader = require('./js-yaml/loader');

@@ -12,3 +12,5 @@

jsyaml.scan = function scan(stream, callback, Loader) {
var loader = new (Loader || _loader.SafeLoader)(stream);
Loader = (Loader || _loader.SafeLoader);
var loader = new Loader(stream);
while (loader.checkToken()) {

@@ -21,3 +23,5 @@ callback(loader.getToken());

jsyaml.compose = function compose(stream, Loader) {
var loader = new (Loader || _loader.SafeLoader)(stream);
Loader = (Loader || _loader.SafeLoader);
var loader = new Loader(stream);
return loader.getSingleNode();

@@ -28,3 +32,5 @@ };

jsyaml.load = function load(stream, Loader) {
var loader = new (Loader || _loader.Loader)(stream);
Loader = (Loader || _loader.Loader);
var loader = new Loader(stream);
return loader.getSingleData();

@@ -35,4 +41,5 @@ };

jsyaml.loadAll = function loadAll(stream, callback, Loader) {
var loader = new (Loader || _loader.Loader)(stream);
Loader = (Loader || _loader.Loader);
var loader = new Loader(stream);
while (loader.checkData()) {

@@ -70,3 +77,3 @@ callback(loader.getData());

var fd = fs.openSync(filename, 'r');
// fill in documents

@@ -73,0 +80,0 @@ module.exports = [];

'use strict';
var $$ = require('./core'),
_nodes = require('./nodes'),
_events = require('./events'),
_errors = require('./errors');
var $$ = require('./common');
var _nodes = require('./nodes');
var _events = require('./events');
var _errors = require('./errors');

@@ -119,3 +119,3 @@

var event, tag, node;
event = this.getEvent();

@@ -156,3 +156,3 @@ tag = event.tag;

if (null !== anchor) {
this.anchors[anchor] = node;
this.anchors[anchor] = node;
}

@@ -190,3 +190,3 @@

if (null !== anchor) {
this.anchors[anchor] = node;
this.anchors[anchor] = node;
}

@@ -193,0 +193,0 @@

'use strict';
var $$ = require('./core'),
_errors = require('./errors'),
_nodes = require('./nodes');
var $$ = require('./common');
var _errors = require('./errors');
var _nodes = require('./nodes');

@@ -76,4 +76,6 @@

var data = this.constructObject(node),
statePopulators;
stateIterator, statePopulators;
stateIterator = function (populator) { populator.execute(); };
while (!!this.statePopulators.length) {

@@ -83,5 +85,3 @@ statePopulators = this.statePopulators;

statePopulators.forEach(function (populator) {
populator.execute();
});
statePopulators.forEach(stateIterator);
}

@@ -253,4 +253,23 @@

SafeConstructor.prototype.flattenMapping = function flattenMapping(node) {
var merge = [], index = 0, keyNode, valueNode, submerge;
var self = this, merge = [], index = 0, keyNode, valueNode, submerge,
pushSingleValue, pushMultipleValues, submergeIterator;
pushSingleValue = function (value) {
merge.push(value);
};
pushMultipleValues = function (values) {
values.forEach(pushSingleValue);
};
submergeIterator = function (subnode) {
if (!$$.isInstanceOf(subnode, _nodes.MappingNode)) {
throw new ConstructorError("while constructing a mapping", node.startMark,
"expected a mapping for merging, but found " + subnode.id,
subnode.startMark);
}
self.flattenMapping(subnode);
submerge.push(subnode.value);
};
while (index < node.value.length) {

@@ -264,23 +283,8 @@ keyNode = node.value[index][0];

if ($$.isInstanceOf(valueNode, _nodes.MappingNode)) {
this.flattenMapping(valueNode);
$$.each(valueNode.value, function (value) {
merge.push(value);
});
self.flattenMapping(valueNode);
$$.each(valueNode.value, pushSingleValue);
} else if ($$.isInstanceOf(valueNode, _nodes.SequenceNode)) {
submerge = [];
$$.each(valueNode.value, function (subnode) {
if (!$$.isInstanceOf(subnode, _nodes.MappingNode)) {
throw new ConstructorError("while constructing a mapping", node.startMark,
"expected a mapping for merging, but found " + subnode.id,
subnode.startMark);
}
this.flattenMapping(subnode);
submerge.push(subnode.value);
}.bind(this));
$$.reverse(submerge).forEach(function (values) {
values.forEach(function (value) {
merge.push(value);
});
});
$$.each(valueNode.value, submergeIterator);
$$.reverse(submerge).forEach(pushMultipleValues);
} else {

@@ -293,5 +297,5 @@ throw new ConstructorError("while constructing a mapping", node.startMark,

keyNode.tag = 'tag:yaml.org,2002:str';
index++;
index += 1;
} else {
index++;
index += 1;
}

@@ -445,3 +449,3 @@ }

SafeConstructor.prototype.constructYamlOmap = function constructYamlOmap(node) {
var omap = [];
var self = this, omap = [];
return $$.Populator(omap, function () {

@@ -468,4 +472,4 @@ if (!$$.isInstanceOf(node, _nodes.SequenceNode)) {

key = this.constructObject(subnode.value[0][0]);
value = this.constructObject(subnode.value[0][1]);
key = self.constructObject(subnode.value[0][0]);
value = self.constructObject(subnode.value[0][1]);
data = Object.create(null);

@@ -476,8 +480,8 @@

omap.push(data);
}.bind(this));
}, this);
});
});
};
SafeConstructor.prototype.constructYamlPairs = function constructYamlPairs(node) {
var pairs = [];
var self = this, pairs = [];
return $$.Populator(pairs, function () {

@@ -504,8 +508,8 @@ if (!$$.isInstanceOf(node, _nodes.SequenceNode)) {

key = this.constructObject(subnode.value[0][0]);
value = this.constructObject(subnode.value[0][1]);
key = self.constructObject(subnode.value[0][0]);
value = self.constructObject(subnode.value[0][1]);
pairs.push([key, value]);
}.bind(this));
}, this);
});
});
};

@@ -629,2 +633,8 @@

Constructor.prototype.constructJavascriptFunction = function constructJavascriptFunction(node) {
/*jslint evil:true*/
var func = new Function('return ' + this.constructScalar(node));
return func();
};
Constructor.addConstructor(

@@ -638,3 +648,7 @@ 'tag:yaml.org,2002:js/undefined',

Constructor.addConstructor(
'tag:yaml.org,2002:js/function',
Constructor.prototype.constructJavascriptFunction);
module.exports.BaseConstructor = BaseConstructor;

@@ -641,0 +655,0 @@ module.exports.SafeConstructor = SafeConstructor;

'use strict';
var $$ = require('./core');
var $$ = require('./common');

@@ -9,3 +9,3 @@

var result = '', i;
for (i = 0; i < n; i++) {
for (i = 0; i < n; i += 1) {
result += str;

@@ -39,4 +39,4 @@ }

while (start > 0 && -1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.buffer[start - 1])) {
start--;
while (start > 0 && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer[start - 1])) {
start -= 1;
if (this.pointer - start > (maxLength / 2 - 1)) {

@@ -52,4 +52,4 @@ head = ' ... ';

while (end < this.buffer.length && -1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.buffer[end])) {
end++;
while (end < this.buffer.length && -1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer[end])) {
end += 1;
if (end - this.pointer > (maxLength / 2 - 1)) {

@@ -65,11 +65,12 @@ tail = ' ... ';

return repeat(' ', indent) + head + snippet + tail + '\n' +
repeat(' ', indent + this.pointer - start + head.length) + '^';
repeat(' ', indent + this.pointer - start + head.length) + '^';
};
Mark.prototype.toString = function () {
var snippet = this.getSnippet(),
where = ' in "' + this.name +
'", line ' + (this.line + 1) +
', column ' + (this.column + 1);
var snippet = this.getSnippet(), where;
where = ' in "' + this.name +
'", line ' + (this.line + 1) +
', column ' + (this.column + 1);
if (snippet) {

@@ -128,3 +129,3 @@ where += ':\n' + snippet;

return lines.join('\n');
}
};
}

@@ -131,0 +132,0 @@ $$.inherits(MarkedYAMLError, YAMLError);

'use strict';
var $$ = require('./core');
var $$ = require('./common');

@@ -15,11 +15,10 @@

Event.prototype.hash =
Event.prototype.toString = function toString() {
var values = [];
Event.prototype.hash = Event.prototype.toString = function toString() {
var self = this, values = [];
Object.getOwnPropertyNames(this).forEach(function (key) {
if (0 <= HASHIFY_KEYS.indexOf(key)) {
values.push(key + '=' + this[key]);
values.push(key + '=' + self[key]);
}
}.bind(this));
});

@@ -26,0 +25,0 @@ return this.constructor.name + '(' + values.join(', ') + ')';

'use strict';
var $$ = require('./core'),
_reader = require('./reader'),
_scanner = require('./scanner'),
_parser = require('./parser'),
_composer = require('./composer'),
_resolver = require('./resolver'),
_constructor = require('./constructor');
var $$ = require('./common');
var _reader = require('./reader');
var _scanner = require('./scanner');
var _parser = require('./parser');
var _composer = require('./composer');
var _resolver = require('./resolver');
var _constructor = require('./constructor');

@@ -12,0 +12,0 @@

'use strict';
var $$ = require('./core');
var $$ = require('./common');

@@ -6,0 +6,0 @@

@@ -65,6 +65,6 @@ // The following YAML grammar is LL(1) and is parsed by a recursive descent

var $$ = require('./core'),
_errors = require('./errors'),
_tokens = require('./tokens'),
_events = require('./events');
var $$ = require('./common');
var _errors = require('./errors');
var _tokens = require('./tokens');
var _events = require('./events');

@@ -114,3 +114,3 @@

for (i = 0; i < arguments.length; i++) {
for (i = 0; i < arguments.length; i += 1) {
if ($$.isInstanceOf(this.currentEvent, arguments[i])) {

@@ -117,0 +117,0 @@ return true;

'use strict';
var fs = require('fs'),
$$ = require('./core'),
_errors = require('./errors');
var fs = require('fs');
var $$ = require('./common');
var _errors = require('./errors');
var NON_PRINTABLE = new RegExp('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]');
// "\x20-\x7E" -> " -~" for JSLint
var NON_PRINTABLE = new RegExp('[^\x09\x0A\x0D -~\x85\xA0-\uD7FF\uE000-\uFFFD]');

@@ -23,4 +24,4 @@

this.toString = function toString() {
return 'unacceptable character ' + this.character + ': ' + this.reason +
'\n in "' + this.name + '", position ' + this.position;
return 'unacceptable character ' + this.character + ': ' + this.reason +
'\n in "' + this.name + '", position ' + this.position;
};

@@ -47,3 +48,3 @@ }

this.checkPrintable(stream);
this.buffer = stream + '\0';
this.buffer = stream + '\x00';
} else if (Buffer.isBuffer(stream)) { // buffer

@@ -98,14 +99,14 @@ this.name = '<buffer>';

ch = this.buffer[this.pointer];
this.pointer++;
this.index++;
this.pointer += 1;
this.index += 1;
if (0 <= '\n\x85\u2028\u2029'.indexOf(ch)
|| ('\r' === ch && '\n' !== this.buffer[this.pointer])) {
this.line++;
this.line += 1;
this.column = 0;
} else if (ch !== '\uFEFF') {
this.column++;
this.column += 1;
}
length--;
length -= 1;
}

@@ -156,3 +157,3 @@ };

if (this.eof) {
this.buffer += '\0';
this.buffer += '\x00';
this.rawBuffer = null;

@@ -165,6 +166,6 @@ break;

Reader.prototype.updateRaw = function updateRaw(size) {
var data = new Buffer(+size || 4096),
count = fs.readSync(this.stream, data, 0, data.length),
tmp;
var data = new Buffer(+size || 4096), count, tmp;
count = fs.readSync(this.stream, data, 0, data.length);
if (null === this.rawBuffer) {

@@ -171,0 +172,0 @@ this.rawBuffer = data.slice(0, count);

'use strict';
var $$ = require('./core'),
_nodes = require('./nodes');
var $$ = require('./common');
var _nodes = require('./nodes');
var DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str',
DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq',
DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map';
var DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str';
var DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq';
var DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map';

@@ -21,2 +21,4 @@

BaseResolver.addImplicitResolver = function addImplicitResolver(tag, regexp, first) {
var self = this;
if (undefined === first) {

@@ -27,8 +29,8 @@ first = [null];

first.forEach(function (ch) {
if (undefined === this.yamlImplicitResolvers[ch]) {
this.yamlImplicitResolvers[ch] = [];
if (undefined === self.yamlImplicitResolvers[ch]) {
self.yamlImplicitResolvers[ch] = [];
}
this.yamlImplicitResolvers[ch].push([tag, regexp]);
}.bind(this));
self.yamlImplicitResolvers[ch].push([tag, regexp]);
});
};

@@ -48,3 +50,3 @@

for (i = 0; i < resolvers.length; i++) {
for (i = 0; i < resolvers.length; i += 1) {
tag = resolvers[i][0];

@@ -51,0 +53,0 @@ regexp = resolvers[i][1];

@@ -30,9 +30,9 @@ // Scanner produces tokens of the following types:

var $$ = require('./core'),
_errors = require('./errors'),
_tokens = require('./tokens');
var $$ = require('./common');
var _errors = require('./errors');
var _tokens = require('./tokens');
var ESCAPE_REPLACEMENTS = {
'0': '\0',
'0': '\x00',
'a': '\x07',

@@ -47,3 +47,3 @@ 'b': '\x08',

'e': '\x1B',
' ': '\x20',
' ': ' ', // \x20, but JSLint against it :))
'\"': '\"',

@@ -71,4 +71,6 @@ '\\': '\\',

while (count--) {
result.push(start++);
while (0 < count) {
result.push(start);
count -= 1;
start += 1;
}

@@ -79,2 +81,3 @@

function ScannerError() {

@@ -173,3 +176,3 @@ _errors.MarkedYAMLError.apply(this, arguments);

for (i = 0; i < arguments.length; i++) {
for (i = 0; i < arguments.length; i += 1) {
if ($$.isInstanceOf(this.tokens[0], arguments[i])) {

@@ -252,3 +255,3 @@ return true;

// Is it the end of stream?
if (ch === '\0') {
if (ch === '\x00') {
return this.fetchStreamEnd();

@@ -573,3 +576,3 @@ }

// Increase the flow level.
this.flowLevel++;
this.flowLevel += 1;

@@ -602,3 +605,3 @@ // Simple keys are allowed after '[' and '{'.

// Decrease the flow level.
this.flowLevel--;
this.flowLevel -= 1;

@@ -860,3 +863,3 @@ // No simple keys after ']' or '}'.

if (+this.column === 0 && this.prefix(3) === '---') {
return (0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3)));
return (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3)));
}

@@ -870,3 +873,3 @@

if (+this.column === 0 && this.prefix(3) === '...') {
return (0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3)));
return (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3)));
}

@@ -879,3 +882,3 @@

// BLOCK-ENTRY: '-' (' '|'\n')
return (0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1)));
return (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1)));
};

@@ -890,3 +893,3 @@

// KEY(block context): '?' (' '|'\n')
return 0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1));
return 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1));
};

@@ -901,3 +904,3 @@

// VALUE(block context): ':' (' '|'\n')
return 0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1));
return 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1));
};

@@ -920,6 +923,6 @@

return (
-1 === '\0 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'.indexOf(ch)
-1 === '\x00 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'.indexOf(ch)
||
(
-1 === '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1))
-1 === '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1))
&&

@@ -965,3 +968,3 @@ (

if (this.peek() === '#') {
while (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
while (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
this.forward();

@@ -999,3 +1002,3 @@ }

while (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
while (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
this.forward();

@@ -1017,3 +1020,3 @@ }

while (/^[0-9A-Za-z]/.test(ch) || 0 <= '-_'.indexOf(ch)) {
length++;
length += 1;
ch = this.peek(length);

@@ -1032,3 +1035,3 @@ }

if (-1 === '\0 \r\n\x85\u2028\u2029'.indexOf(ch)) {
if (-1 === '\x00 \r\n\x85\u2028\u2029'.indexOf(ch)) {
throw new ScannerError("while scanning a directive", startMark,

@@ -1063,3 +1066,3 @@ "expected alphabetic or numeric character, but found " + ch,

if (-1 === '\0 \r\n\x85\u2028\u2029'.indexOf(this.peek())) {
if (-1 === '\x00 \r\n\x85\u2028\u2029'.indexOf(this.peek())) {
throw new ScannerError("while scanning a directive", startMark,

@@ -1088,3 +1091,3 @@ "expected a digit or ' ', but found " + this.peek(),

while (/^[0-9]/.test(this.peek(length))) {
length++;
length += 1;
}

@@ -1139,3 +1142,3 @@

if (-1 === '\0 \r\n\x85\u2028\u2029'.indexOf(ch)) {
if (-1 === '\x00 \r\n\x85\u2028\u2029'.indexOf(ch)) {
throw new ScannerError("while scanning a directive", startMark,

@@ -1157,3 +1160,3 @@ "expected ' ', but found " + ch, this.getMark());

if (this.peek() === '#') {
while (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
while (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
this.forward();

@@ -1165,3 +1168,3 @@ }

if (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(ch)) {
if (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(ch)) {
throw new ScannerError("while scanning a directive", startMark,

@@ -1196,3 +1199,3 @@ "expected a comment or a line break, but found " + ch,

while (/^[0-9A-Za-z]/.test(ch) || 0 <= '-_'.indexOf(ch)) {
length++;
length += 1;
ch = this.peek(length);

@@ -1211,3 +1214,3 @@ }

if (-1 === '\0 \t\r\n\x85\u2028\u2029?:,]}%@`'.indexOf(ch)) {
if (-1 === '\x00 \t\r\n\x85\u2028\u2029?:,]}%@`'.indexOf(ch)) {
throw new ScannerError("while scanning an " + name, startMark,

@@ -1240,3 +1243,3 @@ "expected alphabetic or numeric character, but found " + ch,

this.forward();
} else if (0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(ch)) {
} else if (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(ch)) {
handle = null;

@@ -1250,3 +1253,3 @@ suffix = '!';

while (-1 === '\0 \r\n\x85\u2028\u2029'.indexOf(ch)) {
while (-1 === '\x00 \r\n\x85\u2028\u2029'.indexOf(ch)) {
if (ch === '!') {

@@ -1257,3 +1260,3 @@ useHandle = true;

length++;
length += 1;
ch = this.peek(length);

@@ -1274,3 +1277,3 @@ }

if (-1 === '\0 \r\n\x85\u2028\u2029'.indexOf(ch)) {
if (-1 === '\x00 \r\n\x85\u2028\u2029'.indexOf(ch)) {
throw new ScannerError("while scanning a tag", startMark,

@@ -1323,3 +1326,3 @@ "expected ' ', but found " + ch, this.getMark());

// Scan the inner part of the block scalar.
while (+this.column === indent && this.peek() !== '\0') {
while (+this.column === indent && this.peek() !== '\x00') {
chunks = chunks.concat(breaks);

@@ -1329,4 +1332,4 @@ leadingNonSpace = -1 === ' \t'.indexOf(this.peek());

while (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.peek(length))) {
length++;
while (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.peek(length))) {
length += 1;
}

@@ -1342,3 +1345,3 @@

if (+this.column !== indent || this.peek() === '\0') {
if (+this.column !== indent || this.peek() === '\x00') {
break;

@@ -1350,5 +1353,5 @@ }

// This is the folding according to the specification:
if (folded && lineBreak === '\n' && leadingNonSpace && -1 === ' \t'.indexOf(this.peek())) {
if (!breaks) {
if (!breaks || !breaks.length) {
chunks.push(' ');

@@ -1423,3 +1426,3 @@ }

if (-1 === '\0 \r\n\x85\u2028\u2029'.indexOf(ch)) {
if (-1 === '\x00 \r\n\x85\u2028\u2029'.indexOf(ch)) {
throw new ScannerError("while scanning a block scalar", startMark,

@@ -1442,3 +1445,3 @@ "expected chomping or indentation indicators, but found " + ch,

if (this.peek() === '#') {
while (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
while (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(this.peek())) {
this.forward();

@@ -1450,3 +1453,3 @@ }

if (-1 === '\0\r\n\x85\u2028\u2029'.indexOf(ch)) {
if (-1 === '\x00\r\n\x85\u2028\u2029'.indexOf(ch)) {
throw new ScannerError("while scanning a block scalar", startMark,

@@ -1532,11 +1535,11 @@ "expected a comment or a line break, but found " + ch,

Scanner.prototype.scanFlowScalarNonSpaces = function scanFlowScalarNonSpaces(double, startMark) {
var chunks, length, ch, code, validator;
var self = this, chunks, length, ch, code, validator;
validator = function (k) {
if (-1 === '0123456789ABCDEFabcdef'.indexOf(this.peek(k))) {
if (-1 === '0123456789ABCDEFabcdef'.indexOf(self.peek(k))) {
throw new ScannerError("while scanning a double-quoted scalar", startMark,
"expected escape sequence of " + length + " hexdecimal numbers, but found " + this.peek(k),
this.getMark());
"expected escape sequence of " + length + " hexdecimal numbers, but found " + self.peek(k),
self.getMark());
}
}.bind(this);
};

@@ -1548,4 +1551,4 @@ // See the specification for details.

while (-1 === '\'\"\\\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length))) {
length++;
while (-1 === '\'\"\\\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length))) {
length += 1;
}

@@ -1600,3 +1603,3 @@

while (0 <= ' \t'.indexOf(this.peek(length))) {
length++;
length += 1;
}

@@ -1608,3 +1611,3 @@

if (ch === '\0') {
if (ch === '\x00') {
throw new ScannerError("while scanning a quoted scalar", startMark,

@@ -1640,3 +1643,3 @@ "found unexpected end of stream", this.getMark());

if ((prefix === '---' || prefix === '...') && 0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
if ((prefix === '---' || prefix === '...') && 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
throw new ScannerError("while scanning a quoted scalar", startMark,

@@ -1688,5 +1691,5 @@ "found unexpected document separator", this.getMark());

if (0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(ch)
if (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(ch)
|| (!this.flowLevel && ch === ':'
&& 0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length + 1)))
&& 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length + 1)))
|| (this.flowLevel && 0 <= ',:?[]{}'.indexOf(ch))) {

@@ -1700,3 +1703,3 @@ break;

// It's not clear what we should do with ':' in the flow context.
if (this.flowLevel && ch === ':' && -1 === '\0 \t\r\n\x85\u2028\u2029,[]{}'.indexOf(this.peek(length + 1))) {
if (this.flowLevel && ch === ':' && -1 === '\x00 \t\r\n\x85\u2028\u2029,[]{}'.indexOf(this.peek(length + 1))) {
this.forward(length);

@@ -1740,3 +1743,3 @@ throw new ScannerError("while scanning a plain scalar", startMark,

while (this.peek(length) === ' ') {
length++;
length += 1;
}

@@ -1754,3 +1757,3 @@

if ((prefix === '---' || prefix === '...')
&& 0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
&& 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
return;

@@ -1769,3 +1772,3 @@ }

if ((prefix === '---' || prefix === '...')
&& 0 <= '\0 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
&& 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
return;

@@ -1809,3 +1812,3 @@ }

while (/^[0-9A-Za-z]/.test(ch) || 0 <= '-_'.indexOf(ch)) {
length++;
length += 1;
ch = this.peek(length);

@@ -1820,3 +1823,3 @@ }

length++;
length += 1;
}

@@ -1847,3 +1850,3 @@

} else {
length++;
length += 1;
}

@@ -1869,3 +1872,3 @@

Scanner.prototype.scanUriEscapes = function scanUriEscapes(name, startMark) {
var codes, mark, value, validator;
var self = this, codes, mark, value, validator;

@@ -1877,8 +1880,8 @@ // See the specification for details.

validator = function (k) {
if (-1 === '0123456789ABCDEFabcdef'.indexOf(this.peek(k))) {
if (-1 === '0123456789ABCDEFabcdef'.indexOf(self.peek(k))) {
throw new ScannerError("while scanning a " + name, startMark,
"expected URI escape sequence of 2 hexdecimal numbers, but found " + this.peek(k),
this.getMark());
"expected URI escape sequence of 2 hexdecimal numbers, but found " + self.peek(k),
self.getMark());
}
}.bind(this);
};

@@ -1885,0 +1888,0 @@ while (this.peek() === '%') {

'use strict';
var $$ = require('./core');
var $$ = require('./common');

@@ -6,0 +6,0 @@

{
"name" : "js-yaml",
"version" : "0.3.1",
"version" : "0.3.2",
"description" : "YAML 1.1 Parser",

@@ -14,5 +14,12 @@ "keywords" : ["yaml", "parser", "pyyaml"],

"bin" : { "jsyaml": "bin/js-yaml.js" },
"main" : "./index.js",
"scripts" : {
"test" : "make test"
},
"engines" : { "node": "> 0.4.11 < 0.7.0" }
"devDependencies" : {
"jslint" : "https://github.com/reid/node-jslint/tarball/6131ebf5713274871b89735105e3286131804771"
},
"engines" : { "node": "> 0.4.11" }
}
JS-YAML - YAML 1.1 parser for JavaScript
========================================
[![Build Status](https://secure.travis-ci.org/nodeca/js-yaml.png)](http://travis-ci.org/nodeca/js-yaml)
[Online Demo](http://nodeca.github.com/js-yaml/)

@@ -17,2 +19,13 @@

You can install JS-YAML globally (with `-g` npm argument), and use it to inspect
your YAML files:
```
$ jsyaml /home/ixti/example.yml
---------------------------------------------------------------------------
{ jsyaml: 'rocks!' }
...........................................................................
```
### bundled YAML library for browser

@@ -105,2 +118,14 @@

### safeLoad (string|buffer|file\_resource)
Same as `load()` but uses _safe_ schema - only recommended tags of YAML
specification (no JavaScript-specific tags, e.g. `!!js/regexp`).
### safeLoadAll (string|buffer|file\_resource, iterator)
Same as `loadAll()` but uses _safe_ schema - only recommended tags of YAML
specification (no JavaScript-specific tags, e.g. `!!js/regexp`).
## JavaScript YAML tags scheme

@@ -129,8 +154,7 @@

```
!!js/regexp /pattern/gim # RegExp
!!js/undefined '' # Undefined
!!js/regexp /pattern/gim # RegExp
!!js/undefined '' # Undefined
!!js/function 'function () {...}' # Function
```
More JavaScript-specific YAML tags will be availble soon: (`function`).
### Caveats

@@ -137,0 +161,0 @@

@@ -5,3 +5,3 @@ var fs = require('fs'),

helper = require(__dirname + '/../test-helper'),
$$ = require(__dirname + '/../../lib/js-yaml/core'),
$$ = require(__dirname + '/../../lib/js-yaml/common'),
_errors = require(__dirname + '/../../lib/js-yaml/errors'),

@@ -8,0 +8,0 @@ _composer = require(__dirname + '/../../lib/js-yaml/composer'),

@@ -6,3 +6,3 @@ var suite = module.exports = [],

helper = require(__dirname + '/../test-helper'),
$$ = require(__dirname + '/../../lib/js-yaml/core'),
$$ = require(__dirname + '/../../lib/js-yaml/common'),
_errors = require(__dirname + '/../../lib/js-yaml/errors');

@@ -9,0 +9,0 @@

@@ -6,3 +6,3 @@ var suite = module.exports = [],

helper = require(__dirname + '/../test-helper'),
$$ = require(__dirname + '/../../lib/js-yaml/core'),
$$ = require(__dirname + '/../../lib/js-yaml/common'),
_errors = require(__dirname + '/../../lib/js-yaml/errors');

@@ -9,0 +9,0 @@

@@ -6,3 +6,3 @@ var suite = module.exports = [],

helper = require(__dirname + '/../test-helper'),
$$ = require(__dirname + '/../../lib/js-yaml/core'),
$$ = require(__dirname + '/../../lib/js-yaml/common'),
_nodes = require(__dirname + '/../../lib/js-yaml/nodes');

@@ -9,0 +9,0 @@

@@ -6,3 +6,3 @@ var test = module.exports = {},

helper = require(__dirname + '/../test-helper'),
$$ = require(__dirname + '/../../lib/js-yaml/core'),
$$ = require(__dirname + '/../../lib/js-yaml/common'),
_tokens = require(__dirname + '/../../lib/js-yaml/tokens');

@@ -9,0 +9,0 @@

@@ -7,3 +7,3 @@ // stdlib

// internal
var $$ = require(__dirname + '/../lib/js-yaml/core');
var $$ = require(__dirname + '/../lib/js-yaml/common');

@@ -140,2 +140,5 @@

' F:' + stats.fail + ' E:' + stats.error));
// set correct error code on exit
process.exit((stats.warn + stats.fail + stats.error) > 0 ? 1 : 0);
};

@@ -142,0 +145,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc