{
  "name": "tap-stream",
  "version": "0.1.0",
  "author": {
    "name": "Thorsten Lorenz",
    "email": "thlorenz@gmx.de",
    "url": "http://thlorenz.com"
  },
  "description": "Taps a nodejs stream and logs the data that's coming through.",
  "main": "index.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "tap ./test/*.js"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/thlorenz/tap-stream.git"
  },
  "keywords": [
    "stream",
    "streams",
    "log",
    "print",
    "inspect"
  ],
  "license": "BSD",
  "dependencies": {
    "through": "~1.1.0"
  },
  "devDependencies": {
    "tap": "~0.3.1"
  },
  "readme": "# tap-stream [![Build Status](https://secure.travis-ci.org/thlorenz/tap-stream.png)](http://travis-ci.org/thlorenz/tap-stream)\n\nTaps a nodejs stream and logs the data that's coming through.\n\n    npm install tap-stream\n\nGiven an [object stream](#object-stream) we can print out objects passing through and control the detail via the\ndepth parameter:\n\n```javascript\nobjectStream().pipe(tap(0));\n```\n\n![depth0](https://github.com/thlorenz/tap-stream/raw/master/assets/depth0.png)\n\n```javascript\nobjectStream().pipe(tap(1));\n```\n\n![depth1](https://github.com/thlorenz/tap-stream/raw/master/assets/depth1.png)\n\n```\nobjectStream().pipe(tap(2));\n```\n\n![depth2](https://github.com/thlorenz/tap-stream/raw/master/assets/depth2.png)\n\nFor even more control a custom log function may be supplied:\n\n```javascript\nobjectStream()\n  .pipe(tap(function customLog (data) {\n      var nest = data.nest;\n      console.log ('Bird: %s, id: %s, age: %s, layed egg: %s', nest.name, data.id, nest.age, nest.egg !== undefined);\n    })\n  );\n```\n\n```text\nBird: yellow rumped warbler, id: 0, age: 1, layed egg: true\nBird: yellow rumped warbler, id: 1, age: 1, layed egg: true\n```\n\n## API\n\n### tap( [ depth | log ] )\n\nIntercepts the stream and logs data that is passing through.\n\n- optional parameter is either a `Number` or a `Function`\n- if no parameter is given, `depth` defaults to `0` and `log` to `console.log(util.inspect(..))`\n\n- `depth` controls the `depth` with which\n  [util.inspect](http://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors) is called\n- `log` replaces the default logging function with a custom one\n\n**Example:**\n\n```javascript\nvar tap = require('tap-stream');\n\nmyStream\n  .pipe(tap(1)) // log intermediate results\n  .pipe(..)     // continute manipulating the data\n```\n\n## Object stream\n\nIncluded in order to give context for above examples.\n\n```javascript\nfunction objectStream () {\n  var s = new Stream()\n    , objects = 0;\n \n  var iv = setInterval(\n      function () {\n        s.emit('data', { \n            id: objects\n          , created: new Date()\n          , nest: { \n                name: 'yellow rumped warbler'\n              , age: 1\n              , egg: { name: 'unknown' , age: 0 }\n              } \n          }\n        , 4\n        );\n\n        if (++objects === 2) {\n            s.emit('end');\n            clearInterval(iv);\n        }\n      }\n    , 200);\n  return s;\n}\n```\n",
  "_id": "tap-stream@0.1.0",
  "_from": "tap-stream@~0.1.0"
}
