credit-card-type
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -0,1 +1,6 @@ | ||
5.0.1 | ||
===== | ||
- Visa cards can now be 16, 18, or 19 digits. | ||
5.0.0 | ||
@@ -2,0 +7,0 @@ ===== |
@@ -1,2 +0,2 @@ | ||
(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(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){ | ||
'use strict'; | ||
@@ -48,3 +48,3 @@ | ||
gaps: [4, 8, 12], | ||
lengths: [16], | ||
lengths: [16, 18, 19], | ||
code: { | ||
@@ -193,2 +193,3 @@ name: CVV, | ||
},{}]},{},[1]); | ||
},{}]},{},[1])(1) | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function e(t,r,n){function a(s,p){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!p&&c)return c(s,!0);if(i)return i(s,!0);var o=new Error("Cannot find module '"+s+"'");throw o.code="MODULE_NOT_FOUND",o}var f=r[s]={exports:{}};t[s][0].call(f.exports,function(e){var r=t[s][1][e];return a(r?r:e)},f,f.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s<n.length;s++)a(n[s]);return a}({1:[function(e,t,r){"use strict";function n(e){var t,r,n;return e?(t=e.prefixPattern.source,r=e.exactPattern.source,n=JSON.parse(JSON.stringify(e)),n.prefixPattern=t,n.exactPattern=r,n):null}function a(e){var t,r,a,s=[],p=[];if(!("string"==typeof e||e instanceof String))return[];for(a=0;a<h.length;a++)t=h[a],r=i[t],0!==e.length?r.exactPattern.test(e)?p.push(n(r)):r.prefixPattern.test(e)&&s.push(n(r)):s.push(n(r));return p.length?p:s}var i={},s="visa",p="master-card",c="american-express",o="diners-club",f="discover",u="jcb",x="unionpay",P="maestro",d="CVV",g="CID",y="CVC",l="CVN",h=[s,p,c,o,f,u,x,P];i[s]={niceType:"Visa",type:s,prefixPattern:/^4$/,exactPattern:/^4\d*$/,gaps:[4,8,12],lengths:[16],code:{name:d,size:3}},i[p]={niceType:"MasterCard",type:p,prefixPattern:/^(5|5[1-5]|2|22|222|222[1-9]|2[3-6]|27[0-1]|2720)$/,exactPattern:/^(5[1-5]|222[1-9]|2[3-6]|27[0-1]|2720)\d*$/,gaps:[4,8,12],lengths:[16],code:{name:y,size:3}},i[c]={niceType:"American Express",type:c,prefixPattern:/^(3|34|37)$/,exactPattern:/^3[47]\d*$/,isAmex:!0,gaps:[4,10],lengths:[15],code:{name:g,size:4}},i[o]={niceType:"Diners Club",type:o,prefixPattern:/^(3|3[0689]|30[0-5])$/,exactPattern:/^3(0[0-5]|[689])\d*$/,gaps:[4,10],lengths:[14],code:{name:d,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:g,size:3}},i[u]={niceType:"JCB",type:u,prefixPattern:/^(2|21|213|2131|1|18|180|1800|3|35)$/,exactPattern:/^(2131|1800|35)\d*$/,gaps:[4,8,12],lengths:[16],code:{name:d,size:3}},i[x]={niceType:"UnionPay",type:x,prefixPattern:/^(6|62)$/,exactPattern:/^62\d*$/,gaps:[4,8,12],lengths:[16,17,18,19],code:{name:l,size:3}},i[P]={niceType:"Maestro",type:P,prefixPattern:/^(5|5[06-9]|6\d*)$/,exactPattern:/^5[06-9]\d*$/,gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:y,size:3}},a.getTypeInfo=function(e){return n(i[e])},a.types={VISA:s,MASTERCARD:p,AMERICAN_EXPRESS:c,DINERS_CLUB:o,DISCOVER:f,JCB:u,UNIONPAY:x,MAESTRO:P},t.exports=a},{}]},{},[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",u="jcb",d="unionpay",x="maestro",y="CVV",l="CID",g="CVC",P="CVN",m=[s,p,o,c,f,u,d,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[0-1]|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],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[u]={niceType:"JCB",type:u,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[d]={niceType:"UnionPay",type:d,prefixPattern:/^(6|62)$/,exactPattern:/^62\d*$/,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]\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:u,UNIONPAY:d,MAESTRO:x},t.exports=a},{}]},{},[1])(1)}); |
@@ -47,3 +47,3 @@ 'use strict'; | ||
gaps: [4, 8, 12], | ||
lengths: [16], | ||
lengths: [16, 18, 19], | ||
code: { | ||
@@ -50,0 +50,0 @@ name: CVV, |
{ | ||
"name": "credit-card-type", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "A library for determining credit card type", | ||
@@ -29,8 +29,5 @@ "main": "index.js", | ||
"gulp-uglify": "^1.0.2", | ||
"gulp-watch": "^0.6.8", | ||
"mocha": "^3.0.0", | ||
"sinon": "^1.14.1", | ||
"sinon-chai": "^2.7.0", | ||
"vinyl-source-stream": "^1.0.0" | ||
} | ||
} |
@@ -9,5 +9,5 @@ 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) | ||
## Download | ||
To install via npm: | ||
To install via npm: | ||
``` | ||
```bash | ||
npm install credit-card-type | ||
@@ -18,3 +18,3 @@ ``` | ||
``` | ||
```bash | ||
bower install credit-card-type | ||
@@ -44,10 +44,10 @@ ``` | ||
| Key | Type | Description | | ||
| --- | ---- | ----------- | | ||
| `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` | | ||
| `pattern` | `RegExp` | The regular expression used to determine the card type. | | ||
| `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. | | ||
| `lengths` | `Array` | The expected lengths of the card number as an array of strings (excluding spaces and `/` characters). | | ||
| `code` | `Object` | The information regarding the security code for the determined card. Learn more about the [code object](#code) below. | | ||
| Key | Type | Description | | ||
|------------|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `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` | | ||
| `pattern` | `RegExp` | The regular expression used to determine the card type. | | ||
| `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. | | ||
| `lengths` | `Array` | The expected lengths of the card number as an array of strings (excluding spaces and `/` characters). | | ||
| `code` | `Object` | The information regarding the security code for the determined card. Learn more about the [code object](#code) below. | | ||
@@ -77,16 +77,16 @@ If no card types are found, this returns an empty array. | ||
| Brand | Name | Size | | ||
| ----- | ---- | ---- | | ||
| `Visa` | `CVV` | 3 | | ||
| `MasterCard` | `CVC` | 3 | | ||
| `American Express` | `CID` | 4 | | ||
| `Diners Club` | `CVV` | 3 | | ||
| `Discover` | `CID` | 3 | | ||
| `JCB` | `CVV` | 3 | | ||
| `UnionPay` | `CVN` | 3 | | ||
| `Maestro` | `CVC` | 3 | | ||
| Brand | Name | Size | | ||
|--------------------|-------|------| | ||
| `Visa` | `CVV` | 3 | | ||
| `MasterCard` | `CVC` | 3 | | ||
| `American Express` | `CID` | 4 | | ||
| `Diners Club` | `CVV` | 3 | | ||
| `Discover` | `CID` | 3 | | ||
| `JCB` | `CVV` | 3 | | ||
| `UnionPay` | `CVN` | 3 | | ||
| `Maestro` | `CVC` | 3 | | ||
A full response for a `Visa` card will look like this: | ||
```js | ||
```javascript | ||
{ | ||
@@ -106,3 +106,3 @@ niceType: 'Visa', | ||
``` | ||
```javascript | ||
var creditCardType = require('credit-card-type'); | ||
@@ -115,12 +115,12 @@ var getTypeInfo = require('credit-card-type').getTypeInfo; | ||
```javascript | ||
import creditCardType, { getTypeInfo, types as CardType } from 'credit-card-type'; | ||
``` | ||
import creditCardType, { getTypeInfo, types as CardType } from 'credit-card-type') | ||
``` | ||
#### Filtering | ||
``` | ||
```javascript | ||
creditCardType(cardNumber).filter(function(card) { | ||
return card.type == CardType.MASTERCARD || card.type == CardType.VISA; | ||
}) | ||
}); | ||
``` | ||
@@ -130,3 +130,3 @@ | ||
``` | ||
```javascript | ||
function prettyCardNumber(cardNumber, cardType) { | ||
@@ -158,3 +158,3 @@ var card = getTypeInfo(cardType); | ||
``` | ||
```bash | ||
nvm install | ||
@@ -161,0 +161,0 @@ npm install |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20623
12
339
0