{"_id":"mock-res","_rev":"1995319","name":"mock-res","description":"Mocks node.js http.ServerResponse. See also `mock-req`.","dist-tags":{"latest":"0.6.0"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"time":{"modified":"2021-12-17T01:36:15.000Z","created":"2014-03-02T06:10:07.602Z","0.6.0":"2021-10-25T04:39:50.958Z","0.5.0":"2017-07-07T03:46:33.183Z","0.4.1":"2017-05-08T20:08:57.366Z","0.4.0":"2017-05-03T14:23:47.501Z","0.3.3":"2016-10-07T11:21:49.777Z","0.3.1":"2016-09-30T13:19:52.486Z","0.3.0":"2015-07-17T03:16:50.790Z","0.2.1":"2014-08-01T01:28:42.747Z","0.2.0":"2014-07-22T03:35:59.885Z","0.1.0":"2014-03-02T06:10:07.602Z"},"users":{},"author":{"name":"James Diacono"},"repository":{"type":"git","url":"git+https://github.com/diachedelic/mock-res.git"},"versions":{"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":{"shasum":"0543879ba2a1eb9511806c490a0c256e61eb74da","size":3680,"noattachment":false,"key":"/mock-res/-/mock-res-0.6.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.6.0.tgz"},"_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,"publish_time":1635136790958,"_cnpm_publish_time":1635136790958},"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","size":3781,"noattachment":false,"key":"/mock-res/-/mock-res-0.5.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.5.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-res-0.5.0.tgz_1499399191896_0.9537503304891288"},"directories":{},"publish_time":1499399193183,"_hasShrinkwrap":false,"_cnpm_publish_time":1499399193183},"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","size":3731,"noattachment":false,"key":"/mock-res/-/mock-res-0.4.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.4.1.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mock-res-0.4.1.tgz_1494274136730_0.2475718876812607"},"directories":{},"publish_time":1494274137366,"_hasShrinkwrap":false,"_cnpm_publish_time":1494274137366},"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","size":3718,"noattachment":false,"key":"/mock-res/-/mock-res-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.4.0.tgz"},"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/mock-res-0.4.0.tgz_1493821426335_0.1241261987015605"},"directories":{},"publish_time":1493821427501,"_hasShrinkwrap":false,"_cnpm_publish_time":1493821427501},"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","size":3533,"noattachment":false,"key":"/mock-res/-/mock-res-0.3.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.3.3.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/mock-res-0.3.3.tgz_1475839307233_0.6034439506474882"},"directories":{},"publish_time":1475839309777,"_cnpm_publish_time":1475839309777,"_hasShrinkwrap":false},"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","size":3520,"noattachment":false,"key":"/mock-res/-/mock-res-0.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.3.1.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/mock-res-0.3.1.tgz_1475241591361_0.1803340995684266"},"directories":{},"publish_time":1475241592486,"_cnpm_publish_time":1475241592486,"_hasShrinkwrap":false},"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","size":3504,"noattachment":false,"key":"/mock-res/-/mock-res-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.3.0.tgz"},"directories":{},"publish_time":1437103010790,"_cnpm_publish_time":1437103010790,"_hasShrinkwrap":false},"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","size":3490,"noattachment":false,"key":"/mock-res/-/mock-res-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.2.1.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"directories":{},"publish_time":1406856522747,"_cnpm_publish_time":1406856522747,"_hasShrinkwrap":false},"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","size":3073,"noattachment":false,"key":"/mock-res/-/mock-res-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.2.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"directories":{},"publish_time":1406000159885,"_cnpm_publish_time":1406000159885,"_hasShrinkwrap":false},"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","size":3069,"noattachment":false,"key":"/mock-res/-/mock-res-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/mock-res/download/mock-res-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"diachedelic","email":"james@diacono.com.au"},"maintainers":[{"name":"diachedelic","email":"james@diacono.com.au"}],"directories":{},"publish_time":1393740607602,"_cnpm_publish_time":1393740607602,"_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","_attachments":{},"homepage":"https://github.com/diachedelic/mock-res#readme","bugs":{"url":"https://github.com/diachedelic/mock-res/issues"},"license":"MIT"}