[Pkg-javascript-commits] [node-jsonstream] 200/214: document header feature

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 12:59:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-jsonstream.

commit 71472f16185dce86c50fe529d2e7fccc9277a929
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date:   Sun Sep 25 10:17:15 2016 +1300

    document header feature
---
 readme.markdown | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/readme.markdown b/readme.markdown
index 6266c20..3d3fc23 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -84,6 +84,11 @@ var stream = JSONStream.parse(['rows', true, 'doc']) //rows, ANYTHING, doc
 stream.on('data', function(data) {
   console.log('received:', data);
 });
+//emits anything from _before_ the first match
+stream.on('header', function (data) {
+  console.log('header:', data) // => {"total_rows":129,"offset":0}
+})
+
 ```
 awesome!
 
@@ -96,6 +101,7 @@ stream.on('data', function(data) {
   console.log('key:', data.key);
   console.log('value:', data.value);
 });
+
 ```
 
 ### recursive patterns (..)
@@ -132,6 +138,10 @@ if `map` return non-nullish (anything but `null` or `undefined`)
 that value will be emitted in the stream. If it returns a nullish value,
 nothing will be emitted.
 
+`JSONStream` also emits `'header'` and `'footer'` events,
+the `'header'` event contains anything in the output that was before
+the first match, and the `'footer'`, is anything after the last match.
+
 ## JSONStream.stringify(open, sep, close)
 
 Create a writable stream.
@@ -182,3 +192,4 @@ https://github.com/Floby/node-json-streams
 ## license
 
 Dual-licensed under the MIT License or the Apache License, version 2.0
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-jsonstream.git



More information about the Pkg-javascript-commits mailing list