npm.io
0.1.0 • Published 11 years ago

writer.js

Licence
MIT
Version
0.1.0
Deps
0
Vulns
0
Weekly
0
Stars
1

writer.js

Just a dumb little JS library providing an abstraction around the concept of writing text to something. Could be stdout, could be a file (not implemented yet), could be a string.

Loosely based off similar concepts in the worlds of Java, .NET (e.g. TextWriter) and probably elsewhere.

Example

var writer = require('writer');

var stringWriter = new writer.StringWriter();
stringWriter.write('foo');
stringWriter.write('bar');
stringWriter.write('baz');

stringWriter.toString();
// => 'foobarbaz'

var consoleWriter = new writer.ConsoleWriter();
consoleWriter.write('hey!');
consoleWriter.write('look!');

Make sense? Makes sense to me, anyway.

Keywords