<commit_before>'use strict';
/*
 * BLECAST_BL (BLE with Illuminance Sensor) node
 * BLECAST_TM (BLE with Temeprature Sensor) node
 */

import * as blecastBl from './lib/blecast_bl';
import * as blecastTm from './lib/blecast_tm';
import * as ble from './lib/ble';

export default function(RED) {
  ble.start(RED).then(() => {
    function BlecastBlNode(n) {
      RED.nodes.createNode(this, n);
      this.address = n.address;
      this.uuid = n.uuid;
    }
    RED.nodes.registerType('BLECAST_BL', BlecastBlNode);

    function BlecastBlInNode(n) {
      RED.nodes.createNode(this, n);
      this.useString = n.useString;
      this.blecastBlNodeId = n.blecastBl;
      this.blecastBlNode = RED.nodes.getNode(this.blecastBlNodeId);
      ble.registerIn(this, 'BLECAST_BL', this.blecastBlNode.address, this.blecastBlNode.uuid,
        blecastBl.parse, this.useString, RED);
      this.name = n.name;
    }
    RED.nodes.registerType('BLECAST_BL in', BlecastBlInNode);

    function BlecastTmNode(n) {
      RED.nodes.createNode(this, n);
      this.address = n.address;
      this.uuid = n.uuid;
    }
    RED.nodes.registerType('BLECAST_TM', BlecastTmNode);

    function BlecastTmInNode(n) {
      RED.nodes.createNode(this, n);
      this.useString = n.useString;
      this.blecastTmNodeId = n.blecastTm;
      this.blecastTmNode = RED.nodes.getNode(this.blecastTmNodeId);
      ble.registerIn(this, 'BLECAST_TM', this.blecastTmNode.address, this.blecastTmNode.uuid,
        blecastTm.parse, this.useString, RED);
      this.name = n.name;
    }
    RED.nodes.registerType('BLECAST_TM in', BlecastTmInNode);

  }).catch(e => {
    RED.log.error(RED._('blecast_bl.errors.unknown', { error: e }));
  });
}
<commit_msg>Return a Promise object when the debug flag is enabled<commit_after>'use strict';
/*
 * BLECAST_BL (BLE with Illuminance Sensor) node
 * BLECAST_TM (BLE with Temeprature Sensor) node
 */

import * as blecastBl from './lib/blecast_bl';
import * as blecastTm from './lib/blecast_tm';
import * as ble from './lib/ble';
import Promise from 'es6-promises';

export default function(RED) {
  let p = new Promise((resolve, reject) => {
    ble.start(RED).then(() => {
      function BlecastBlNode(n) {
        RED.nodes.createNode(this, n);
        this.address = n.address;
        this.uuid = n.uuid;
      }
      RED.nodes.registerType('BLECAST_BL', BlecastBlNode);

      function BlecastBlInNode(n) {
        RED.nodes.createNode(this, n);
        this.useString = n.useString;
        this.blecastBlNodeId = n.blecastBl;
        this.blecastBlNode = RED.nodes.getNode(this.blecastBlNodeId);
        ble.registerIn(this, 'BLECAST_BL', this.blecastBlNode.address, this.blecastBlNode.uuid,
          blecastBl.parse, this.useString, RED);
        this.name = n.name;
      }
      RED.nodes.registerType('BLECAST_BL in', BlecastBlInNode);

      function BlecastTmNode(n) {
        RED.nodes.createNode(this, n);
        this.address = n.address;
        this.uuid = n.uuid;
      }
      RED.nodes.registerType('BLECAST_TM', BlecastTmNode);

      function BlecastTmInNode(n) {
        RED.nodes.createNode(this, n);
        this.useString = n.useString;
        this.blecastTmNodeId = n.blecastTm;
        this.blecastTmNode = RED.nodes.getNode(this.blecastTmNodeId);
        ble.registerIn(this, 'BLECAST_TM', this.blecastTmNode.address, this.blecastTmNode.uuid,
          blecastTm.parse, this.useString, RED);
        this.name = n.name;
      }
      RED.nodes.registerType('BLECAST_TM in', BlecastTmInNode);
      resolve();

    }).catch(e => {
      RED.log.error(RED._('blecast_bl.errors.unknown', { error: e }));
      reject(e);
    });
  });

  if (RED.debug) {
    return p;
  }
}

{'fraction_non_alphanumeric': 0.13712284482758622, 'fraction_numerical': 0.00026939655172413793, 'mean_word_length': 2.95, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '1211320', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1298, 'n_words': 226}