Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs11-async
documents
Commits
17565876
Commit
17565876
authored
4 years ago
by
Caleb C. Sander
Browse files
Options
Download
Email Patches
Plain Diff
Fix #11
parent
758391f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
specs/grep/grep.md
+4
-3
specs/grep/grep.md
with
4 additions
and
3 deletions
+4
-3
specs/grep/grep.md
View file @
17565876
...
...
@@ -11,7 +11,7 @@ You will also be implementing several `Transform` streams as part of this projec
## Goals
-
See how Node.js's stream abstraction
makes it easy to consume
different sources of data
-
See how Node.js's stream abstraction
simplifies working with
different sources of data
-
Implement some
`Transform`
streams
## The Unix `grep` utility
...
...
@@ -52,7 +52,7 @@ For example, `some-command | grep ERROR` will print out only the lines of output
Implement
`grep`
(including 4 of its command-line flags) in Node.js.
Your
`grep`
will be invoked using
`node grep.js [-i] [-r] [-v] [-z] pattern
...
files`
.
Your
`grep`
will be invoked using
`node grep.js [-i] [-r] [-v] [-z] pattern
[
files
...]
`
.
The flags
`-i`
,
`-r`
,
`-v`
, and
`-z`
are described later.
A simple implementation of
`grep`
would read the entire input, loop over its lines, and print the lines that match the pattern.
...
...
@@ -117,5 +117,6 @@ There are three types of `Readable` stream you will likely use:
Node.js streams can emit different sorts of data.
By default, most streams emit chunks of bytes.
To make them emit chunks of text instead, call
`stream.setEncoding('utf8')`
on the input stream, as well as each
`Transform`
stream.
This makes sense for a compressed file stream, but all other streams in the pipeline should emit chunks of text instead.
You can call
`stream.setEncoding('utf8')`
on the input stream as well as each
`Transform`
stream to make them output text.
Your
`Transform`
streams should also call
`super({decodeStrings: false})`
in their constructors so they receive each chunk of data as a string.
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help