UNPKG

@e2fyi/streams

Version:

Nodejs stream library for various use cases: e.g. Auto-tagging object streams, streaming to mongoDb via mongoose models, etc.

245 lines (87 loc) 3.91 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: DocumentTagger</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: DocumentTagger</h1> <section> <header> <h2> <span class="ancestors"><a href="module-@e2fyi_streams.html">@e2fyi/streams</a>.</span>DocumentTagger</h2> <div class="class-description"><p>Transform Object stream (objectMode=true) to tag with an autoIncrement id. An object or function can be optionally provided to mutate each object in the stream.</p></div> </header> <article> <div class="container-overview"> <h2>Constructor</h2> <h4 class="name" id="DocumentTagger"><span class="type-signature"></span>new DocumentTagger<span class="signature">(opts)</span><span class="type-signature"></span></h4> <div class="description"> <p>Create a new DocumentTagger stream.</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>opts</code></td> <td class="type"> <span class="param-type">DocumentTaggerSettings</span> </td> <td class="description last"><p>Settings for the stream.</p></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="src_document-tagger.js.html">src/document-tagger.js</a>, <a href="src_document-tagger.js.html#line50">line 50</a> </li></ul></dd> </dl> <h5>Fires:</h5> <ul> <li><a href="DocumentTagger.html#event:filtered">DocumentTagger#event:filtered</a></li> </ul> <h5>Example</h5> <pre class="prettyprint"><code>const docTagger = new DocumentTagger({autoIncrement: 'id', mutate: { project: 'test' }}); someReadableStreamFromArray([{text: 'abc'}, {text: 'efg'}]) .pipe(docTagger) .pipe(process.stdout); // stdout > // {"text": "abc", "id": 0, "project": "test"} // {"text": "efg", "id": 1, "project": "test"}</code></pre> </div> <h3 class="subsection-title">Extends</h3> <ul> <li>stream.Transform</li> </ul> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-@e2fyi_streams.html">@e2fyi/streams</a></li></ul><h3>Classes</h3><ul><li><a href="module-@e2fyi_streams.DocumentTagger.html">DocumentTagger</a></li><li><a href="module-@e2fyi_streams.MongooseStream.html">MongooseStream</a></li></ul><h3>Events</h3><ul><li><a href="DocumentTagger.html#event:filtered">filtered</a></li><li><a href="MongooseStream.html#event:mongoose-bulk-write">mongoose-bulk-write</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.0</a> on Thu Dec 14 2017 18:22:08 GMT+0800 (+08) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>