writer.js
来自「原名JSPackager」· JavaScript 代码 · 共 66 行
JS
66 行
/**
* class for writing to character streams.
* @public
* @constructor
* @author jindw
*/
function Writer(){
this.buf = [];
}
/**
* Write a string.
* @public
* @param str String to be written
* @return <Writer> return itself
*/
Writer.prototype.print = function(str){
for(var i=0;i<arguments.length;i++)this.buf.push(arguments[i]);
return this;
}
/**
* Write a string.
* @public
* @arguments str... String to be written
* @return <Writer> return itself
* @see #write
*/
Writer.prototype.write = function(){
return this.print.apply(this,arguments);
}
/**
* Write a string.
* @public
* @param str String to be written
* @return <Writer> return itself
*/
Writer.prototype.println = function(str){
for(var i=0;i<arguments.length;i++)this.buf.push(arguments[i]);
this.buf.push('\r\n');
return this;
}
/**
* Write a string.
* @public
* @param str String to be written
* @return <Writer> return itself
* @see #write
*/
Writer.prototype.writeln = function(str){
return this.println.apply(this,arguments);
}
/**
* create a new String for the content
* @public
* @return <Writer> return itself
*/
Writer.prototype.clear = function(){
this.buf.length = 0;
return this;
}
/**
* create a new String for the content
* @public
*/
Writer.prototype.toString = function(){
return this.buf.join('');
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?