credit-card-type
Advanced tools
Comparing version 5.0.4 to 6.0.0
@@ -0,1 +1,9 @@ | ||
6.0.0 | ||
===== | ||
- Update mastercard niceType property to `Mastercard` to match new brand guidelines | ||
__Breaking Changes__ | ||
- Remove internal properties `prefixPattern` and `exactPattern` from returned object | ||
5.0.4 | ||
@@ -43,2 +51,3 @@ ===== | ||
- Add support for series 2 MasterCard bins (ranging from 222100 to 272099) | ||
- Removes dependency on Lodash | ||
@@ -45,0 +54,0 @@ |
@@ -28,23 +28,10 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.creditCardType=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
function clone(x) { | ||
var prefixPattern, exactPattern, dupe; | ||
function clone(originalObject) { | ||
var dupe; | ||
if (!x) { return null; } | ||
if (!originalObject) { return null; } | ||
// TODO: in the next major version, we should | ||
// consider removing these pattern properties. | ||
// They are not useful extnerally and can be | ||
// confusing because the exactPattern does not | ||
// always match (for instance, Maestro cards | ||
// can start with 62, but the exact pattern | ||
// does not include that since it would | ||
// exclude UnionPay and Discover cards | ||
// when it is not sure whether or not | ||
// the card is a UnionPay, Discover or | ||
// Maestro card). | ||
prefixPattern = x.prefixPattern.source; | ||
exactPattern = x.exactPattern.source; | ||
dupe = JSON.parse(JSON.stringify(x)); | ||
dupe.prefixPattern = prefixPattern; | ||
dupe.exactPattern = exactPattern; | ||
dupe = JSON.parse(JSON.stringify(originalObject)); | ||
delete dupe.prefixPattern; | ||
delete dupe.exactPattern; | ||
@@ -68,3 +55,3 @@ return dupe; | ||
types[MASTERCARD] = { | ||
niceType: 'MasterCard', | ||
niceType: 'Mastercard', | ||
type: MASTERCARD, | ||
@@ -71,0 +58,0 @@ prefixPattern: /^(5|5[1-5]|2|22|222|222[1-9]|2[3-6]|27|27[0-2]|2720)$/, |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.creditCardType=e()}}(function(){return function e(t,n,r){function a(s,p){if(!n[s]){if(!t[s]){var o="function"==typeof require&&require;if(!p&&o)return o(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return a(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)a(r[s]);return a}({1:[function(e,t,n){"use strict";function r(e){var t,n,r;return e?(t=e.prefixPattern.source,n=e.exactPattern.source,r=JSON.parse(JSON.stringify(e)),r.prefixPattern=t,r.exactPattern=n,r):null}function a(e){var t,n,a,s=[],p=[];if(!("string"==typeof e||e instanceof String))return[];for(a=0;a<m.length;a++)t=m[a],n=i[t],0!==e.length?n.exactPattern.test(e)?p.push(r(n)):n.prefixPattern.test(e)&&s.push(r(n)):s.push(r(n));return p.length?p:s}var i={},s="visa",p="master-card",o="american-express",c="diners-club",f="discover",d="jcb",u="unionpay",x="maestro",y="CVV",l="CID",g="CVC",P="CVN",m=[s,p,o,c,f,d,u,x];i[s]={niceType:"Visa",type:s,prefixPattern:/^4$/,exactPattern:/^4\d*$/,gaps:[4,8,12],lengths:[16,18,19],code:{name:y,size:3}},i[p]={niceType:"MasterCard",type:p,prefixPattern:/^(5|5[1-5]|2|22|222|222[1-9]|2[3-6]|27|27[0-2]|2720)$/,exactPattern:/^(5[1-5]|222[1-9]|2[3-6]|27[0-1]|2720)\d*$/,gaps:[4,8,12],lengths:[16],code:{name:g,size:3}},i[o]={niceType:"American Express",type:o,prefixPattern:/^(3|34|37)$/,exactPattern:/^3[47]\d*$/,isAmex:!0,gaps:[4,10],lengths:[15],code:{name:l,size:4}},i[c]={niceType:"Diners Club",type:c,prefixPattern:/^(3|3[0689]|30[0-5])$/,exactPattern:/^3(0[0-5]|[689])\d*$/,gaps:[4,10],lengths:[14,16,19],code:{name:y,size:3}},i[f]={niceType:"Discover",type:f,prefixPattern:/^(6|60|601|6011|65|64|64[4-9])$/,exactPattern:/^(6011|65|64[4-9])\d*$/,gaps:[4,8,12],lengths:[16,19],code:{name:l,size:3}},i[d]={niceType:"JCB",type:d,prefixPattern:/^(2|21|213|2131|1|18|180|1800|3|35)$/,exactPattern:/^(2131|1800|35)\d*$/,gaps:[4,8,12],lengths:[16],code:{name:y,size:3}},i[u]={niceType:"UnionPay",type:u,prefixPattern:/^((6|62|62\d|(621(?!83|88|98|99))|622(?!06)|627[02,06,07]|628(?!0|1)|629[1,2])|622018)$/,exactPattern:/^(((620|(621(?!83|88|98|99))|622(?!06|018)|62[3-6]|627[02,06,07]|628(?!0|1)|629[1,2]))\d*|622018\d{12})$/,gaps:[4,8,12],lengths:[16,17,18,19],code:{name:P,size:3}},i[x]={niceType:"Maestro",type:x,prefixPattern:/^(5|5[06-9]|6\d*)$/,exactPattern:/^(5[06-9]|6[37])\d*$/,gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:g,size:3}},a.getTypeInfo=function(e){return r(i[e])},a.types={VISA:s,MASTERCARD:p,AMERICAN_EXPRESS:o,DINERS_CLUB:c,DISCOVER:f,JCB:d,UNIONPAY:u,MAESTRO:x},t.exports=a},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.creditCardType=e()}}(function(){return function e(t,n,r){function i(s,p){if(!n[s]){if(!t[s]){var o="function"==typeof require&&require;if(!p&&o)return o(s,!0);if(a)return a(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";function r(e){var t;return e?(t=JSON.parse(JSON.stringify(e)),delete t.prefixPattern,delete t.exactPattern,t):null}function i(e){var t,n,i,s=[],p=[];if(!("string"==typeof e||e instanceof String))return[];for(i=0;i<m.length;i++)t=m[i],n=a[t],0!==e.length?n.exactPattern.test(e)?p.push(r(n)):n.prefixPattern.test(e)&&s.push(r(n)):s.push(r(n));return p.length?p:s}var a={},s="visa",p="master-card",o="american-express",f="diners-club",c="discover",d="jcb",u="unionpay",l="maestro",y="CVV",x="CID",g="CVC",P="CVN",m=[s,p,o,f,c,d,u,l];a[s]={niceType:"Visa",type:s,prefixPattern:/^4$/,exactPattern:/^4\d*$/,gaps:[4,8,12],lengths:[16,18,19],code:{name:y,size:3}},a[p]={niceType:"Mastercard",type:p,prefixPattern:/^(5|5[1-5]|2|22|222|222[1-9]|2[3-6]|27|27[0-2]|2720)$/,exactPattern:/^(5[1-5]|222[1-9]|2[3-6]|27[0-1]|2720)\d*$/,gaps:[4,8,12],lengths:[16],code:{name:g,size:3}},a[o]={niceType:"American Express",type:o,prefixPattern:/^(3|34|37)$/,exactPattern:/^3[47]\d*$/,isAmex:!0,gaps:[4,10],lengths:[15],code:{name:x,size:4}},a[f]={niceType:"Diners Club",type:f,prefixPattern:/^(3|3[0689]|30[0-5])$/,exactPattern:/^3(0[0-5]|[689])\d*$/,gaps:[4,10],lengths:[14,16,19],code:{name:y,size:3}},a[c]={niceType:"Discover",type:c,prefixPattern:/^(6|60|601|6011|65|64|64[4-9])$/,exactPattern:/^(6011|65|64[4-9])\d*$/,gaps:[4,8,12],lengths:[16,19],code:{name:x,size:3}},a[d]={niceType:"JCB",type:d,prefixPattern:/^(2|21|213|2131|1|18|180|1800|3|35)$/,exactPattern:/^(2131|1800|35)\d*$/,gaps:[4,8,12],lengths:[16],code:{name:y,size:3}},a[u]={niceType:"UnionPay",type:u,prefixPattern:/^((6|62|62\d|(621(?!83|88|98|99))|622(?!06)|627[02,06,07]|628(?!0|1)|629[1,2])|622018)$/,exactPattern:/^(((620|(621(?!83|88|98|99))|622(?!06|018)|62[3-6]|627[02,06,07]|628(?!0|1)|629[1,2]))\d*|622018\d{12})$/,gaps:[4,8,12],lengths:[16,17,18,19],code:{name:P,size:3}},a[l]={niceType:"Maestro",type:l,prefixPattern:/^(5|5[06-9]|6\d*)$/,exactPattern:/^(5[06-9]|6[37])\d*$/,gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:g,size:3}},i.getTypeInfo=function(e){return r(a[e])},i.types={VISA:s,MASTERCARD:p,AMERICAN_EXPRESS:o,DINERS_CLUB:f,DISCOVER:c,JCB:d,UNIONPAY:u,MAESTRO:l},t.exports=i},{}]},{},[1])(1)}); |
27
index.js
@@ -27,23 +27,10 @@ 'use strict'; | ||
function clone(x) { | ||
var prefixPattern, exactPattern, dupe; | ||
function clone(originalObject) { | ||
var dupe; | ||
if (!x) { return null; } | ||
if (!originalObject) { return null; } | ||
// TODO: in the next major version, we should | ||
// consider removing these pattern properties. | ||
// They are not useful extnerally and can be | ||
// confusing because the exactPattern does not | ||
// always match (for instance, Maestro cards | ||
// can start with 62, but the exact pattern | ||
// does not include that since it would | ||
// exclude UnionPay and Discover cards | ||
// when it is not sure whether or not | ||
// the card is a UnionPay, Discover or | ||
// Maestro card). | ||
prefixPattern = x.prefixPattern.source; | ||
exactPattern = x.exactPattern.source; | ||
dupe = JSON.parse(JSON.stringify(x)); | ||
dupe.prefixPattern = prefixPattern; | ||
dupe.exactPattern = exactPattern; | ||
dupe = JSON.parse(JSON.stringify(originalObject)); | ||
delete dupe.prefixPattern; | ||
delete dupe.exactPattern; | ||
@@ -67,3 +54,3 @@ return dupe; | ||
types[MASTERCARD] = { | ||
niceType: 'MasterCard', | ||
niceType: 'Mastercard', | ||
type: MASTERCARD, | ||
@@ -70,0 +57,0 @@ prefixPattern: /^(5|5[1-5]|2|22|222|222[1-9]|2[3-6]|27|27[0-2]|2720)$/, |
{ | ||
"name": "credit-card-type", | ||
"version": "5.0.4", | ||
"version": "6.0.0", | ||
"description": "A library for determining credit card type", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,3 +44,3 @@ Credit Card Type [![Build Status](https://travis-ci.org/braintree/credit-card-type.svg)](https://travis-ci.org/braintree/credit-card-type) [![npm version](https://badge.fury.io/js/credit-card-type.svg)](http://badge.fury.io/js/credit-card-type) [![Bower](https://badge.fury.io/bo/credit-card-type.svg)](http://badge.fury.io/bo/credit-card-type) | ||
|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `niceType` | `String` | A pretty printed representation of the card brand.<br/>- `Visa`<br />- `MasterCard`<br />- `American Express`<br />- `Diners Club`<br />- `Discover`<br />- `JCB`<br />- `UnionPay`<br />- `Maestro` | | ||
| `niceType` | `String` | A pretty printed representation of the card brand.<br/>- `Visa`<br />- `Mastercard`<br />- `American Express`<br />- `Diners Club`<br />- `Discover`<br />- `JCB`<br />- `UnionPay`<br />- `Maestro` | | ||
| `type` | `String` | A code-friendly presentation of the card brand (useful to class names in CSS). Please refer to Card Type "Constants" below for the list of possible values.<br/>- `visa`<br />- `master-card`<br />- `american-express`<br />- `diners-club`<br />- `discover`<br />- `jcb`<br />- `unionpay`<br />- `maestro` | | ||
@@ -77,3 +77,3 @@ | `gaps` | `Array` | The expected indeces of gaps in a string representation of the card number. For example, in a Visa card, `4111 1111 1111 1111`, there are expected spaces in the 4th, 8th, and 12th positions. This is useful in setting your own formatting rules. | | ||
| `Visa` | `CVV` | 3 | | ||
| `MasterCard` | `CVC` | 3 | | ||
| `Mastercard` | `CVC` | 3 | | ||
| `American Express` | `CID` | 4 | | ||
@@ -98,4 +98,2 @@ | `Diners Club` | `CVV` | 3 | | ||
*Note:* The response also includes an `exactPattern` regex and a `prefixPattern` regex. These are used internally to determine the card type, but they should not be relied on and may be removed in the next major version. | ||
### Advanced Usage | ||
@@ -102,0 +100,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21588
335
155