Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "libyaml", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Bindings to libYAML", | ||
@@ -18,6 +18,13 @@ | ||
"engines": { | ||
"node": "0.4" | ||
"node": ">=0.4.0" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"underscore": "1", | ||
"tap": "0.0.x" | ||
}, | ||
"scripts": { | ||
"install": "node-waf configure build" | ||
"install": "node-waf configure build", | ||
"test": "tap ./tests/*.js" | ||
}, | ||
@@ -24,0 +31,0 @@ |
65
yaml.js
@@ -1,2 +0,2 @@ | ||
// YAML.node, © 2010 Stéphan Kochen | ||
// YAML.node, © 2011 Stéphan Kochen | ||
// MIT-licensed. (See the included LICENSE file.) | ||
@@ -46,4 +46,6 @@ | ||
if (m) { | ||
var s = m[2], length = s.length; result = 0, i; | ||
for (i = 0; i < length; i++) { | ||
var s = m[2], | ||
length = s.length, | ||
result = 0; | ||
for (var i = 0; i < length; i++) { | ||
if (s[i] == '_') | ||
@@ -63,8 +65,9 @@ continue; | ||
if (m) { | ||
var offset = 0, dateTimePart = m[1].replace('t', 'T'); | ||
var dateTimePart = m[1].replace('t', 'T'), | ||
offset = 0; | ||
if (m[2] && m[2] !== 'Z') { | ||
var parts = m[2].split(':'); | ||
offset = parseInt(parts[0]) * 100; | ||
offset = parseInt(parts[0], 10) * 100; | ||
if (parts.length == 2) | ||
offset += parseInt(parts[1]); | ||
offset += parseInt(parts[1], 10); | ||
} | ||
@@ -79,4 +82,6 @@ if (offset >= 0) | ||
// Regular numbers. | ||
if (canParseIntRe.test(v)) return parseInt( v.replace(underscoresRe, '')); | ||
if (canParseFloatRe.test(v)) return parseFloat(v.replace(underscoresRe, '')); | ||
if (canParseIntRe.test(v)) | ||
return parseInt(v.replace(underscoresRe, ''), 0); | ||
if (canParseFloatRe.test(v)) | ||
return parseFloat(v.replace(underscoresRe, '')); | ||
@@ -86,9 +91,11 @@ // Times. | ||
if (m) { | ||
var parts = m[2].split(':'), length = parts.length, result = 0, i; | ||
for (i = 0; i < parts.length; i++) { | ||
var parts = m[2].split(':'), | ||
length = parts.length, | ||
result = 0; | ||
for (var i = 0; i < length; i++) { | ||
result *= 60; | ||
if (i + 1 == parts.length) | ||
if (length == i + 1) | ||
result += parseFloat(parts[i]); | ||
else | ||
result += parseInt(parts[i]); | ||
result += parseInt(parts[i], 10); | ||
} | ||
@@ -243,2 +250,5 @@ if (m[1] == '-') | ||
} | ||
else if (item instanceof Date) { | ||
emitter.scalar(item.toISOString()); | ||
} | ||
else if (item.length) { | ||
@@ -262,4 +272,13 @@ emitter.sequence(function() { | ||
break; | ||
case "number": | ||
if (item === Infinity) | ||
emitter.scalar(".inf"); | ||
else if (item === -Infinity) | ||
emitter.scalar("-.inf"); | ||
else if (isNaN(item)) | ||
emitter.scalar(".NaN"); | ||
else | ||
emitter.scalar(String(item)); | ||
break; | ||
default: | ||
// FIXME: Properly serialize some special scalars (inf, datetimes, etc.) | ||
emitter.scalar(String(item)); | ||
@@ -287,1 +306,21 @@ break; | ||
}; | ||
// Helper for quickly writing out a file. | ||
exports.dumpFile = function(filename) { | ||
var documents = Array.prototype.slice.call(arguments, 1), | ||
numDocuments = documents.length, | ||
callback; | ||
if (numDocuments !== 0 && typeof documents[numDocuments - 1] === 'function') | ||
callback = documents.pop(); | ||
var data = exports.dump.apply(this, documents); | ||
fs.writeFile(filename, data, callback); | ||
}; | ||
// Synchronous version of dumpFile. | ||
exports.dumpFileSync = function(filename) { | ||
var documents = Array.prototype.slice.call(arguments, 1); | ||
var data = exports.dump.apply(this, documents); | ||
fs.writeFileSync(filename, data); | ||
}; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
39718
25
400
1
2
1