Comparing version 1.9.1 to 1.9.2
@@ -24,5 +24,5 @@ | ||
* @param {String} path Path to the file. | ||
* @param {Object} [options] An object with options. | ||
* @param {String} [options.flags] The mode to open the file with. | ||
* @param {String} [options.charset] The charset to open the file with. | ||
* @param {Object} [options] An object with options. | ||
* second argument. | ||
@@ -32,4 +32,7 @@ * @returns {Promise * (String || Buffer)} | ||
exports.read = function (path, flags, charset, options) { | ||
if (typeof flags == "object") { | ||
if (typeof flags === "object") { | ||
options = flags; | ||
} else if (typeof charset === "object") { | ||
options = charset; | ||
options.flags = flags; | ||
} else { | ||
@@ -40,3 +43,3 @@ options = options || {}; | ||
} | ||
options.flags = "r" + (options.flags || "").replace(/r/g, ""); | ||
options.flags = options.flags || "r"; | ||
return Q.when(this.open(path, options), function (stream) { | ||
@@ -57,5 +60,5 @@ return stream.read(); | ||
* @param {String || Buffer} content | ||
* @param {Object} [options] An object with options. | ||
* @param {String} [options.flags] The mode to open the file with. | ||
* @param {String} [options.charset] The charset to open the file with. | ||
* @param {Object} [options] An object with options. | ||
* @returns {Promise * Undefined} a promise that resolves | ||
@@ -66,4 +69,7 @@ * when the writing is complete. | ||
var self = this; | ||
if (typeof flags == "object") { | ||
if (typeof flags === "object") { | ||
options = flags; | ||
} else if (typeof charset === "object") { | ||
options = charset; | ||
options.flags = flags; | ||
} else { | ||
@@ -74,3 +80,3 @@ options = options || {}; | ||
} | ||
flags = "w" + (options.flags || "").replace(/[w]/g, ""); | ||
flags = options.flags || "w"; | ||
if (flags.indexOf("b") !== -1) { | ||
@@ -95,5 +101,5 @@ if (!(content instanceof Buffer)) { | ||
* @param {String || Buffer} content | ||
* @param {Object} [options] An object with options. | ||
* @param {String} [options.flags] The mode to open the file with. | ||
* @param {String} [options.charset] The charset to open the file with. | ||
* @param {Object} [options] An object with options. | ||
* @returns {Promise * Undefined} a promise that resolves | ||
@@ -104,4 +110,7 @@ * when the writing is complete. | ||
var self = this; | ||
if (typeof flags == "object") { | ||
if (typeof flags === "object") { | ||
options = flags; | ||
} else if (typeof charset === "object") { | ||
options = charset; | ||
options.flags = flags; | ||
} else { | ||
@@ -112,3 +121,3 @@ options = options || {}; | ||
} | ||
flags = "w+" + (options.flags || "").replace(/[w\+]/g, ""); | ||
flags = options.flags || "a"; | ||
if (content instanceof Buffer) { | ||
@@ -115,0 +124,0 @@ flags += "b"; |
@@ -81,3 +81,3 @@ /** | ||
} | ||
if (flags.indexOf("w") >= 0) { | ||
if (flags.indexOf("w") >= 0 || flags.indexOf("a") >= 0) { | ||
var stream = FS.createWriteStream(String(path), nodeOptions); | ||
@@ -84,0 +84,0 @@ return Writer(stream, charset); |
@@ -1,2 +0,2 @@ | ||
var Q = require("q"); | ||
var Negotiate = require("./negotiate"); | ||
@@ -3,0 +3,0 @@ var QS = require("qs"); |
var Q = require("q"); | ||
var Content = require("./content"); | ||
var Status = require("./status"); | ||
@@ -67,4 +68,4 @@ exports.HandleJsonResponses = function (app, reviver, tab) { | ||
if (!badRequest) | ||
badRequest = exports.badRequest; | ||
return exports.ContentRequest(function (content, request, response) { | ||
badRequest = Status.badRequest; | ||
return Content.ContentRequest(function (content, request, response) { | ||
try { | ||
@@ -71,0 +72,0 @@ var object = JSON.parse(content); |
{ | ||
"name": "q-io", | ||
"version": "1.9.1", | ||
"version": "1.9.2", | ||
"description": "IO using Q promises", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/kriskowal/q-io/", |
@@ -90,2 +90,4 @@ | ||
self.node = _stream; | ||
return begin.promise; | ||
@@ -92,0 +94,0 @@ } |
@@ -34,3 +34,3 @@ | ||
- ``flags``: ``r``, ``w``, ``a``, ``b``, default of `r`, not binary | ||
- ``flags``: ``r``, ``w``, ``a``, ``b``, default of `r`, not bytewise | ||
- ``charset``: default of ``utf-8`` | ||
@@ -46,3 +46,3 @@ - ``bufferSize``: in bytes | ||
into memory. It returns a promise for the whole file contents. By | ||
default, `read` provides a string decoded from UTF-8. With the binary | ||
default, `read` provides a string decoded from UTF-8. With the bytewise | ||
mode flag, provides a `Buffer`. | ||
@@ -157,14 +157,14 @@ | ||
### rename(source, target) | ||
Moves a file or directory from one path to another using the underlying | ||
`rename(2)` implementation, thus it cannot move a file across devices. | ||
### move(source, target) | ||
Moves a file or directory from one path to another. Cannot move over a | ||
target directory, even if it is empty. Otherwise, does nothing if the | ||
source and target are the same entry in the file system. | ||
Moves a file or directory from one path to another. If the source and | ||
target are on different devices, falls back to copying and removing, | ||
using `copyTree(source, target)` and, if completely successful, | ||
`removeTree(source)`. | ||
Node's `rename` implementation, at least on Mac OS X, does not enforce | ||
the rule that writing over an empty directory should fail. Since Q-IO | ||
enforces this rule in software, it is not atomic and there is a chance | ||
that an empty directory will be created over the target path between | ||
when `move` checks for it and when it overwrites it. | ||
### link(source, taget) | ||
@@ -924,4 +924,4 @@ | ||
Copyright 2009–2012 Kristopher Michael Kowal | ||
Copyright 2009–2013 Kristopher Michael Kowal | ||
MIT License (enclosed) | ||
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
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
8178
2964899
125