Comparing version 0.3.7 to 1.0.0
@@ -0,1 +1,11 @@ | ||
1.0.0 / 2012-06-01 | ||
------------------ | ||
* `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore. | ||
Fixes #42. | ||
* `require(filename)` now returns a single document and throws an Error if | ||
file contains more than one document. | ||
* CLI was merged back from js-yaml.bin | ||
0.3.7 / 2012-02-28 | ||
@@ -2,0 +12,0 @@ ------------------ |
@@ -75,4 +75,3 @@ 'use strict'; | ||
// fill in documents | ||
module.exports = []; | ||
jsyaml.loadAll(fd, function (doc) { module.exports.push(doc); }); | ||
module.exports = jsyaml.load(fd); | ||
@@ -79,0 +78,0 @@ fs.closeSync(fd); |
@@ -140,3 +140,3 @@ 'use strict'; | ||
Composer.prototype.composeSequenceNode = function composeSequenceNode(anchor) { | ||
var start_event, event, tag, node, index, end_event; | ||
var start_event, tag, node, index, end_event; | ||
@@ -174,3 +174,3 @@ start_event = this.getEvent(); | ||
Composer.prototype.composeMappingNode = function composeMappingNode(anchor) { | ||
var startEvent, event, tag, node, itemKey, itemValue, endEvent; | ||
var startEvent, tag, node, itemKey, itemValue, endEvent; | ||
@@ -177,0 +177,0 @@ startEvent = this.getEvent(); |
@@ -186,3 +186,3 @@ 'use strict'; | ||
key = this.constructObject(key_node, deep); | ||
// TODO: Do we need to check | ||
// TODO: Do we need to check | ||
if (undefined === key_node.hash) { | ||
@@ -237,3 +237,3 @@ throw new ConstructorError("while constructing a mapping", key_node.startMark, | ||
$$.each(node.value, function (pair) { | ||
var key_node = pair[0], value_node = pair[1], value; | ||
var key_node = pair[0], value_node = pair[1]; | ||
@@ -240,0 +240,0 @@ if ('tag:yaml.org,2002:value' === key_node.tag) { |
@@ -112,7 +112,7 @@ 'use strict'; | ||
if (null !== self.contextMark | ||
&& (null === self.problem || null === self.problemMark | ||
|| self.contextMark.name !== self.problemMark.name | ||
|| self.contextMark.line !== self.problemMark.line | ||
|| self.contextMark.column !== self.problemMark.column)) { | ||
if (null !== self.contextMark && | ||
(null === self.problem || null === self.problemMark || | ||
self.contextMark.name !== self.problemMark.name || | ||
self.contextMark.line !== self.problemMark.line || | ||
self.contextMark.column !== self.problemMark.column)) { | ||
lines.push(self.contextMark.toString()); | ||
@@ -119,0 +119,0 @@ } |
@@ -554,3 +554,3 @@ // The following YAML grammar is LL(1) and is parsed by a recursive descent | ||
Parser.prototype.parseBlockMappingValue = function parseBlockMappingValue() { | ||
var token, event; | ||
var token; | ||
@@ -557,0 +557,0 @@ if (this.checkToken(_tokens.ValueToken)) { |
@@ -16,5 +16,5 @@ 'use strict'; | ||
// are running on that shit... | ||
var getSingleChar = (undefined === ('a')[0]) | ||
? function (str, pos) { return str.charAt(pos); } | ||
: function (str, pos) { return str[pos]; }; | ||
var getSingleChar = (undefined === ('a')[0]) ? | ||
function (str, pos) { return str.charAt(pos); } | ||
: function (str, pos) { return str[pos]; }; | ||
@@ -109,4 +109,4 @@ | ||
if (0 <= '\n\x85\u2028\u2029'.indexOf(ch) | ||
|| ('\r' === ch && '\n' !== this.buffer[this.pointer])) { | ||
if (0 <= '\n\x85\u2028\u2029'.indexOf(ch) || | ||
('\r' === ch && '\n' !== this.buffer[this.pointer])) { | ||
this.line += 1; | ||
@@ -113,0 +113,0 @@ this.column = 0; |
@@ -83,6 +83,4 @@ 'use strict'; | ||
Resolver.addImplicitResolver('tag:yaml.org,2002:bool', | ||
new RegExp('^(?:y|yes|Yes|YES|n|no|No|NO' + | ||
'|true|True|TRUE|false|False|FALSE' + | ||
'|on|On|ON|off|Off|OFF)$'), | ||
['y', 'Y', 'n', 'N', 't', 'T', 'f', 'F', 'o', 'O']); | ||
new RegExp('^(?:true|True|TRUE|false|False|FALSE)$'), | ||
['t', 'T', 'f', 'F']); | ||
@@ -89,0 +87,0 @@ Resolver.addImplicitResolver('tag:yaml.org,2002:float', |
@@ -23,3 +23,3 @@ // Scanner produces tokens of the following types: | ||
// SCALAR(value, plain, style) | ||
// | ||
// | ||
// Read comments in the Scanner code for more details. | ||
@@ -911,7 +911,5 @@ | ||
return ( | ||
-1 === '\x00 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'.indexOf(ch) | ||
|| | ||
-1 === '\x00 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'.indexOf(ch) || | ||
( | ||
-1 === '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1)) | ||
&& | ||
-1 === '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1)) && | ||
( | ||
@@ -1474,3 +1472,3 @@ ch === '-' || (!this.flowLevel && 0 <= '?:'.indexOf(ch)) | ||
Scanner.prototype.scanFlowScalar = function scanFlowScalar(style) { | ||
var dbl, chunks, length, code, startMark, quote, endMark; | ||
var dbl, chunks, startMark, quote, endMark; | ||
// See the specification for details. | ||
@@ -1653,6 +1651,6 @@ // Note that we loose indentation rules for quoted scalars. Quoted | ||
if (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(ch) | ||
|| (!this.flowLevel && ch === ':' | ||
&& 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length + 1))) | ||
|| (this.flowLevel && 0 <= ',:?[]{}'.indexOf(ch))) { | ||
if (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(ch) || ( | ||
!this.flowLevel && ch === ':' && | ||
0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length + 1)) | ||
) || (this.flowLevel && 0 <= ',:?[]{}'.indexOf(ch))) { | ||
break; | ||
@@ -1684,4 +1682,4 @@ } | ||
if (!Array.isArray(spaces) || !spaces.length || this.peek() === '#' | ||
|| (!this.flowLevel && this.column < indent)) { | ||
if (!Array.isArray(spaces) || !spaces.length || this.peek() === '#' || | ||
(!this.flowLevel && this.column < indent)) { | ||
break; | ||
@@ -1717,4 +1715,4 @@ } | ||
if ((prefix === '---' || prefix === '...') | ||
&& 0 <= '\x00 \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))) { | ||
return; | ||
@@ -1732,4 +1730,4 @@ } | ||
if ((prefix === '---' || prefix === '...') | ||
&& 0 <= '\x00 \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))) { | ||
return; | ||
@@ -1736,0 +1734,0 @@ } |
{ | ||
"name" : "js-yaml", | ||
"version" : "0.3.7", | ||
"version" : "1.0.0", | ||
"description" : "YAML 1.1 Parser", | ||
@@ -22,11 +22,9 @@ "keywords" : ["yaml", "parser", "pyyaml"], | ||
"main" : "./index.js", | ||
"scripts" : { | ||
"test" : "make test" | ||
}, | ||
"devDependencies" : { | ||
"vows" : "~ 0.6.0", | ||
"jslint" : "https://github.com/reid/node-jslint/tarball/6131ebf5713274871b89735105e3286131804771" | ||
}, | ||
"engines" : { "node": "> 0.4.11" } | ||
"bin" : { "js-yaml": "bin/js-yaml.js" }, | ||
"scripts" : { "test": "make test" }, | ||
"dependencies" : { "argparse": "~ 0.1.3" }, | ||
"devDependencies" : { "vows": "~ 0.6.0" }, | ||
"engines" : { "node": ">= 0.6.0" } | ||
} |
@@ -11,2 +11,15 @@ JS-YAML - YAML 1.1 parser for JavaScript | ||
## Braking changes in 0.3.x -> 1.0.x | ||
- `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore. | ||
Decision to drop support of such "magic" was made after speaking with YAML | ||
core developers: from now on we try to keep as minimal subset of rules as | ||
possible to keep things obvious. Booleans are following YAML 1.2 core schema | ||
now: http://www.yaml.org/spec/1.2/spec.html#id2804923 | ||
- `require('file.yml')` now returns a single document (was array of documents) | ||
and throws an error when file contains multiple documents. | ||
- `js-yaml.bin` become part of `js-yaml` again. | ||
## Installation | ||
@@ -20,6 +33,27 @@ | ||
If you want to inspect your YAML files from CLI, | ||
install [js-yaml.bin](https://github.com/nodeca/js-yaml.bin). | ||
### CLI executable | ||
If you want to inspect your YAML files from CLI, install js-yaml globally: | ||
``` | ||
npm install js-yaml -g | ||
``` | ||
##### Usage | ||
usage: js-yaml [-h] [-v] [-c] [-j] [-t] file | ||
Positional arguments: | ||
file File with YAML document(s) | ||
Optional arguments: | ||
-h, --help Show this help message and exit. | ||
-v, --version Show program's version number and exit. | ||
-c, --compact Display errors in compact mode | ||
-j, --to-json Output a non-funky boring JSON | ||
-t, --trace Show stack trace on error | ||
### bundled YAML library for browser | ||
@@ -47,20 +81,9 @@ | ||
// Get array of documents, or throw exception on error | ||
var docs = require('/home/ixti/examples.yml'); | ||
// Get document, or throw exception on error | ||
var doc = require('/home/ixti/example.yml'); | ||
console.log(docs); | ||
console.log(doc); | ||
``` | ||
If you are sure, that file has only one document, chained `shift()` will help to exclude array wrapper: | ||
``` javascript | ||
require('js-yaml'); | ||
// Get array of documents, or throw exception on error | ||
var singleDoc = require('/home/ixti/examples.yml').shift(); | ||
console.log(singleDoc); | ||
``` | ||
### load (string|buffer|file\_resource) | ||
@@ -67,0 +90,0 @@ |
@@ -163,4 +163,4 @@ 'use strict'; | ||
CanonicalScanner.prototype.scanDirective = function scanDirective() { | ||
if (this.data.slice(this.index, this.index + DIRECTIVE.length) === this.DIRECTIVE | ||
&& 0 <= ' \n\x00'.indexOf(this.data.slice(this.index + DIRECTIVE.length))) { | ||
if (this.data.slice(this.index, this.index + DIRECTIVE.length) === this.DIRECTIVE && | ||
0 <= ' \n\x00'.indexOf(this.data.slice(this.index + DIRECTIVE.length))) { | ||
this.index += this.DIRECTIVE.length; | ||
@@ -176,4 +176,4 @@ return new _tokens.DirectiveToken('YAML', [1, 1], null, null); | ||
TokenClass = (this.data[this.index] === '*') | ||
? (_tokens.AliasToken) : (_tokens.AnchorToken); | ||
TokenClass = (this.data[this.index] === '*') ? (_tokens.AliasToken) | ||
: (_tokens.AnchorToken); | ||
@@ -180,0 +180,0 @@ this.index += 1; |
@@ -64,4 +64,4 @@ 'use strict'; | ||
JsYaml.scan(Fs.readFileSync(dataFile, 'utf8'), function (token) { | ||
if (Common.isInstanceOf(token, Tokens.StreamStartToken) | ||
|| Common.isInstanceOf(token, Tokens.StreamEndToken)) { | ||
if (Common.isInstanceOf(token, Tokens.StreamStartToken) || | ||
Common.isInstanceOf(token, Tokens.StreamEndToken)) { | ||
return; | ||
@@ -68,0 +68,0 @@ } |
@@ -13,5 +13,5 @@ 'use strict'; | ||
test: function () { | ||
var str = require(source).shift(); | ||
var str = require(source); | ||
Assert.equal('string', typeof str); | ||
} | ||
}); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
test: function () { | ||
var doc = require(source).shift(), expected = new Date(2011, 11, 24); | ||
var doc = require(source), expected = new Date(2011, 11, 24); | ||
@@ -16,0 +16,0 @@ // JS month starts with 0 (0 => Jan, 1 => Feb, ...) |
@@ -13,5 +13,5 @@ 'use strict'; | ||
test: function () { | ||
var doc = require(source).shift(); | ||
var doc = require(source); | ||
Assert.equal(doc.test, 'a b c\n'); | ||
} | ||
}); |
@@ -14,5 +14,5 @@ 'use strict'; | ||
Assert.doesNotThrow(function () { | ||
require(source).shift(); | ||
require(source); | ||
}, TypeError); | ||
} | ||
}); |
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 not supported yet
Sorry, the diff of this file is not supported yet
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
420324
1
437
4330
0
198
1
1
28
+ Addedargparse@~ 0.1.3
+ Addedargparse@0.1.16(transitive)
+ Addedunderscore@1.7.0(transitive)
+ Addedunderscore.string@2.4.0(transitive)