From bad7cd0e28cebd243ed20601aa68cf474f346b4b Mon Sep 17 00:00:00 2001
From: dbencic
Date: Thu, 2 Jul 2015 00:02:11 +0200
Subject: [PATCH 1/2] Support for multiple occurrences of 'loud' class
This solution supports multiple elements with 'loud' class. Previous solution transforms only first one.
---
problems/html_stream/solution.js | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/problems/html_stream/solution.js b/problems/html_stream/solution.js
index a8594dc6..bf9211ff 100644
--- a/problems/html_stream/solution.js
+++ b/problems/html_stream/solution.js
@@ -4,10 +4,12 @@
var through = require('through2');
var tr = trumpet();
- var loud = tr.select('.loud').createStream();
- loud.pipe(through(function (buf, _, next) {
+ tr.selectAll('.loud', function(loud) {
+ var stream = loud.createStream();
+ stream.pipe(through(function (buf, _, next) {
this.push(buf.toString().toUpperCase());
next();
- })).pipe(loud);
+ })).pipe(stream);
+ });
process.stdin.pipe(tr).pipe(process.stdout);
From 055cb9a531df6c8c5e7dc0a528c698fd98e9821c Mon Sep 17 00:00:00 2001
From: Dragan Bencic
Date: Thu, 2 Jul 2015 00:11:52 +0200
Subject: [PATCH 2/2] Solution that supports multiple 'loud' tags
---
problems/html_stream/expected.html | 2 +-
problems/html_stream/input.html | 2 +-
problems/html_stream/solution.js | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/problems/html_stream/expected.html b/problems/html_stream/expected.html
index 586a7d13..e7d10641 100644
--- a/problems/html_stream/expected.html
+++ b/problems/html_stream/expected.html
@@ -7,7 +7,7 @@
Four score and several years ago, our fathers bought four swiss
continents, a new vacation, covered in liberty.
And predicated to the preposition that tall men created a
- sequel.
+ sequel. FIRST LOUD TEXT.
diff --git a/problems/html_stream/input.html b/problems/html_stream/input.html
index af23e560..e2e1b77f 100644
--- a/problems/html_stream/input.html
+++ b/problems/html_stream/input.html
@@ -7,7 +7,7 @@
Four score and several years ago, our fathers bought four swiss
continents, a new vacation, covered in liberty.
And predicated to the preposition that tall men created a
- sequel.
+ sequel. first loud text.
diff --git a/problems/html_stream/solution.js b/problems/html_stream/solution.js
index bf9211ff..6406f499 100644
--- a/problems/html_stream/solution.js
+++ b/problems/html_stream/solution.js
@@ -5,11 +5,11 @@
var tr = trumpet();
tr.selectAll('.loud', function(loud) {
- var stream = loud.createStream();
- stream.pipe(through(function (buf, _, next) {
+ var stream = loud.createStream();
+ stream.pipe(through(function (buf, _, next) {
this.push(buf.toString().toUpperCase());
next();
- })).pipe(stream);
+ })).pipe(stream);
});
process.stdin.pipe(tr).pipe(process.stdout);