Skip to content

Commit a5b3436

Browse files
committed
test: simplify example
1 parent d85f936 commit a5b3436

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,24 @@ http.createServer(function (request, response) {
124124
}).listen(8080);
125125
```
126126

127-
More on intercepting errors bellow.
127+
More on intercepting errors below.
128+
129+
### Transforming text files
130+
131+
If you wish to apply a transform to text files before they are streamed in
132+
response, you can supply a `transform` callback which returns a `stream`
133+
`Transform`.
134+
135+
```js
136+
const server = http.createServer((req, res) => {
137+
const s = new statik.Server(__dirname + '/../fixtures', {
138+
transform (fileString, pathname, req, res) {
139+
140+
}
141+
});
142+
s.serve(req, res);
143+
}).listen(9010);
144+
```
128145

129146
### Intercepting errors & Listening
130147

test/integration/transform-factory-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ it('invokes custom transform factory and applies its transform', async function
1313
called = true;
1414
return new Transform({
1515
transform(chunk, _enc, cb) {
16-
cb(null, Buffer.from(chunk.toString().toUpperCase() + '\n--CUSTOM--'));
16+
cb(null, chunk.toString().toUpperCase() + '\n--CUSTOM--');
1717
}
1818
});
1919
};

0 commit comments

Comments
 (0)