Skip to content
This repository was archived by the owner on Dec 4, 2018. It is now read-only.

Commit 71472f1

Browse files
committed
document header feature
1 parent 0a89ff6 commit 71472f1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

readme.markdown

+11
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ var stream = JSONStream.parse(['rows', true, 'doc']) //rows, ANYTHING, doc
8484
stream.on('data', function(data) {
8585
console.log('received:', data);
8686
});
87+
//emits anything from _before_ the first match
88+
stream.on('header', function (data) {
89+
console.log('header:', data) // => {"total_rows":129,"offset":0}
90+
})
91+
8792
```
8893
awesome!
8994

@@ -96,6 +101,7 @@ stream.on('data', function(data) {
96101
console.log('key:', data.key);
97102
console.log('value:', data.value);
98103
});
104+
99105
```
100106

101107
### recursive patterns (..)
@@ -132,6 +138,10 @@ if `map` return non-nullish (anything but `null` or `undefined`)
132138
that value will be emitted in the stream. If it returns a nullish value,
133139
nothing will be emitted.
134140

141+
`JSONStream` also emits `'header'` and `'footer'` events,
142+
the `'header'` event contains anything in the output that was before
143+
the first match, and the `'footer'`, is anything after the last match.
144+
135145
## JSONStream.stringify(open, sep, close)
136146

137147
Create a writable stream.
@@ -182,3 +192,4 @@ https://github.com/Floby/node-json-streams
182192
## license
183193

184194
Dual-licensed under the MIT License or the Apache License, version 2.0
195+

0 commit comments

Comments
 (0)