From 2a333e073c895b488c88b240f264e92e737e0f46 Mon Sep 17 00:00:00 2001 From: Ido Sela Date: Thu, 7 Jun 2012 20:59:18 -0400 Subject: [PATCH] A minor alternative for generating the isCard functions --- creditcard.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/creditcard.js b/creditcard.js index 6ead5ca..a92ab58 100644 --- a/creditcard.js +++ b/creditcard.js @@ -74,8 +74,7 @@ var CreditCard = { } ;(function(){ - for(var card in CreditCard.CARDS) - CreditCard['is'+card] = _.bind(function(card, number){ - return CreditCard.CARDS[card].test(CreditCard.strip(number)) - }, CreditCard, card) + _.each(CreditCard.CARDS, function(exp, card) { + CreditCard['is'+card] = _.compose(_.bind(exp.test, exp), CreditCard.strip) + }) })() \ No newline at end of file