VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol__src__AppPattern__circuit__CCBlock.js
/*** module: node_modules/absol/src/AppPattern/circuit/CCBlock.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _stringGenerate = require("../../String/stringGenerate");

var _safeThrow = _interopRequireDefault(require("../../Code/safeThrow"));


/***
 *
 * @param {{id?:string}=} opt
 * @constructor
 */
function CCBlock(opt) {
  opt = opt || {};
  this.id = opt.id || (0, _stringGenerate.randomIdent)(16);
  Object.defineProperty(this, '__cc_listener__', {
    enumerable: false,
    configurable: true,
    writable: false,
    value: {}
  });
  Object.defineProperty(this, '__cc_line_list_by_id__', {
    enumerable: false,
    configurable: true,
    writable: false,
    value: {}
  });
}
/***
 *
 * @param {string} pinName
 * @param {function} listener
 * @return {CCBlock}
 */


CCBlock.prototype.pinOn = function (pinName, listener) {
  var cbList;

  if (this.__cc_listener__[pinName]) {
    cbList = this.__cc_listener__[pinName];
  } else {
    cbList = [];
    this.__cc_listener__[pinName] = cbList;
  }

  if (cbList.indexOf(listener) < 0) {
    cbList.push(listener);
  } else {
    console.warn("Duplicate pin listener!");
  }

  return this;
};

CCBlock.prototype.pinOff = function (pinName, listener) {
  if (!this.__cc_listener__[pinName]) return this;
  var cbList = this.__cc_listener__[pinName];
  var cbIdx = cbList.indexOf(listener);

  if (cbIdx >= 0) {
    cbList.splice(cbIdx);
  }

  return this;
};

CCBlock.prototype.pinFire = function (pinName) {
  if (!this.__cc_listener__[pinName]) return this;

  var cbList = this.__cc_listener__[pinName].slice();

  var args = Array.prototype.slice.call(arguments, 1);
  if (args.length === 0 && this.pinHandlers[pinName] && this.pinHandlers[pinName].get && cbList.length > 0) args.push(this.pinGetValue(pinName));

  for (var i = 0; i < cbList.length; ++i) {
    try {
      cbList[i].apply(this, args);
    } catch (e) {
      (0, _safeThrow.default)(e);
    }
  }
};

CCBlock.prototype.pinFireAll = function () {
  var pinNames = Object.keys(this.pinHandlers);
  var pinName;

  for (var i = 0; i < pinNames.length; ++i) {
    pinName = pinNames[i];
    if (this.pinHandlers[pinName] && this.pinHandlers[pinName].get) this.pinFire(pinName);
  }
};

CCBlock.prototype.pinReceives = function (pinName) {
  var args = Array.prototype.slice.call(arguments, 1);

  if (this.pinHandlers[pinName] && this.pinHandlers[pinName].receives) {
    this.pinHandlers[pinName].receives.apply(this, args);
  }
};

CCBlock.prototype.pinGetValue = function (pinName) {
  var args = Array.prototype.slice.call(arguments, 1);

  if (this.pinHandlers[pinName] && this.pinHandlers[pinName].get) {
    return this.pinHandlers[pinName].get.apply(this, args);
  }

  return undefined;
};

CCBlock.prototype.pinGetDescriptor = function (pinName) {
  var args = Array.prototype.slice.call(arguments, 1);
  var descriptor = this.pinHandlers[pinName] && this.pinHandlers[pinName].descriptor;

  if (descriptor) {
    if (typeof descriptor === "function") return this.pinHandlers[pinName].get.apply(this, args);
    return descriptor;
  }

  return undefined;
};

Object.defineProperty(CCBlock.prototype, 'pinLines', {
  get: function () {
    var lineList = this.__cc_line_list_by_id__;
    return Object.keys(lineList).map(function (id) {
      return lineList[id];
    });
  }
});
CCBlock.prototype.pinHandlers = {};
var _default = CCBlock;
exports.default = _default;

VaKeR 2022