<commit_before>var Parser = require('../../lib/compliance/parsepdf417');
var PairingData = require('../pairingdata');

module.exports = {
  config: config,
  camOn: camOn,
  camOff: camOff,
  scanPairingCode: scanPairingCode,
  scanMainQR: scanMainQR,
  scanPDF417: scanPDF417,
  scanPhotoID: scanPhotoID,
  cancel: cancel
};

var configuration = null;
var _cancelCb = null;

function config(_configuration) {
  configuration = _configuration.mock.data;
}

function camOn() {
}

function camOff(cb) {
  cb();
}

function scanPairingCode(callback) {
  var pairingData = PairingData.process(configuration.pairingData);
  return setTimeout(function () { callback(null, pairingData); }, 500);
}

function scanMainQR(callback) {
  var qrData = configuration.qrData;
  console.log('DEBUG scanning');
  console.dir(configuration);
  _cancelCb = function cancel() {
    callback(null, null);
  };
  return setTimeout(function () {
    callback(null, qrData);
  }, 4000);
}

function scanPDF417(callback) {
  var pdf417Data = configuration.pdf417Data;
  setTimeout(function() { callback(null, Parser.parse(pdf417Data)); }, 800);
}

function scanPhotoID(callback) {
  var fakeLicense = configuration.fakeLicense;
  setTimeout(function() { callback(null, fakeLicense); }, 800);
}

function cancel() {
  if (_cancelCb) _cancelCb();
}<commit_msg>fix(mock/scanner) fix bitcoin address parsing<commit_after>var Parser = require('../../lib/compliance/parsepdf417');
var PairingData = require('../pairingdata');

module.exports = {
  config: config,
  camOn: camOn,
  camOff: camOff,
  scanPairingCode: scanPairingCode,
  scanMainQR: scanMainQR,
  scanPDF417: scanPDF417,
  scanPhotoID: scanPhotoID,
  cancel: cancel
};

var configuration = null;
var _cancelCb = null;

function config(_configuration) {
  configuration = _configuration.mock.data;
}

function camOn() {
}

function camOff(cb) {
  cb();
}

function scanPairingCode(callback) {
  var pairingData = PairingData.process(configuration.pairingData);
  return setTimeout(function () { callback(null, pairingData); }, 500);
}

function parseBitcoinURI(uri) {
  var res = /^(bitcoin:\/{0,2})?(\w+)/.exec(uri);
  var address = res && res[2];
  if (!address) {
    return null;
  } else return address;
}

function scanMainQR(callback) {
  var qrData = parseBitcoinURI(configuration.qrData);
  console.log('DEBUG scanning');
  console.dir(configuration);
  _cancelCb = function cancel() {
    callback(null, null);
  };
  return setTimeout(function () {
    callback(null, qrData);
  }, 1000);
}

function scanPDF417(callback) {
  var pdf417Data = configuration.pdf417Data;
  setTimeout(function() { callback(null, Parser.parse(pdf417Data)); }, 800);
}

function scanPhotoID(callback) {
  var fakeLicense = configuration.fakeLicense;
  setTimeout(function() { callback(null, fakeLicense); }, 800);
}

function cancel() {
  if (_cancelCb) _cancelCb();
}
{'fraction_non_alphanumeric': 0.13939813213420962, 'fraction_numerical': 0.02455897613282601, 'mean_word_length': 5.0, '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': '2930640', 'n_tokens_mistral': 1001, 'n_tokens_neox': 928, 'n_words': 198}