<commit_before>// install  :     cordova plugin add https://github.com/randdusing/cordova-plugin-bluetoothle.git
// link     :     https://github.com/randdusing/cordova-plugin-bluetoothle

angular.module('ngCordovaBluetoothLE', []).factory('$cordovaBluetoothLE', ['$q', '$timeout', function($q, $timeout){
  var errorUnsupported = {
    error: "unsupported",
    message: "Operation unsupported"
  };


  var initialize = function(params) {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      window.bluetoothle.initialize(
        function(obj) {
          q.notify(obj);
        },
        params
      );
    }
    return q.promise;
  };

  var enable = function() {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      window.bluetoothle.enable(
        null,
        function(obj) {
          q.reject(obj);
        }
      );
    }
    return q.promise;
  };

  var disable = function() {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      window.bluetoothle.disable(
        null,
        function(obj) {
          q.reject(obj);
        }
      );
    }
    return q.promise;
  };

  var startScan = function(params) {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      var timeout = null;
      if (params.scanTimeout) {
        timeout = $timeout(function() {
          window.bluetoothle.stopScan(
            function(obj) {
              q.resolve(obj);
            },
            function(obj) {
              q.reject(obj);
            }
          );
        }, params.scanTimeout);
      }

      window.bluetoothle.startScan(
        function(obj) {
          q.notify(obj);
        },
        function(obj) {
          $timeout.cancel(timeout);
          q.reject(obj);
        },
        params
      );
    }
    return q.promise;
  };

  var stopScan = function() {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {<commit_msg>Prevent stopScan to be called on timeout<commit_after>// install  :     cordova plugin add https://github.com/randdusing/cordova-plugin-bluetoothle.git
// link     :     https://github.com/randdusing/cordova-plugin-bluetoothle

angular.module('ngCordovaBluetoothLE', []).factory('$cordovaBluetoothLE', ['$q', '$timeout', function($q, $timeout){
  var errorUnsupported = {
    error: "unsupported",
    message: "Operation unsupported"
  };


  var initialize = function(params) {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      window.bluetoothle.initialize(
        function(obj) {
          q.notify(obj);
        },
        params
      );
    }
    return q.promise;
  };

  var enable = function() {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      window.bluetoothle.enable(
        null,
        function(obj) {
          q.reject(obj);
        }
      );
    }
    return q.promise;
  };

  var disable = function() {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      window.bluetoothle.disable(
        null,
        function(obj) {
          q.reject(obj);
        }
      );
    }
    return q.promise;
  };

  var startScan = function(params) {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
      q.reject(errorUnsupported);
    } else {
      var timeout = null;
      if (params.scanTimeout) {
        timeout = $timeout(function() {
          window.bluetoothle.isScanning(function(obj) {
            if (obj.isScanning) {
              window.bluetoothle.stopScan(
                function(obj) {
                  q.resolve(obj);
                },
                function(obj) {
                  q.reject(obj);
                }
              );
            }
          });
        }, params.scanTimeout);
      }

      window.bluetoothle.startScan(
        function(obj) {
          q.notify(obj);
        },
        function(obj) {
          $timeout.cancel(timeout);
          q.reject(obj);
        },
        params
      );
    }
    return q.promise;
  };

  var stopScan = function() {
    var q = $q.defer();
    if (window.bluetoothle === undefined) {
{'fraction_non_alphanumeric': 0.13981626708492045, 'fraction_numerical': 0.0, 'mean_word_length': 1.777846919726198, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '4088958', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1368, 'n_words': 237}