Skip to content

Commit

Permalink
Make writer customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
twada committed Jun 9, 2014
1 parent 3d19b58 commit 4e4632c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions index.js
Expand Up @@ -36,22 +36,22 @@ function create (options) {
if (typeof config.compare !== 'function') {
config.compare = defaultComparator(config);
}
if (!config.writer) {
config.writer = new StringWriter(config.lineSeparator);
if (!config.writerClass) {
config.writerClass = StringWriter;
}
return function (context) {
var that = this,
events = [],
var events = [],
pairs = [],
renderer = new PowerAssertContextRenderer(config);
writer = new config.writerClass(extend({}, config)),
renderer = new PowerAssertContextRenderer(extend({}, config));
renderer.init(context);
traverseContext(context, events, pairs);
renderer.render(events, config.writer);
renderer.render(events, writer);
pairs.forEach(function (pair) {
config.compare(pair, config.writer);
config.compare(pair, writer);
});
config.writer.write('');
return config.writer.flush();
writer.write('');
return writer.flush();
};
}

Expand Down
4 changes: 2 additions & 2 deletions lib/string-writer.js
@@ -1,6 +1,6 @@
function StringWriter (lineSeparator) {
function StringWriter (config) {
this.lines = [];
this.lineSeparator = lineSeparator;
this.lineSeparator = config.lineSeparator;
}

StringWriter.prototype.write = function (str) {
Expand Down

0 comments on commit 4e4632c

Please sign in to comment.