{"_id":"mock-res","_rev":"23-29da552143af2b5bdd42f27a88866702","name":"mock-res","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","dist-tags":{"latest":"0.6.0"},"versions":{"0.1.0":{"name":"mock-res","version":"0.1.0","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"_id":"mock-res@0.1.0","dist":{"shasum":"ce971806e77e82bfa6bbc2eb0673b61100e21824","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.1.0.tgz","integrity":"sha512-6o6X4HDChchQ7J2LPZLve0DW9hDon857DDz+L82+eBWVUI6x5+op4gNxN1A39jVQMJXOd0G8YVd94Vjnzidiqg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH2gERMzbXN8dtO9mJCqeTG+bsp7hnQPtaxRr/fpwBuBAiEAgWzhfwVpiNUSLVodJ206yBwx5Y+2zXOvB3eoHTNC8JU="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"directories":{}},"0.2.0":{"name":"mock-res","version":"0.2.0","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"_id":"mock-res@0.2.0","dist":{"shasum":"081fcb8b7f7e28f72a3c71ed3b618540a6a762f3","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.2.0.tgz","integrity":"sha512-yZbEdy7sfR0GS5QBMVRXssq/nofR4Aln1QUvJntk6W5VIZ0OSm5Gnq4tFldyyuyPynjhlJqg4PZNhIcJUHWm+w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIETmLNo6gM5CL+VbgZKOKa3pDgkxmrIwaSEU8K4SAiA5AiEA7Kh7fCdZyJ4hOrMdyFKSjiddzjAx8W4REhgaC4ptRuw="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"directories":{}},"0.2.1":{"name":"mock-res","version":"0.2.1","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"_id":"mock-res@0.2.1","dist":{"shasum":"b751db0fd89100f1e315443b89003e58cf84dd56","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.2.1.tgz","integrity":"sha512-e+4W+oDtzsBOapGTGEgjxpfU1UB5E902HjpBHsxbDcRzXyVedzDa5Ffn1Yg7ArCxVG7R4kXRd7gttkwXgrAqZQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH3kjE3HhpHO0HKRY5aiRZlTSDSja9iL9/3lzKakHlAZAiEAy+GSfnmU9bru+U/0EyJJTwshFUWT0Bd++PJjZm7ZPn8="}]},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"directories":{}},"0.3.0":{"name":"mock-res","version":"0.3.0","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"f9c720342e8f9434e7cc1005b3477f335124c3e1","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.3.0","_shasum":"0c2034cc6336d0595a3af109f7448283ee9c47f5","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.5","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"dist":{"shasum":"0c2034cc6336d0595a3af109f7448283ee9c47f5","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.3.0.tgz","integrity":"sha512-Hh/Mljjp9XI21xOJvs/LO+jEig3uAG8mJcUepJFBJ4INibBbYmb4l2mLqysaphuT5DXWjsQyqGhsd1D3rfNicQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMqzOOfCsRxIvh4RoPEWg/KLdNCYyLbFC1D4rBUXNv+QIhAL2njI1eY0aDzlPJHsr/bwvsf9fegVwUiZDVNaebOS7x"}]},"directories":{}},"0.3.1":{"name":"mock-res","version":"0.3.1","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"c8f749adca341db6a21eb5cd9eb4cc4ef25a3322","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.3.1","_shasum":"abadc6ed11b1a955b0b7c149012d736a9b6d9e9f","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.7.0","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"dist":{"shasum":"abadc6ed11b1a955b0b7c149012d736a9b6d9e9f","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.3.1.tgz","integrity":"sha512-gB9OnHO7ZbHI4+DLobkWsR+H/Q07VFYfO2oApgy6ll+ACwX5NfAQBmS+0ljBQXyDqmB8zUkaeXc6F/csGDYLaA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCEyLa0PP5VP9Y4//B/NbP2td9ISa/9U1AvXjPVKvDy1AIhAMJczIhJaOLbu1CSI/INb+NYObs0Bjepa2CovRkXkflX"}]},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/mock-res-0.3.1.tgz_1475241591361_0.1803340995684266"},"directories":{}},"0.3.3":{"name":"mock-res","version":"0.3.3","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"93a33be9158bcf94738ff18279d305671fb3ae90","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.3.3","_shasum":"b2b37dca5a4ad6930bcdf9765778be9927d40d05","_from":".","_npmVersion":"2.15.8","_nodeVersion":"4.4.7","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"dist":{"shasum":"b2b37dca5a4ad6930bcdf9765778be9927d40d05","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.3.3.tgz","integrity":"sha512-3S47fzLkBeABGoRaPsFSQksEnDWHpohzQuo7unoRNhUH5vc+m5PWRhWDenglQlOb6NPqWpdsm64U9qFLZ6Ks5Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIB0nTki3UL1VwCzQEA7pjW5zG64v0THIfsIixPS05wZUAiEAgbn++nzU9QCby/vP08jEm7yUiN5zq7Lu0aCMbpG5u5o="}]},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/mock-res-0.3.3.tgz_1475839307233_0.6034439506474882"},"directories":{}},"0.4.0":{"name":"mock-res","version":"0.4.0","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"03140dff1e8bb5bf00f248be97cf5a045602167f","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.4.0","_shasum":"0e379280864ff9ff357341ec52df23b82d274671","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.10.0","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"dist":{"shasum":"0e379280864ff9ff357341ec52df23b82d274671","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.4.0.tgz","integrity":"sha512-n9pYao8uGVWLKyGs3lGHKP3N/w70YEmobUHz8xpAMG50v585kMxABapkEkufpxO3BXb/0YJaidEZ69CJZPB9JQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDznlAn9L5jPU3WYkbiRjd6dzWHbMEhFACKI7YfqcIdtQIhANCRs+5lFjkpicwG7Oh46ekM0oZkhYNY3uj9voib2453"}]},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mock-res-0.4.0.tgz_1493821426335_0.1241261987015605"},"directories":{}},"0.4.1":{"name":"mock-res","version":"0.4.1","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"0e501dde0fd6f9f1bf7538c64ae6335304413433","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.4.1","_shasum":"d3004ea770ae0faec45b6594cc9500709809ec61","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.10.0","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"dist":{"shasum":"d3004ea770ae0faec45b6594cc9500709809ec61","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.4.1.tgz","integrity":"sha512-ek7elfM9mCFW3yrJR+lOk93ycvG+h0BTJk1b7A7Pyr2fwGMnof88IShB0CAT7MEM70RSJ9a0zfHYCap0CGksWQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCFKtGaESFm3A4T887wnQ95ig4S+O/8KI0c78NgIhLoYQIhAM0W+7vSeMAWeswxKVOPbhkELZ3i+m+fP8Z8QtgysyjI"}]},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mock-res-0.4.1.tgz_1494274136730_0.2475718876812607"},"directories":{}},"0.5.0":{"name":"mock-res","version":"0.5.0","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"4fbc7cce829232eda2f7dddd5a0bbf04183e7e9e","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.5.0","_shasum":"98368beb09df753f64f66d94e5536a97b36a2430","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.10.0","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"dist":{"shasum":"98368beb09df753f64f66d94e5536a97b36a2430","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.5.0.tgz","integrity":"sha512-KBTRmramDPSr1TwsTy54uzm50QUAdyLTy6CXcHwwPN9pMVH90S12rwbAvXf3Bghr2TNPEuLmz227ClR8SIwQNQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCAWIJ5lLBzDgSkG3ZJ+evzTYGRmFz+5LfvJLQW3nOOzgIgMEr0X8jMkG44x4Hvjd/wHF0rUZpoFOnusMM1iJVzd6g="}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-res-0.5.0.tgz_1499399191896_0.9537503304891288"},"directories":{}},"0.6.0":{"name":"mock-res","version":"0.6.0","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"keywords":["mock","http","ServerResponse","response","res"],"author":{"name":"James Diacono"},"license":"MIT","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"gitHead":"e3b78416553b77b04311152c55eaf6e6bfc42f8c","homepage":"https://github.com/diachedelic/mock-res#readme","_id":"mock-res@0.6.0","_nodeVersion":"16.4.1","_npmVersion":"7.18.1","dist":{"integrity":"sha512-FCX7To1rh+0d+CaZNTU+3TF7IyhTRfsw5zwg6l8g+g7p6l46CwIyGMWV9dL8KuCrVx+ONPKrWi7C5J1eAUVPKA==","shasum":"0543879ba2a1eb9511806c490a0c256e61eb74da","tarball":"https://registry.npmjs.org/mock-res/-/mock-res-0.6.0.tgz","fileCount":5,"unpackedSize":10484,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2zeGCRA9TVsSAnZWagAAfC4P/14y6K23QudChM0g7bOx\nQOtAqx68ir7m/Xu9GNi6++9zsDfI85Jg74ktVuX1JrO8VXXRTuTW40+poVBN\nUhU9otYQXArPeVdo8UT31HUklGIBaP9J/xEnkt1ieheSEIgGhtJR/3oXqGKN\n+u1BO0HCaEMnr2N5pq2E1JyK3x8P/iEsQugBZ/UJuom+qgtDMEFr3J6bojaZ\n1Z/tzkSv+/QI9l/JtT0+Cs1h0I30Dbf0zsmJWiO8HK4dW6FmKftsL3ucBhzT\n9NmB6lOMlBI2uId84nBcSTA5A5OqTjs7xPlT84deNqKlZQPT42xwiejE68Or\nwPaP3k0KutrzjGhEFcLpe1q9lxgE95TNOghMOKul8mGUPbZXTEM0gRI8qtxk\ngiIPcVjmkkZTIwVRC9H/3CmWdpRzVPJ+dVC5rUTjSlrDGzu4SivI0In7Dm2C\noQcPqGH3/kqUxH4yRJ1DMzS5F0i0LGJyY/kkv5r2BO1J8vYaV94LM31v4sIR\nK74xSOVUyF2zPW0hJajN55RECszRjZUBiOCrBGQ8YKytgpT0Tj0cGq2lKTFI\nHDlPaDeQRsb/i+k9gnR+j/pb1cGbJoZmjZU/oieZfKhrIFT6aZkt959D9sm3\nOTP7PIGrWFBuKabPcnB34y82XfheHaM/6ou67Ab4eyTyyG2N4n75zc334q0g\nPGme\r\n=qfmS\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG6tR0cy5jXNbaO1Jucz5yghI2hqxHBcI52je/pjaqfqAiBpi1srpbJyKbuCp9nFG7or1+s6+PwaLXXf8s0uEd4+qQ=="}]},"_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"directories":{},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-res_0.6.0_1635136790829_0.6884085373810427"},"_hasShrinkwrap":false}},"readme":"mock-res\n========\n\nMocks node.js http.ServerResponse (a response). See also `mock-req`.\n\nBeing a readable/writable stream, you can pipe the response body to and from it.\n\n# Usage\nSee `test.js` for further usage.\n\n\tvar MockRes = require('mock-res');\n\n\t// Basic usage\n\tvar res = new MockRes();\n\n\t// Supply a callback to be called after res.end() is called\n\tvar res = new MockRes(function onEnd() {\n\t\tconsole.log('Response sent');\n\t});\n\n\t// Listen for stream events\n\tres.on('error', function (err) {\n\t\t// If not listened for, the 'error' event will throw,\n\t\t// as is true for any stream.\n\t});\n\tres.on('finish', function () {\n\t\tconsole.log('Finished writing response');\n\t});\n\n\t// Read status code\n\tres.statusCode; // 200 by default\n\n\t// Read body as string\n\tres._getString(); // 'I am a chicken';\n\n\t// Read body as parsed JSON\n\tres._getJSON(); // { chicken: true }\n\n\t// Pipe body somewhere\n\tres.pipe(fs.createWriteStream('/tmp/yo'));\n\n## Example test case\n\n\tvar assert = require('assert');\n\tvar list = require('./list-handler');\n\tvar MockRes = require('mock-res');\n\n\tfunction test(done) {\n\t\t/* Arrange */\n\n\t\t// Use `mock-req` for a better mock\n\t\tvar req = {\n\t\t\tmethod: 'GET',\n\t\t\turl: '/foos'\n\t\t}\n\n\t\tvar res = new MockRes(onEnd);\n\n\t\t/* Act */\n\t\tlist(req, res);\n\n\t\t/* Assert */\n\t\tfunction onEnd() {\n\t\t\t// NOTE `this` === `res`\n\n\t\t\tassert.equal(this.statusCode, 200);\n\t\t\tassert.equal(this._getString(), '[{\"id\":0},{\"id\":1}]');\n\t\t\tassert.deepEqual(this._getJSON(), [{id: 0 }, {id: 1 }]);\n\t\t\tassert.deepEqual(this.getHeader('set-cookie'), ['a=1', 'b=2']);\n\n\t\t\tres.pipe(process.stdout); // `res` is just a readable stream here\n\n\t\t\tdone(); // this is an async test\n\t\t}\n\t}\n\n## Methods\n\n* All readable/writable stream methods.\n* `writeHead(statusCode, [reasonPhrase], [headers])` Sets the response status code, status message, and headers.  See also the [`http.ServerResponse` documentation](http://nodejs.org/api/http.html#http_response_writehead_statuscode_reasonphrase_headers).\n* `setHeader()`, `getHeader()`, `getHeaders()`, `removeHeader()`\n* `_getString()` Reads the body as a string, from the internal stream buffer.\n* `_getJSON()` Reads the body as a parsed JSON object, from the internal stream buffer.\n","maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"time":{"modified":"2022-06-20T02:08:54.077Z","created":"2014-03-02T06:10:05.657Z","0.1.0":"2014-03-02T06:10:07.602Z","0.2.0":"2014-07-22T03:35:59.885Z","0.2.1":"2014-08-01T01:28:42.747Z","0.3.0":"2015-07-17T03:16:50.790Z","0.3.1":"2016-09-30T13:19:52.486Z","0.3.3":"2016-10-07T11:21:49.777Z","0.4.0":"2017-05-03T14:23:47.501Z","0.4.1":"2017-05-08T20:08:57.366Z","0.5.0":"2017-07-07T03:46:33.183Z","0.6.0":"2021-10-25T04:39:50.958Z"},"readmeFilename":"README.md","keywords":["mock","http","ServerResponse","response","res"],"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"author":{"name":"James Diacono"},"bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"license":"MIT","homepage":"https://github.com/diachedelic/mock-res#readme"}