From 456c7390c0020a628693d3ddf244ce88eb81b641 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 24 Aug 2017 10:05:00 +0200 Subject: [PATCH] Updated README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6cc80b0..3bd63ca 100644 --- a/README.md +++ b/README.md @@ -44,22 +44,22 @@ function _runMiddlewares (err, req, res) { ``` #### Keep the context -If you need it you can also keep the context of the calling function by calling `run` with `run.call(this, req, res)`, in this way you can avoid closures allocation. +If you need it you can also keep the context of the calling function by calling `run` with `run(req, res, this)`, in this way you can avoid closures allocation. ```js http .createServer(function handler (req, res) { - middie.run.call({ context: 'object' }, req, res) + middie.run(req, res, { context: 'object' }) }) .listen(3000) -function _runMiddlewares (err, req, res) { +function _runMiddlewares (err, req, res, ctx) { if (err) { console.log(err) res.end(err) return } - console.log(this.context) + console.log(ctx) } ```