From 79878b036cf479b096d7871b37f342dcf3a678c4 Mon Sep 17 00:00:00 2001 From: "Jose F. Romaniello" Date: Mon, 7 Jan 2013 10:40:52 -0300 Subject: [PATCH] refactorize to use xtend --- lib/index.js | 23 +++-------------------- package.json | 3 ++- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/index.js b/lib/index.js index f1ce77c..fc5856a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,23 +1,6 @@ var connectUtils = require('connect').utils, - cookie = require('cookie'); - -var overwrite = function(overwritten) { - return (function() { - if( arguments.length > 1 ) { - for(var objects in arguments ) { - overwrite( this, arguments[objects] ); - } - } - - for( var key in arguments[0] ) { - if( arguments[0].hasOwnProperty(key) ) { - this[key] = arguments[0][key]; - } - } - - return this; - }).apply(overwritten, Array.prototype.slice.call(arguments, 1)); -}; + cookie = require('cookie'), + xtend = require('xtend'); function authorize(options) { var auth = { @@ -29,7 +12,7 @@ function authorize(options) { fail: null }; - overwrite( auth, options ); + xtend( auth, options ); auth.userProperty = auth.passport._userProperty || 'user'; diff --git a/package.json b/package.json index 7d7c850..2dc605e 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "passport": "~0.1.12", "connect": "~2.4.5", "cookie": "0.0.4", - "request": "~2.12.0" + "request": "~2.12.0", + "xtend": "~1.0.3" }, "devDependencies": { "should": "~1.2.1",