Another module for card detection, with special attention for brazilian cards like Elo and Hipercard.
- American Express
- Diners Club
You can install it through NPM:
npm install @polvo-labs/card-type --save
Or you can just copy
dist/card-type.js and include it into your project.
// ES6// CommonJSvar cardType = cardTypevar cards = cards// Globalvar cardType = windowCardTypecardTypevar cards = windowCardTypecards
NOTE: You don't need to import
cardsunless you want to extend it and include your own cards and patterns.
cardType (number) => String
The function that returns your card type.
// 'visa'// 'mastercard'// 'hipercard'// ''
cards : Array
An array with card patterns and ranges. You can extend it and include your own cards.
cards// 'my-card'// 'my-card'// 'my-card'// 'my-card'
Make sure to install all dependencies:
Then, just run:
Did you miss a card? Contributions are welcome!