From 627f02ac2e5656238d13408e4bc0415fc4a2b187 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Mon, 28 Jun 2010 18:17:51 +0800 Subject: [PATCH] JSDOC/TextStream.js --- JSDOC/TextStream.js | 65 +++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/JSDOC/TextStream.js b/JSDOC/TextStream.js index 0682c0b..a916386 100644 --- a/JSDOC/TextStream.js +++ b/JSDOC/TextStream.js @@ -6,43 +6,44 @@ XObject = imports.XObject.XObject; /** @constructor */ -TextStream = function(text) { - if (typeof(text) == "undefined") text = ""; - text = ""+text; - this.text = text; - this.cursor = 0; -} - -XObject.extend( TextStream.prototype, { - - look : function(n) { - if (typeof n == "undefined") n = 0; - - if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { - var result = new String(""); - result.eof = true; - return result; - } - return this.text.charAt(this.cursor+n); +TextStream = XObject.define( + function(text) { + if (typeof(text) == "undefined") text = ""; + text = ""+text; + this.text = text; + this.cursor = 0; }, - - next : function(n) { - if (typeof n == "undefined") n = 1; - if (n < 1) return null; + Object, + { - var pulled = ""; - for (var i = 0; i < n; i++) { - if (this.cursor+i < this.text.length) { - pulled += this.text.charAt(this.cursor+i); - } - else { + look : function(n) { + if (typeof n == "undefined") n = 0; + + if (this.cursor+n < 0 || this.cursor+n >= this.text.length) { var result = new String(""); result.eof = true; return result; } - } + return this.text.charAt(this.cursor+n); + }, + + next : function(n) { + if (typeof n == "undefined") n = 1; + if (n < 1) return null; + + var pulled = ""; + for (var i = 0; i < n; i++) { + if (this.cursor+i < this.text.length) { + pulled += this.text.charAt(this.cursor+i); + } + else { + var result = new String(""); + result.eof = true; + return result; + } + } - this.cursor += n; - return pulled; - } + this.cursor += n; + return pulled; + } }); \ No newline at end of file -- 2.39.2