Comparing version 0.1.1 to 0.2.1
@@ -17,3 +17,3 @@ #!/usr/bin/env node | ||
Math.random() > 0.5 | ||
).moveTo([y,x]).write("."); | ||
).moveTo([y,x]).text("."); | ||
}, 5); |
32
index.js
@@ -1,28 +0,24 @@ | ||
var util = require("util"); | ||
var Stream = require("stream").Stream; | ||
var stream = require("stream"), | ||
util = require("util"); | ||
var csi = Buffer([0x1b, 0x5b]); | ||
var Jetty = module.exports = function Jetty(stream) { | ||
Stream.call(this); | ||
this.writable = true; | ||
this.readable = true; | ||
var Jetty = module.exports = function Jetty(outputStream) { | ||
stream.Readable.call(this); | ||
// pipe if stream is provided | ||
if (stream) { | ||
this.pipe(stream); | ||
if (outputStream) { | ||
this.pipe(outputStream); | ||
} | ||
}; | ||
util.inherits(Jetty, Stream); | ||
util.inherits(Jetty, stream.Readable); | ||
Jetty.prototype.write = function(data) { | ||
this.emit('data', data); | ||
return !this.paused && this.writable; | ||
}; | ||
Jetty.prototype._read = function _read(n) {}; | ||
Jetty.prototype.seq = function(char, args) { | ||
this.write(csi); | ||
this.push(csi); | ||
if (args && args.length) { | ||
this.write(args.join(";")); | ||
this.push(args.join(";")); | ||
} | ||
this.write(char); | ||
this.push(char); | ||
@@ -33,3 +29,3 @@ return this; | ||
Jetty.prototype.text = function(str, styleFn) { | ||
styleFn ? styleFn.call(this, str) : this.write(str); | ||
styleFn ? styleFn.call(this, str) : this.push(str); | ||
return this; | ||
@@ -36,0 +32,0 @@ }; |
{ | ||
"name": "jetty", | ||
"version": "0.1.1", | ||
"version": "0.2.1", | ||
"description": "TTY, you so fly", | ||
"main": "index.js", | ||
"dependencies": {}, | ||
"engines": { | ||
"node": "~0.10.0" | ||
}, | ||
"repository": { | ||
@@ -8,0 +11,0 @@ "type": "git", |
@@ -50,3 +50,3 @@ Jetty | ||
Math.random() > 0.5 | ||
).moveTo([y,x]).write("."); | ||
).moveTo([y,x]).text("."); | ||
}, 5); | ||
@@ -53,0 +53,0 @@ ``` |
11185
203