Closed Sequoia closed 9 years ago
@Sequoia follow up on this? Are we done with this one?
Yeah sry didn't have time to try it this weekend! Will do presently :)
Do you think that we should mix this with arguments to support something like this?
cat macbeth.txt | solution.js --word=thou
Multiple tests could assert that the program displays the correct lines for a variety of --word
arguments
hmmmmmm..... my knee jerk reaction is KISS & leave that out, as I outline here, but in that case the proposal was introducing hapi
whereas in this it's building on/reinforcing an existing concept.
Yeah I say "do it" :+1: :ok_hand: :smiley_cat:
--word
parameterverify
problem.md
fileboilerplate.js
to suggest using minimist
all done?!
I'll review when I get a chance sry for delay!
wrt boilerplate.js I think it might be better to move some of that into the Example
section of the Readme: learners should have to type at least some of that in themselves for the purposes of rote. Also I'm trying to keep English strings out of the boilerplate/solution as much as possible to ease eventual i18n. :pray:
Add note about toString on buffers
console.log('x' + ...read())
casts buffer to str but console.log('x', ...read())
(i.e. 2 args for console.log does not. The latter is in the boilerplateconsole.log("reading:" + process.stdin.read().toString());
does not work because readable is emitted with a null
on end of input it seems :/process.stdin.on('readable', function() {
var buffer = process.stdin.read();
if(buffer === null) { return; }
console.log("reading:" + buffer);
});
^ This basically work
on('readable'),
) may actually lead the learner away from the solution-- it seems intuitive that cl
ing should happen on readable but really it should (probably) happen on end
clijs run
does I think it should actually set up the env like it will be set up for verify
, i.e. pipe data in & feed it a switchstream-adventure
if they want to learn more about this exciting topicresults
string then operate on it on('end')
" pattern is canonical but not necessarily obvious. I suggest adding note/example that highlights this techniqueI'd probably say that this lesson is "too hard" as it currently stands. It took me a minute to figure it out and I'm reasonably good at this stuff. I want to carefully avoid (as much as possible) learners getting "stuck", and I think this lesson would get people a lot of people stuck.
Will create new ticket for revisions. Initial version is :+1: done.
How to accept an incoming stream, specifically output of another program piped into the user's program. Goal is to have >1 incoming chunk while keeping it as simple as possible.
also
recommend/link to
stream-adventure
in the docs for people who want to learn more about streams.