Permalink
Browse files

v0.0.8

  • Loading branch information...
1 parent c8f6a13 commit 2ca160385d67a88a4977c0ea53e0cb1bcd804986 @kriskowal committed Aug 11, 2011
Showing with 33 additions and 71 deletions.
  1. +5 −0 CHANGES
  2. +1 −1 LICENSE
  3. +0 −61 lib/q-io/buffer-io.js
  4. +3 −6 package.json
  5. +24 −3 {lib → }/q-io.js
View
@@ -1,4 +1,9 @@
+0.0.8
+ - Reorganized, moved q-io to the top level.
+ - Reved dependencies.
+ - Moved q-io-buffer to its own project.
+
0.0.3
- reved up Q to version 0.2 so duck-promises will work
View
@@ -1,5 +1,5 @@
-Copyright 2009, 2010 Kristopher Michael Kowal. All rights reserved.
+Copyright 2009-2011 Kristopher Michael Kowal. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
View
@@ -1,61 +0,0 @@
-
-var Q = require("q");
-var Buffer = require("buffer").Buffer;
-
-exports.BufferIO = function () {
- var self = {};
- var buffers = [];
- var closed = Q.defer();
-
- // TODO read size
- self.read = function () {
- consolidate(buffers);
- return buffers.shift();
- };
-
- self.write = function (buffer) {
- buffers.push(new Buffer(buffer));
- };
-
- self.closed = closed.promise;
-
- self.close = function () {
- };
-
- self.destroy = function () {
- };
-
- self.toBuffer = function () {
- consolidate(buffers);
- // for whatever reason, the buffer constructor does
- // not copy buffers in v0.3.3
- var buffer = new Buffer(buffers[0].length);
- buffers[0].copy(buffer);
- return buffer;
- };
-
- return self;
-};
-
-exports.consolidate = consolidate;
-function consolidate(buffers) {
- var length = 0;
- var at;
- var i;
- var ii = buffers.length;
- var buffer;
- var result;
- for (i = 0; i < ii; i++) {
- buffer = buffers[i];
- length += buffer.length;
- }
- result = new Buffer(length);
- at = 0;
- for (i = 0; i < ii; i++) {
- buffer = buffers[i];
- buffer.copy(result, at, 0);
- at += buffer.length;
- }
- buffers.splice(0, ii, result);
-}
-
View
@@ -1,7 +1,7 @@
{
"name": "q-io",
+ "version": "0.0.8",
"description": "Q Promise wrappers for Node's IO.",
- "version": "0.0.4",
"homepage": "http://github.com/kriskowal/q-io/",
"author": "Kris Kowal <kris@cixar.com> (http://github.com/kriskowal/)",
"bugs": {
@@ -14,12 +14,9 @@
"url": "http://github.com/kriskowal/q-io/raw/master/LICENSE"
}
],
- "main": "lib/q-io.js",
- "modules": {
- "buffer-io": "./lib/q-io/buffer-io.js"
- },
+ "main": "q-io.js",
"dependencies": {
- "q": ">=0.2.8"
+ "q": "0.7.1"
},
"repository": {
"type": "git",
View
@@ -7,7 +7,6 @@
var FS = require("fs"); // node
var SYS = require("sys"); // node
var Q = require("q"); // q package
-var consolidate = require("./q-io/buffer-io").consolidate;
/*whatsupdoc*/
@@ -141,8 +140,8 @@ exports.Writer = function (_stream, charset) {
* that all of the content has been sent.
*/
self.write = function (content) {
- if (!_stream.writeable)
- return Q.reject(_stream.writeable);
+ if (!_stream.writeable && !_stream.writable)
+ return Q.reject("Stream not writable");
if (!_stream.write(content)) {
return drained;
}
@@ -186,3 +185,25 @@ exports.Writer = function (_stream, charset) {
return self; // todo returns the begin.promise
};
+exports.consolidate = consolidate;
+function consolidate(buffers) {
+ var length = 0;
+ var at;
+ var i;
+ var ii = buffers.length;
+ var buffer;
+ var result;
+ for (i = 0; i < ii; i++) {
+ buffer = buffers[i];
+ length += buffer.length;
+ }
+ result = new Buffer(length);
+ at = 0;
+ for (i = 0; i < ii; i++) {
+ buffer = buffers[i];
+ buffer.copy(result, at, 0);
+ at += buffer.length;
+ }
+ buffers.splice(0, ii, result);
+}
+

0 comments on commit 2ca1603

Please sign in to comment.