[Pkg-javascript-commits] [node-mocks-http] 242/296: Refactor `defineGetter()` function

Thorsten Alteholz alteholz at moszumanska.debian.org
Mon Feb 8 18:13:41 UTC 2016


This is an automated email from the git hooks/post-receive script.

alteholz pushed a commit to branch master
in repository node-mocks-http.

commit b6dd93e7bdb6fe8f6d1be793e25c68a488a6804b
Author: Johnny Estilles <johnny.estilles at agentia.asia>
Date:   Wed Jun 3 12:58:12 2015 +0800

    Refactor `defineGetter()` function
---
 lib/express/mock-request.js        |  9 +--------
 lib/express/utils/define-getter.js | 11 +++++++++++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/express/mock-request.js b/lib/express/mock-request.js
index ca03039..335dd98 100644
--- a/lib/express/mock-request.js
+++ b/lib/express/mock-request.js
@@ -7,6 +7,7 @@ var parse = require('parseurl');
 var isIP = require('net').isIP;
 var fresh = require('fresh');
 
+var defineGetter = require('./utils/define-getter');
 var http = require('./node/http');
 
 var req = exports = module.exports = {
@@ -159,11 +160,3 @@ defineGetter(req, 'xhr', function xhr() {
   var val = this.get('X-Requested-With') || '';
   return val.toLowerCase() === 'xmlhttprequest';
 });
-
-function defineGetter(obj, name, getter) {
-  Object.defineProperty(obj, name, {
-    configurable: true,
-    enumerable: true,
-    get: getter
-  });
-}
diff --git a/lib/express/utils/define-getter.js b/lib/express/utils/define-getter.js
new file mode 100644
index 0000000..dd67768
--- /dev/null
+++ b/lib/express/utils/define-getter.js
@@ -0,0 +1,11 @@
+'use strict';
+
+function defineGetter(obj, name, getter) {
+  Object.defineProperty(obj, name, {
+    configurable: true,
+    enumerable: true,
+    get: getter
+  });
+}
+
+module.exports = defineGetter;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-mocks-http.git



More information about the Pkg-javascript-commits mailing list