<commit_before># IIN Checker for payment cards
[![Circle CI](https://circleci.com/gh/holidayextras/iinChecker/tree/master.svg?style=svg&circle-token=<PASSWORD>)](https://circleci.com/gh/holidayextras/iinChecker)
[![Dependency status](https://david-dm.org/holidayextras/iinChecker/status.png)](https://david-dm.org/holidayextras/iinChecker#info=dependencies&view=table)
[![Dev Dependency Status](https://david-dm.org/holidayextras/iinChecker/dev-status.png)](https://david-dm.org/holidayextras/iinChecker#info=devDependencies&view=table)

[![NPM](https://nodei.co/npm/iin-checker.png)](https://nodei.co/npm/iin-checker/)

## About

Issuer identification number checker which returns details about a credit/debit and other payment cards

### Additional resources and links
- [Wikipedia: ISO/IEC 7812 Standard](http://en.wikipedia.org/wiki/ISO/IEC_7812)
- [Wikipedia: Rules arround bank cards numbers](http://en.wikipedia.org/wiki/Bank_card_number)
- [StackOverflow: RegEx for calculating brand](http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number)
- [Another NPM Card Module](https://github.com/observing/creditcard)

## Installation

The module is available in the NPM registery. It can be installed using the
`npm` commandline utlity.

```
npm install iin-checker
```

Once you have installed the module you can simply require inside of your Node.js
application and use it's exported methods. Here is a simple example of that which gets the card details back as an object:

```js
var IinChecker = require( 'iin-checker' );
// Initialise with default options no caching
var iin = new IinChecker( {} );

// Initialise with caching
var iin = new IinChecker( {
    cache: true,
    cacheServerConfig: {}
    cachePolicy: [
        {
          'segment': 'iinChecker',
          'expiresIn': 86400000
        }
      ]
} );



iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    console.log( 'Result:', result );
  }
} );
```
### Caching
Caching is turned off by default. Currently supports redis cache and in-memory cache.
It can be turned on and will be set to in-memory caching if cacheServerConfig is empty.
The cache time to live(expiresIn) is set to a day (86400000 ms) and segement is set to 'iinChecker' by default this can be overridden by passing custom 'cachePolicy'.


### Card Type Detection

If you want to test to see if the card is a Credit or Debit card you can can achive this in the following way:

```js
var IinChecker = require( 'iin-checker' );
var iin = new IinChecker( {} );

iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    var isDebit = ( result.type === iin.types.DEBIT )
    console.log( 'Debit?:', isDebit );
  }
} );
```

Possible values for _iin.types_ are **DEBIT**, **CREDIT** and **UNKNOWN**.

### Card Brand Detection

If you want to test to see which brand the card is, you can can achive this in the following way:

```js
var IinChecker = require( 'iin-checker' );
var iin = new IinChecker( {} );

iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    var isMastercard = ( result.brand === iin.brands.MASTERCARD )
    console.log( 'Mastercard?:', isMastercard );
  }
} );
```

Possible values for _iin.brands_ are **VISA**, **MASTERCARD**, **AMEX**, **DISCOVER**, **JCB**, **MAESTRO** and **LASER**. In future more card brands will be supported, if you need a brand adding please raise an issue.

## [Changelog](CHANGELOG.md)

## [Contributing](CONTRIBUTING.md)


## License
Copyright (c) 2014 Shortbreaks
Licensed under the MIT license.

## Todo
- Get non-provider RegEx alternative
- Read providers from configs (as the tests do)
- Allow preference of providers to be passed into options
- Support caching

<commit_msg>code review tweaks<commit_after># IIN Checker for payment cards
[![Circle CI](https://circleci.com/gh/holidayextras/iinChecker/tree/master.svg?style=svg&circle-token=<PASSWORD>)](https://circleci.com/gh/holidayextras/iinChecker)
[![Dependency status](https://david-dm.org/holidayextras/iinChecker/status.png)](https://david-dm.org/holidayextras/iinChecker#info=dependencies&view=table)
[![Dev Dependency Status](https://david-dm.org/holidayextras/iinChecker/dev-status.png)](https://david-dm.org/holidayextras/iinChecker#info=devDependencies&view=table)

[![NPM](https://nodei.co/npm/iin-checker.png)](https://nodei.co/npm/iin-checker/)

## About

Issuer identification number checker which returns details about a credit/debit and other payment cards

### Additional resources and links
- [Wikipedia: ISO/IEC 7812 Standard](http://en.wikipedia.org/wiki/ISO/IEC_7812)
- [Wikipedia: Rules arround bank cards numbers](http://en.wikipedia.org/wiki/Bank_card_number)
- [StackOverflow: RegEx for calculating brand](http://stackoverflow.com/questions/72768/how-do-you-detect-credit-card-type-based-on-number)
- [Another NPM Card Module](https://github.com/observing/creditcard)

## Installation

The module is available in the NPM registery. It can be installed using the
`npm` commandline utlity.

```
npm install iin-checker
```

Once you have installed the module you can simply require inside of your Node.js
application and use it's exported methods. Here is a simple example of that which gets the card details back as an object:

```js
var IinChecker = require( 'iin-checker' );
// Initialise with default options no caching
var iin = new IinChecker( {} );

// Initialise with caching
var iin = new IinChecker( {
    cache: true,
    cacheServerConfig: {},
    cachePolicy: [
        {
          'segment': 'iinChecker',
          'expiresIn': 86400000
        }
      ]
} );



iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    console.log( 'Result:', result );
  }
} );
```
### Caching
Caching is turned off by default. Currently supports redis cache and in-memory cache.
It can be turned on and will be set to in-memory caching if cacheServerConfig is empty.
The cache time to live(expiresIn) is set to a day (86400000 ms) and segement is set to 'iinChecker' by default this can be overridden by passing custom 'cachePolicy'.


### Card Type Detection

If you want to test to see if the card is a Credit or Debit card you can can achive this in the following way:

```js
var IinChecker = require( 'iin-checker' );
var iin = new IinChecker( {} );

iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    var isDebit = ( result.type === iin.types.DEBIT )
    console.log( 'Debit?:', isDebit );
  }
} );
```

Possible values for _iin.types_ are **DEBIT**, **CREDIT** and **UNKNOWN**.

### Card Brand Detection

If you want to test to see which brand the card is, you can can achive this in the following way:

```js
var IinChecker = require( 'iin-checker' );
var iin = new IinChecker( {} );

iin.lookup( '543210', function( err, result ) {
  if ( err ) {
    console.log( 'Error:', err );
  } else {
    var isMastercard = ( result.brand === iin.brands.MASTERCARD )
    console.log( 'Mastercard?:', isMastercard );
  }
} );
```

Possible values for _iin.brands_ are **VISA**, **MASTERCARD**, **AMEX**, **DISCOVER**, **JCB**, **MAESTRO** and **LASER**. In future more card brands will be supported, if you need a brand adding please raise an issue.

## [Changelog](CHANGELOG.md)

## [Contributing](CONTRIBUTING.md)


## License
Copyright (c) 2014 Shortbreaks
Licensed under the MIT license.

## Todo
- Get non-provider RegEx alternative
- Read providers from configs (as the tests do)
- Allow preference of providers to be passed into options
- Support caching


{'fraction_non_alphanumeric': 0.1339953572349755, 'fraction_numerical': 0.013154500902759866, 'mean_word_length': 4.065316786414108, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2382564', 'n_tokens_mistral': 2642, 'n_tokens_neox': 2516, 'n_words': 788}