{"id":19574708,"url":"https://github.com/stringparser/stdout-monkey","last_synced_at":"2025-07-29T10:39:08.334Z","repository":{"id":21196205,"uuid":"24506550","full_name":"stringparser/stdout-monkey","owner":"stringparser","description":"Monkeypatch for stdout with knobs. For testing purposes, or other things. ","archived":false,"fork":false,"pushed_at":"2014-10-09T15:24:05.000Z","size":204,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-06T00:54:16.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stringparser.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-26T16:21:04.000Z","updated_at":"2020-05-26T01:32:26.000Z","dependencies_parsed_at":"2022-08-18T06:21:46.714Z","dependency_job_id":null,"html_url":"https://github.com/stringparser/stdout-monkey","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/stringparser/stdout-monkey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fstdout-monkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fstdout-monkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fstdout-monkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fstdout-monkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stringparser","download_url":"https://codeload.github.com/stringparser/stdout-monkey/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stringparser%2Fstdout-monkey/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267672284,"owners_count":24125535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T06:43:35.112Z","updated_at":"2025-07-29T10:39:08.309Z","avatar_url":"https://github.com/stringparser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stdout-monkey [\u003cimg alt=\"progressed.io\" src=\"http://progressed.io/bar/99\" align=\"right\"/\u003e](https://github.com/fehmicansaglam/progressed.io)\n\n[\u003cimg alt=\"build\" src=\"http://img.shields.io/travis/stringparser/stdout-monkey/master.svg?style=flat-square\" align=\"left\"/\u003e](https://travis-ci.org/stringparser/stdout-monkey/builds)\n[\u003cimg alt=\"NPM version\" src=\"http://img.shields.io/npm/v/stdout-monkey.svg?style=flat-square\" align=\"right\"/\u003e](http://www.npmjs.org/package/stdout-monkey)\n\u003cbr\u003e\u003cbr\u003e\n\nMonkeypatch for stdout with knobs. For testing purposes, or other things.\n\u003cbr\u003e\n\n## install\n\n    npm install stdout-monkey\n\n## example\n\n```js\nvar stdout = require('stdout-monkey');\n\nvar monkey = stdout(function(str, enc, cb){\n  this.log('I want more bananas!');\n})\n\nconsole.log('Hey, stop it!');\n// -\u003e I want more bananas!\n```\n\n## why\n\nYou don't want to spam `stdout` for testing. You want to `batch` data or you want to transform data before it reaches `stdout`.\n\n### api\n\nBelow when I write `stdout` I really want to write `process.stdout.write`.\n\n```\nvar monkey = require('stdout-monkey')([callback])\n```\n\nCalling the module with a function returns a *monkeypatched* `stdout` disabled by default. Instead the arguments are passed to the given `callback`. \n\nNote: that is not really accurate since the `object` is not a `writable` stream.\n\n#### monkey.patch([callback])\n\nDefault method returned from the module. Patch `stdout` and disable it. Use the given callback instead.\nReturns the `monkey` instance.\n\n#### monkey.restore([data], [enc], [cb])\n\nRestore `stdout`. Optionaly write something.\n\n#### monkey.listen([callback])\n\nPatch `stdout` but only to include the `callback`. `stdout` will work as normal, you can *spy* but not *modify* what is written.\n\n#### monkey.write(data, [enc], [cb])\n\nUse the original `process.stdout.write` even if it was patched.\n\n#### monkey.log([arguments])\n\nUse `console.log` even if `stdout` was patched.\n\n\u003chr\u003e\n\nAll above methods are chainable.\n\n### properties\n\nThe `monkey` has a `state` property indicating if `process.stdout.write` was `patched` or if he used the `restore` or `listen` methods.\n\nNOTE: the `state` is not changed when calling the `log` or `write` methods.\n\n## test\n\n    npm test\n\n### inspirated and based on\n\n - [a gist](https://gist.github.com/pguillory/729616)\n - [a modified version of the gist](https://gist.github.com/stringparser/b539b8cfd5769542037d)\n\n### todo\n\n - [ ] make the `monkey` a `through` stream.\n\n### license\n\n[\u003cimg alt=\"LICENSE\" src=\"http://img.shields.io/npm/l/stdout-monkey.svg?style=flat-square\"/\u003e](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringparser%2Fstdout-monkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstringparser%2Fstdout-monkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstringparser%2Fstdout-monkey/lists"}