credit-card-type
Advanced tools
Comparing version 9.1.0 to 10.0.0
@@ -0,1 +1,10 @@ | ||
# 10.0.0 | ||
- BREAKING CHANGES | ||
- Update Node to v18 | ||
-DevDependencies | ||
- Update prettier to v3 | ||
- Update eslint-plugin-prettier to v5 | ||
- Typescript to v5 | ||
# 9.1.0 | ||
@@ -2,0 +11,0 @@ |
@@ -47,3 +47,3 @@ "use strict"; | ||
]; | ||
var testOrder = clone_1.clone(ORIGINAL_TEST_ORDER); | ||
var testOrder = (0, clone_1.clone)(ORIGINAL_TEST_ORDER); | ||
function findType(cardType) { | ||
@@ -53,3 +53,3 @@ return customCards[cardType] || cardTypes[cardType]; | ||
function getAllCardTypes() { | ||
return testOrder.map(function (cardType) { return clone_1.clone(findType(cardType)); }); | ||
return testOrder.map(function (cardType) { return (0, clone_1.clone)(findType(cardType)); }); | ||
} | ||
@@ -66,3 +66,3 @@ function getCardPosition(name, ignoreErrorForNotExisting) { | ||
var results = []; | ||
if (!is_valid_input_type_1.isValidInputType(cardNumber)) { | ||
if (!(0, is_valid_input_type_1.isValidInputType)(cardNumber)) { | ||
return results; | ||
@@ -75,5 +75,5 @@ } | ||
var cardConfiguration = findType(cardType); | ||
add_matching_cards_to_results_1.addMatchingCardsToResults(cardNumber, cardConfiguration, results); | ||
(0, add_matching_cards_to_results_1.addMatchingCardsToResults)(cardNumber, cardConfiguration, results); | ||
}); | ||
var bestMatch = find_best_match_1.findBestMatch(results); | ||
var bestMatch = (0, find_best_match_1.findBestMatch)(results); | ||
if (bestMatch) { | ||
@@ -85,3 +85,3 @@ return [bestMatch]; | ||
creditCardType.getTypeInfo = function (cardType) { | ||
return clone_1.clone(findType(cardType)); | ||
return (0, clone_1.clone)(findType(cardType)); | ||
}; | ||
@@ -102,3 +102,3 @@ creditCardType.removeCard = function (name) { | ||
if (!originalObject) { | ||
throw new Error("\"" + cardType + "\" is not a recognized type. Use `addCard` instead.'"); | ||
throw new Error("\"".concat(cardType, "\" is not a recognized type. Use `addCard` instead.'")); | ||
} | ||
@@ -108,3 +108,3 @@ if (updates.type && originalObject.type !== updates.type) { | ||
} | ||
var clonedCard = clone_1.clone(originalObject); | ||
var clonedCard = (0, clone_1.clone)(originalObject); | ||
clonedCard = __assign(__assign({}, clonedCard), updates); | ||
@@ -119,3 +119,3 @@ customCards[clonedCard.type] = clonedCard; | ||
creditCardType.resetModifications = function () { | ||
testOrder = clone_1.clone(ORIGINAL_TEST_ORDER); | ||
testOrder = (0, clone_1.clone)(ORIGINAL_TEST_ORDER); | ||
customCards = {}; | ||
@@ -122,0 +122,0 @@ }; |
@@ -10,6 +10,6 @@ "use strict"; | ||
var pattern = cardConfiguration.patterns[i]; | ||
if (!matches_1.matches(cardNumber, pattern)) { | ||
if (!(0, matches_1.matches)(cardNumber, pattern)) { | ||
continue; | ||
} | ||
var clonedCardConfiguration = clone_1.clone(cardConfiguration); | ||
var clonedCardConfiguration = (0, clone_1.clone)(cardConfiguration); | ||
if (Array.isArray(pattern)) { | ||
@@ -16,0 +16,0 @@ patternLength = String(pattern[0]).length; |
@@ -74,3 +74,2 @@ "use strict"; | ||
620, | ||
[624, 626], | ||
[62100, 62182], | ||
@@ -82,5 +81,3 @@ [62184, 62187], | ||
622018, | ||
[622019, 622999], | ||
[62207, 62209], | ||
[622126, 622925], | ||
[623, 626], | ||
@@ -87,0 +84,0 @@ 6270, |
@@ -1,5 +0,5 @@ | ||
export declare type CreditCardTypeCardBrandId = "american-express" | "diners-club" | "discover" | "elo" | "hiper" | "hipercard" | "jcb" | "maestro" | "mastercard" | "mir" | "unionpay" | "visa"; | ||
declare type CreditCardTypeCardBrandNiceType = "American Express" | "Diners Club" | "Discover" | "Elo" | "Hiper" | "Hipercard" | "JCB" | "Maestro" | "Mastercard" | "Mir" | "UnionPay" | "Visa"; | ||
declare type CreditCardTypeSecurityCodeLabel = "CVV" | "CVC" | "CID" | "CVN" | "CVE" | "CVP2"; | ||
export declare type CreditCardType = { | ||
export type CreditCardTypeCardBrandId = "american-express" | "diners-club" | "discover" | "elo" | "hiper" | "hipercard" | "jcb" | "maestro" | "mastercard" | "mir" | "unionpay" | "visa"; | ||
type CreditCardTypeCardBrandNiceType = "American Express" | "Diners Club" | "Discover" | "Elo" | "Hiper" | "Hipercard" | "JCB" | "Maestro" | "Mastercard" | "Mir" | "UnionPay" | "Visa"; | ||
type CreditCardTypeSecurityCodeLabel = "CVV" | "CVC" | "CID" | "CVN" | "CVE" | "CVP2"; | ||
export type CreditCardType = { | ||
niceType: string; | ||
@@ -6,0 +6,0 @@ type: string; |
{ | ||
"name": "credit-card-type", | ||
"version": "9.1.0", | ||
"version": "10.0.0", | ||
"description": "A library for determining credit card type", | ||
@@ -23,9 +23,11 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.13", | ||
"eslint": "^7.8.1", | ||
"eslint-config-braintree": "^5.0.0-typescript-prep-rc.18", | ||
"jest": "^26.4.2", | ||
"prettier": "^2.1.1", | ||
"ts-jest": "^26.3.0", | ||
"typescript": "^3.9.7" | ||
"@types/jest": "^29.5.3", | ||
"@typescript-eslint/eslint-plugin": "^5.54.1", | ||
"eslint": "^8.47.0", | ||
"eslint-config-braintree": "^6.0.0-typescript-prep-rc.2", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"jest": "^29.6.3", | ||
"prettier": "^3.0.2", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -32,0 +34,0 @@ "jest": { |
@@ -1,2 +0,2 @@ | ||
# 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) | ||
# Credit Card Type [![Build Status](https://github.com/braintree/credit-card-type/workflows/Unit%20Tests/badge.svg)](https://github.com/braintree/credit-card-type/actions?query=workflow%3A%22Unit+Tests%22) [![npm version](https://badge.fury.io/js/credit-card-type.svg)](http://badge.fury.io/js/credit-card-type) | ||
@@ -20,2 +20,3 @@ Credit Card Type provides a useful utility method for determining a credit card type from both fully qualified and partial numbers. This is not a validation library but rather a smaller component to help you build your own validation or UI library. | ||
// The card number provided should be normalized prior to usage here. | ||
var visaCards = creditCardType("4111"); | ||
@@ -47,2 +48,4 @@ console.log(visaCards[0].type); // 'visa' | ||
_Note:_ The card number provided should be normalized ahead of time. The card number string should not contain any non-integer values (e.g. no letters or special characters) | ||
### `creditCardType.getTypeInfo(type: String)` | ||
@@ -49,0 +52,0 @@ |
@@ -52,3 +52,3 @@ import cardTypes = require("./lib/card-types"); | ||
return testOrder.map( | ||
(cardType) => clone(findType(cardType)) as CreditCardType | ||
(cardType) => clone(findType(cardType)) as CreditCardType, | ||
); | ||
@@ -59,3 +59,3 @@ } | ||
name: string, | ||
ignoreErrorForNotExisting = false | ||
ignoreErrorForNotExisting = false, | ||
): number { | ||
@@ -118,3 +118,3 @@ const position = testOrder.indexOf(name); | ||
cardType: string, | ||
updates: Partial<CreditCardType> | ||
updates: Partial<CreditCardType>, | ||
): void => { | ||
@@ -125,3 +125,3 @@ const originalObject = customCards[cardType] || cardTypes[cardType]; | ||
throw new Error( | ||
`"${cardType}" is not a recognized type. Use \`addCard\` instead.'` | ||
`"${cardType}" is not a recognized type. Use \`addCard\` instead.'`, | ||
); | ||
@@ -128,0 +128,0 @@ } |
@@ -8,3 +8,3 @@ import { clone } from "./clone"; | ||
cardConfiguration: CreditCardType, | ||
results: Array<CreditCardType> | ||
results: Array<CreditCardType>, | ||
): void { | ||
@@ -11,0 +11,0 @@ let i, patternLength; |
@@ -75,3 +75,2 @@ import type { BuiltInCreditCardType, CardCollection } from "../types"; | ||
620, | ||
[624, 626], | ||
[62100, 62182], | ||
@@ -83,5 +82,3 @@ [62184, 62187], | ||
622018, | ||
[622019, 622999], | ||
[62207, 62209], | ||
[622126, 622925], | ||
[623, 626], | ||
@@ -88,0 +85,0 @@ 6270, |
import { CreditCardType } from "../types"; | ||
function hasEnoughResultsToDetermineBestMatch( | ||
results: CreditCardType[] | ||
results: CreditCardType[], | ||
): boolean { | ||
const numberOfResultsWithMaxStrengthProperty = results.filter( | ||
(result) => result.matchStrength | ||
(result) => result.matchStrength, | ||
).length; | ||
@@ -22,3 +22,3 @@ | ||
export function findBestMatch( | ||
results: CreditCardType[] | ||
results: CreditCardType[], | ||
): CreditCardType | null { | ||
@@ -25,0 +25,0 @@ if (!hasEnoughResultsToDetermineBestMatch(results)) { |
@@ -8,3 +8,3 @@ /* | ||
min: number | string, | ||
max: number | string | ||
max: number | string, | ||
): boolean { | ||
@@ -35,3 +35,3 @@ const maxLengthToCheck = String(min).length; | ||
cardNumber: string, | ||
pattern: string | number | string[] | number[] | ||
pattern: string | number | string[] | number[], | ||
): boolean { | ||
@@ -38,0 +38,0 @@ if (Array.isArray(pattern)) { |
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
43254
280
9
951