<commit_before>'use strict';
( function() {
  // get some stuff we need to support IIN Checker
  var _ = require( 'lodash' );
  var request = require( 'request' );
  // Load all of our providers into an array that we can loop over.
  var providers = require( '../configs/providers' );

  var iinChecker = function( iinOptions ) {
    // default options
    this.options = {
      language: 'en',
      cache: false
    };
    // if there's any overriding options, blat them over the defaults
    this.options = _.extend( this.options, iinOptions );

    // Define our constants for comparison
    this.nullValue = 'UNKNOWN'; /* Value incase services are offline or return null */
    this.brands = {
      VISA: 'VISA',
      MASTERCARD: 'MASTERCARD',
      AMEX: 'AMERICAN EXPRESS',
      DISCOVER: 'DISCOVER',
      DINERS: 'DINERS CLUB',
      JCB: 'JCB',
      MAESTRO: 'MAESTRO',
      LASER: 'LASER',
      UNKNOWN: this.nullValue
    };
    // DANKORT what do we do with this?
    // CHINA UNION PAY
    // SOLO
    // ELECTRON ??? Don't support? Visa Electron

    // DINERS has been added for RegEx, but both Robbin and BinList return these cards as DISCOVER
    // TODO: Change this later to be consitent across RegEx and providers

    this.types = {
      DEBIT: 'DEBIT',
      CREDIT: 'CREDIT',
      UNKNOWN: this.nullValue
    };

    // now fetch the language settings based on the requested language
    this.options.messages = require( './i18n/' + this.options.language ); // ISO 639‑1

    this.makeRequest = function( iin, providerCount, callback ) {
      var self = this;
      var cardInfo;
      var providerDetails = providers[providerCount];

      request( { url: providerDetails.domain + providerDetails.path + iin, json: true }, function( error, response, body ) {
        if ( !error && response.statusCode === 200 ) {
          // Remap the reply to match our schema
          cardInfo = providerDetails.map( body, self.nullValue );
          // if caching is on, provider request is only attempted if card details were not
          // in the cache now we have the details set it.
          if ( self.options.cache &&
            cardInfo.brand && cardInfo.brand !== self.brands.UNKNOWN &&
            cardInfo.type && cardInfo.type !== self.nullValue ) {
            self.options.cache.set( iin, cardInfo );
          }

          // send the results back a-la-node<commit_msg>move check to verify is card details are cacheable to a function<commit_after>'use strict';
( function() {
  // get some stuff we need to support IIN Checker
  var _ = require( 'lodash' );
  var request = require( 'request' );
  // Load all of our providers into an array that we can loop over.
  var providers = require( '../configs/providers' );

  var iinChecker = function( iinOptions ) {
    // default options
    this.options = {
      language: 'en',
      cache: false
    };
    // if there's any overriding options, blat them over the defaults
    this.options = _.extend( this.options, iinOptions );

    // Define our constants for comparison
    this.nullValue = 'UNKNOWN'; /* Value incase services are offline or return null */
    this.brands = {
      VISA: 'VISA',
      MASTERCARD: 'MASTERCARD',
      AMEX: 'AMERICAN EXPRESS',
      DISCOVER: 'DISCOVER',
      DINERS: 'DINERS CLUB',
      JCB: 'JCB',
      MAESTRO: 'MAESTRO',
      LASER: 'LASER',
      UNKNOWN: this.nullValue
    };
    // DANKORT what do we do with this?
    // CHINA UNION PAY
    // SOLO
    // ELECTRON ??? Don't support? Visa Electron

    // DINERS has been added for RegEx, but both Robbin and BinList return these cards as DISCOVER
    // TODO: Change this later to be consitent across RegEx and providers

    this.types = {
      DEBIT: 'DEBIT',
      CREDIT: 'CREDIT',
      UNKNOWN: this.nullValue
    };

    // now fetch the language settings based on the requested language
    this.options.messages = require( './i18n/' + this.options.language ); // ISO 639‑1

    this.isCacheable = function( cardInfo ) {
      if ( this.options.cache &&
          cardInfo.brand && cardInfo.brand !== this.brands.UNKNOWN &&
          cardInfo.type && cardInfo.type !== this.nullValue
      ) {
        return true;
      }
      return false;
    };

    this.makeRequest = function( iin, providerCount, callback ) {
      var self = this;
      var cardInfo;
      var providerDetails = providers[providerCount];

      request( { url: providerDetails.domain + providerDetails.path + iin, json: true }, function( error, response, body ) {
        if ( !error && response.statusCode === 200 ) {
          // Remap the reply to match our schema
          cardInfo = providerDetails.map( body, self.nullValue );
          // if caching is on, provider request is only attempted if card details were not
          // in the cache now we have the details set it.
          if ( self.isCacheable( cardInfo ) ) {
            self.options.cache.set( iin, cardInfo );
          }

          // send the results back a-la-node
{'fraction_non_alphanumeric': 0.10756972111553785, 'fraction_numerical': 0.0035856573705179283, 'mean_word_length': 2.33843085106383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6768426', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1441, 'n_words': 504}