function synchronizeSelection(options, configuration, watcher) {
      if (angular.isObject(options.chart) && angular.isObject(options.chart.data) && angular.isObject(options.chart.data.selection) && options.chart.data.selection.enabled === true) {

        // add onselected listener
        configuration.data.onselected = function (data, element) {

          // check if listener is disabled currently
          if (service.disableSelectionListener) {
            return;
          }

          // update state
          AngularChartWatcher.updateState(watcher, function () {
            createSelectionsPath(options);
            options.state.selected.push(data);
          });

          // call user defined callback
          if (angular.isFunction(options.chart.data.onselected)) {
            AngularChartWatcher.applyFunction(watcher, function () {
              options.chart.data.onselected(data, element);
            });
          }

        };

        // add onunselection listener
        configuration.data.onunselected = function (data, element) {

          // check if listener is disabled currently
          if (service.disableSelectionListener) {
            return;
          }

          // update state
          AngularChartWatcher.updateState(watcher, function () {
            createSelectionsPath(options);
            options.state.selected = options.state.selected.filter(function (selected) {
              return selected.id !== data.id || selected.index !== data.index;
            });
          });

          // call user defined callback
          if (angular.isFunction(options.chart.data.onunselected)) {
            AngularChartWatcher.applyFunction(watcher, function () {
              options.chart.data.onunselected(data, element);
            });
          }

        };

      }
    }

function synchronizeSelection ( options , configuration , watcher ) { if ( angular . isObject ( options . chart ) && angular . isObject ( options . chart . data ) && angular . isObject ( options . chart . data . selection ) && options . chart . data . selection . enabled === true ) { configuration . data . onselected = function ( data , element ) { if ( service . disableSelectionListener ) { return ; } AngularChartWatcher . updateState ( watcher , function ( ) { createSelectionsPath ( options ) ; options . state . selected . push ( data ) ; } ) ; if ( angular . isFunction ( options . chart . data . onselected ) ) { AngularChartWatcher . applyFunction ( watcher , function ( ) { options . chart . data . onselected ( data , element ) ; } ) ; } } ; configuration . data . onunselected = function ( data , element ) { if ( service . disableSelectionListener ) { return ; } AngularChartWatcher . updateState ( watcher , function ( ) { createSelectionsPath ( options ) ; options . state . selected = options . state . selected . filter ( function ( selected ) { return selected . id !== data . id || selected . index !== data . index ; } ) ; } ) ; if ( angular . isFunction ( options . chart . data . onunselected ) ) { AngularChartWatcher . applyFunction ( watcher , function ( ) { options . chart . data . onunselected ( data , element ) ; } ) ; } } ; } }

Listen to chart events to save selections into to state object.

Listen to chart events to save selections into to state object .


function setupDataSmallWatcher(watcher) {
      return watcher.scope.$watch('options.data', function () {
        if (angular.isFunction(watcher.dataCallback)) {
          watcher.dataCallback();
        }
        setupDataWatcher(watcher);
      }, true);
    }

function setupDataSmallWatcher ( watcher ) { return watcher . scope . $watch ( 'options.data' , function ( ) { if ( angular . isFunction ( watcher . dataCallback ) ) { watcher . dataCallback ( ) ; } setupDataWatcher ( watcher ) ; } , true ) ; }

start watcher changes in small datasets, compares whole object

start watcher changes in small datasets compares whole object


function setupDataBigWatcher(watcher) {
      return watcher.scope.$watch(function () {
        if (watcher.scope.options.data && angular.isArray(watcher.scope.options.data)) {
          return watcher.scope.options.data.length;
        } else {
          return 0;
        }
      }, function () {
        if (angular.isFunction(watcher.dataCallback)) {
          watcher.dataCallback();
        }
        setupDataWatcher(watcher);
      });
    }

function setupDataBigWatcher ( watcher ) { return watcher . scope . $watch ( function ( ) { if ( watcher . scope . options . data && angular . isArray ( watcher . scope . options . data ) ) { return watcher . scope . options . data . length ; } else { return 0 ; } } , function ( ) { if ( angular . isFunction ( watcher . dataCallback ) ) { watcher . dataCallback ( ) ; } setupDataWatcher ( watcher ) ; } ) ; }

start watcher changes in big datasets, compares length of records

start watcher changes in big datasets compares length of records


function addIdentifier() {
      $scope.dataAttributeChartID = 'chartid' + Math.floor(Math.random() * 1000000001);
      angular.element($element).attr('id', $scope.dataAttributeChartID);
      configuration.bindto = '#' + $scope.dataAttributeChartID;
    }

function addIdentifier ( ) { $scope . dataAttributeChartID = 'chartid' + Math . floor ( Math . random ( ) * 1000000001 ) ; angular . element ( $element ) . attr ( 'id' , $scope . dataAttributeChartID ) ; configuration . bindto = '#' + $scope . dataAttributeChartID ; }


function loadEntity(name, promise, options) {
  if (!name || typeof name !== 'string') throw new Error('Missing required entity name');
  if (!promise || !promise.then) throw new Error('Missing required entity promise');

  try {
    !(0, _validateOptions.default)(options);
  } catch (error) {
    throw error;
  }

  var entityLifecycle = new _entityLifecycle.default(name, options);
  return function (dispatch, getState) {
    entityLifecycle.setDispatch(dispatch);
    entityLifecycle.setGetState(getState);
    entityLifecycle.onLoad();
    return new Promise(function (resolve, reject) {
      promise.then(function (data) {
        resolve(entityLifecycle.onSuccess(data));
      }).catch(function (error) {
        reject(entityLifecycle.onFailure(error));
      });
    });
  };
}

function
loadEntity
(
name
,
promise
,
options
)
{
if
(
!
name
||
typeof
name
!==
'string'
)
throw
new
Error
(
'Missing required entity name'
)
;
if
(
!
promise
||
!
promise
.
then
)
throw
new
Error
(
'Missing required entity promise'
)
;
try
{
!
(
0
,
_validateOptions
.
default
)
(
options
)
;
}
catch
(
error
)
{
throw
error
;
}
var
entityLifecycle
=
new
_entityLifecycle
.
default
(
name
,
options
)
;
return
function
(
dispatch
,
getState
)
{
entityLifecycle
.
setDispatch
(
dispatch
)
;
entityLifecycle
.
setGetState
(
getState
)
;
entityLifecycle
.
onLoad
(
)
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
promise
.
then
(
function
(
data
)
{
resolve
(
entityLifecycle
.
onSuccess
(
data
)
)
;
}
)
.
catch
(
function
(
error
)
{
reject
(
entityLifecycle
.
onFailure
(
error
)
)
;
}
)
;
}
)
;
}
;
}

Redux thunk action creator for performing asynchronous actions.

@param {string}  name        Entity name
@param {Promise} promise     Promise (e.g. OrderService.getOrders())
@param {object}  options     Configuration options object
@return {function}           Perform an asynchronous action, dispatch Redux actions accordingly

Redux thunk action creator for performing asynchronous actions .


function generateAction(action, keys, values) {
  var generatedAction = Object.assign({}, action);
  keys.forEach(function (arg, index) {
    generatedAction[keys[index]] = values[index];
  });
  return generatedAction;
}

function generateAction ( action , keys , values ) { var generatedAction = Object . assign ( { } , action ) ; keys . forEach ( function ( arg , index ) { generatedAction [ keys [ index ] ] = values [ index ] ; } ) ; return generatedAction ; }

Generation a Redux action object
@param action
@param keys
@param args
@returns {*}
@private


function makeActionCreator(type) {
  for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    keys[_key - 1] = arguments[_key];
  }

  if (!type) throw new Error('Type cannot be null/undefined');
  return function () {
    for (var _len2 = arguments.length, values = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
      values[_key2] = arguments[_key2];
    }

    return generateAction({
      type: type
    }, keys, values);
  };
}

function
makeActionCreator
(
type
)
{
for
(
var
_len
=
arguments
.
length
,
keys
=
new
Array
(
_len
>
1
_len
1
:
0
)
,
_key
=
1
;
_key
<
_len
;
_key
++
)
{
keys
[
_key
1
]
=
arguments
[
_key
]
;
}
if
(
!
type
)
throw
new
Error
(
'Type cannot be null/undefined'
)
;
return
function
(
)
{
for
(
var
_len2
=
arguments
.
length
,
values
=
new
Array
(
_len2
)
,
_key2
=
0
;
_key2
<
_len2
;
_key2
++
)
{
values
[
_key2
]
=
arguments
[
_key2
]
;
}
return
generateAction
(
{
type
:
type
}
,
keys
,
values
)
;
}
;
}

Generate action creators based on input arguments. The first argument is always
treated as the Redux action type; all other passed arguments are treated
as property on the action object itself.

Example: const myActionType = 'DO_IT';
const doItAction = makeActionCreator(myActionType, 'data');
doItAction(123); --> { type: "DO_IT", data: 123 }

@param type
@returns {Function}

Generate action creators based on input arguments . The first argument is always treated as the Redux action type ; all other passed arguments are treated as property on the action object itself .


function _getRandomDelayBetween (min, max, roundTo) {
    return Number(Math.random() * (max - min) + min).toFixed(roundTo);
}

function _getRandomDelayBetween ( min , max , roundTo ) { return Number ( Math . random ( ) * ( max - min ) + min ) . toFixed ( roundTo ) ; }

Generate a random number in a given range, and round to a given value
@param min
@param max
@param roundTo
@returns {string}
@private

Generate a random number in a given range and round to a given value


function _logDetails (action) {
    if (action) {
        console.log(`${chalk.white.bgRed('  Prev State:')}
        ${__toString(state)}`);
        console.log(`${chalk.white.bgBlue('      Action:')}
        ${__toString(action)}`);
    } else {
        console.log(`${chalk.white.bgGreen('  Next State:')}
        ${__toString(state)}`);
        console.log('\n');
    }
}

function
_logDetails
(
action
)
{
if
(
action
)
{
console
.
log
(
`
${
chalk
.
white
.
bgRed
(
'  Prev State:'
)
}
${
__toString
(
state
)
}
`
)
;
console
.
log
(
`
${
chalk
.
white
.
bgBlue
(
'      Action:'
)
}
${
__toString
(
action
)
}
`
)
;
}
else
{
console
.
log
(
`
${
chalk
.
white
.
bgGreen
(
'  Next State:'
)
}
${
__toString
(
state
)
}
`
)
;
console
.
log
(
'\n'
)
;
}
}

Log Redux actions
@param action
@private


function _removeSubscribers(aSubscribers, oSubscriber) {
  let nUnsubscribed = 0;
  if (!isTypeOf(aSubscribers, sNotDefined)) {
    let nIndex = aSubscribers.length - 1;
    for (; nIndex >= 0; nIndex--) {
      if (aSubscribers[nIndex].subscriber === oSubscriber) {
        nUnsubscribed++;
        aSubscribers.splice(nIndex, 1);
      }
    }
  }
  return nUnsubscribed;
}

function _removeSubscribers ( aSubscribers , oSubscriber ) { let nUnsubscribed = 0 ; if ( ! isTypeOf ( aSubscribers , sNotDefined ) ) { let nIndex = aSubscribers . length - 1 ; for ( ; nIndex >= 0 ; nIndex -- ) { if ( aSubscribers [ nIndex ] . subscriber === oSubscriber ) { nUnsubscribed ++ ; aSubscribers . splice ( nIndex , 1 ) ; } } } return nUnsubscribed ; }

_removeSubscribers remove the subscribers to one channel and return the number of
subscribers that have been unsubscribed.
@param {Array<Object>} aSubscribers
@param {Object} oSubscriber
@return {Number}
@private

_removeSubscribers remove the subscribers to one channel and return the number of subscribers that have been unsubscribed .


function _removeSubscribersPerEvent(oEventsCallbacks, sChannelId, oSubscriber) {
  let nUnsubscribed = 0;
  iterateObject(oEventsCallbacks, function (oItem, sEvent) {
    const aEventsParts = sEvent.split(':');
    let sChannel = sChannelId;
    let sEventType = sEvent;
    if (aEventsParts[0] === 'global') {
      sChannel = aEventsParts[0];
      sEventType = aEventsParts[1];
    }
    nUnsubscribed += _removeSubscribers(oChannels[sChannel][sEventType], oSubscriber);
  });
  return nUnsubscribed;
}

function _removeSubscribersPerEvent ( oEventsCallbacks , sChannelId , oSubscriber ) { let nUnsubscribed = 0 ; iterateObject ( oEventsCallbacks , function ( oItem , sEvent ) { const aEventsParts = sEvent . split ( ':' ) ; let sChannel = sChannelId ; let sEventType = sEvent ; if ( aEventsParts [ 0 ] === 'global' ) { sChannel = aEventsParts [ 0 ] ; sEventType = aEventsParts [ 1 ] ; } nUnsubscribed += _removeSubscribers ( oChannels [ sChannel ] [ sEventType ] , oSubscriber ) ; } ) ; return nUnsubscribed ; }

Loops per all the events to remove subscribers.
@param {Object} oEventsCallbacks
@param {String} sChannelId
@param {Object} oSubscriber
@return {Number}
@private

Loops per all the events to remove subscribers .


function _addSubscribers(oEventsCallbacks, sChannelId, oSubscriber) {
  iterateObject(oEventsCallbacks, function (oItem, sEvent) {
    subscribeTo(sChannelId, sEvent, oItem, oSubscriber);
  });
}

function _addSubscribers ( oEventsCallbacks , sChannelId , oSubscriber ) { iterateObject ( oEventsCallbacks , function ( oItem , sEvent ) { subscribeTo ( sChannelId , sEvent , oItem , oSubscriber ) ; } ) ; }

_addSubscribers add all the events of one channel from the subscriber
@param {Object} oEventsCallbacks
@param {String} sChannelId
@param {Object} oSubscriber
@private


function _getChannelEvents(sChannelId, sEvent) {
  if (oChannels[sChannelId] === und) {
    oChannels[sChannelId] = {};
  }
  if (oChannels[sChannelId][sEvent] === und) {
    oChannels[sChannelId][sEvent] = [];
  }
  return oChannels[sChannelId][sEvent];
}

function _getChannelEvents ( sChannelId , sEvent ) { if ( oChannels [ sChannelId ] === und ) { oChannels [ sChannelId ] = { } ; } if ( oChannels [ sChannelId ] [ sEvent ] === und ) { oChannels [ sChannelId ] [ sEvent ] = [ ] ; } return oChannels [ sChannelId ] [ sEvent ] ; }

_getChannelEvents return the events array in channel.
@param {String} sChannelId
@param {String} sEvent
@return {Object}
@private

_getChannelEvents return the events array in channel .


function subscribersByEvent(oChannel, sEventName) {
  let aSubscribers = [];
  if (!isTypeOf(oChannel, sNotDefined)) {
    iterateObject(oChannel, function (oItem, sKey) {
      if (sKey === sEventName) {
        aSubscribers = oItem;
      }
    });
  }
  return aSubscribers;
}

function subscribersByEvent ( oChannel , sEventName ) { let aSubscribers = [ ] ; if ( ! isTypeOf ( oChannel , sNotDefined ) ) { iterateObject ( oChannel , function ( oItem , sKey ) { if ( sKey === sEventName ) { aSubscribers = oItem ; } } ) ; } return aSubscribers ; }

subscribersByEvent return all the subscribers of the event in the channel.
@param {Object} oChannel
@param {String} sEventName
@return {Array<Object>}
@private

subscribersByEvent return all the subscribers of the event in the channel .


function subscribeTo(sChannelId, sEventType, fpHandler, oSubscriber) {
  const aChannelEvents = _getChannelEvents(sChannelId, sEventType);
  aChannelEvents.push({
    subscriber: oSubscriber,
    handler: fpHandler
  });
}

function subscribeTo ( sChannelId , sEventType , fpHandler , oSubscriber ) { const aChannelEvents = _getChannelEvents ( sChannelId , sEventType ) ; aChannelEvents . push ( { subscriber : oSubscriber , handler : fpHandler } ) ; }

Method to add a single callback in one channel an in one event.
@param {String} sChannelId
@param {String} sEventType
@param {Function} fpHandler
@param {Object} oSubscriber

Method to add a single callback in one channel an in one event .


function unsubscribeFrom(sChannelId, sEventType, oSubscriber) {
  const aChannelEvents = _getChannelEvents(sChannelId, sEventType);
  for (let nEvent = aChannelEvents.length - 1; nEvent >= 0; nEvent--) {
    const oItem = aChannelEvents[nEvent];
    if (oItem.subscriber === oSubscriber) {
      aChannelEvents.splice(nEvent, 1);
    }
  }
}

function unsubscribeFrom ( sChannelId , sEventType , oSubscriber ) { const aChannelEvents = _getChannelEvents ( sChannelId , sEventType ) ; for ( let nEvent = aChannelEvents . length - 1 ; nEvent >= 0 ; nEvent -- ) { const oItem = aChannelEvents [ nEvent ] ; if ( oItem . subscriber === oSubscriber ) { aChannelEvents . splice ( nEvent , 1 ) ; } } }

Method to unsubscribe a subscriber from a channel and event type.
It iterates in reverse order to avoid messing with array length when removing items.
@param {String} sChannelId
@param {String} sEventType
@param {Object} oSubscriber

Method to unsubscribe a subscriber from a channel and event type . It iterates in reverse order to avoid messing with array length when removing items .


function subscribe(oSubscriber) {
  const oEventsCallbacks = oSubscriber.events;
  if (!oSubscriber || oEventsCallbacks === und) {
    return false;
  }
  iterateObject(oEventsCallbacks, function (oItem, sChannelId) {
    if (oChannels[sChannelId] === und) {
      oChannels[sChannelId] = {};
    }
    _addSubscribers(oItem, sChannelId, oSubscriber);
  });

  return true;
}

function subscribe ( oSubscriber ) { const oEventsCallbacks = oSubscriber . events ; if ( ! oSubscriber || oEventsCallbacks === und ) { return false ; } iterateObject ( oEventsCallbacks , function ( oItem , sChannelId ) { if ( oChannels [ sChannelId ] === und ) { oChannels [ sChannelId ] = { } ; } _addSubscribers ( oItem , sChannelId , oSubscriber ) ; } ) ; return true ; }

subscribe method gets the oEventsCallbacks object with all the handlers and add these handlers to the channel.
@param {Object} oSubscriber
@return {Boolean}

subscribe method gets the oEventsCallbacks object with all the handlers and add these handlers to the channel .


function unsubscribe(oSubscriber) {
  let nUnsubscribed = 0;
  const oEventsCallbacks = oSubscriber.events;
  if (!oSubscriber || oEventsCallbacks === und) {
    return false;
  }
  iterateObject(oEventsCallbacks, function (oItem, sChannelId) {
    if (oChannels[sChannelId] === und) {
      oChannels[sChannelId] = {};
    }
    nUnsubscribed = _removeSubscribersPerEvent(oItem, sChannelId, oSubscriber);
  });

  return nUnsubscribed > 0;
}

function unsubscribe ( oSubscriber ) { let nUnsubscribed = 0 ; const oEventsCallbacks = oSubscriber . events ; if ( ! oSubscriber || oEventsCallbacks === und ) { return false ; } iterateObject ( oEventsCallbacks , function ( oItem , sChannelId ) { if ( oChannels [ sChannelId ] === und ) { oChannels [ sChannelId ] = { } ; } nUnsubscribed = _removeSubscribersPerEvent ( oItem , sChannelId , oSubscriber ) ; } ) ; return nUnsubscribed > 0 ; }

unsubscribe gets the oEventsCallbacks methods and removes the handlers of the channel.
@param {Object} oSubscriber
@return {Boolean}

unsubscribe gets the oEventsCallbacks methods and removes the handlers of the channel .


function _executeHandler(oHandlerObject, oData, sChannelId, sEvent) {
  oHandlerObject.handler.call(oHandlerObject.subscriber, oData);
  if (getDebug()) {
    const ErrorHandler = errorHandler();
    ErrorHandler.log(sChannelId, sEvent, oHandlerObject);
  }
}

function _executeHandler ( oHandlerObject , oData , sChannelId , sEvent ) { oHandlerObject . handler . call ( oHandlerObject . subscriber , oData ) ; if ( getDebug ( ) ) { const ErrorHandler = errorHandler ( ) ; ErrorHandler . log ( sChannelId , sEvent , oHandlerObject ) ; } }

Method to execute handlers
@param {Object} oHandlerObject
@param {Object} oData
@param {String} sChannelId
@param {String} sEvent


function publish(sChannelId, sEvent, oData) {
  const aSubscribers = copyArray(this.subscribers(sChannelId, sEvent));
  let oSubscriber;
  const nLenSubscribers = aSubscribers.length;
  if (nLenSubscribers === 0) {
    return false;
  }
  oData = preprocessorsPublishData(oData);
  while (!!(oSubscriber = aSubscribers.shift())) {
    _executeHandler(oSubscriber, oData, sChannelId, sEvent);
  }
  return true;
}

function publish ( sChannelId , sEvent , oData ) { const aSubscribers = copyArray ( this . subscribers ( sChannelId , sEvent ) ) ; let oSubscriber ; const nLenSubscribers = aSubscribers . length ; if ( nLenSubscribers === 0 ) { return false ; } oData = preprocessorsPublishData ( oData ) ; while ( ! ! ( oSubscriber = aSubscribers . shift ( ) ) ) { _executeHandler ( oSubscriber , oData , sChannelId , sEvent ) ; } return true ; }

Publish the event in one channel.
@param {String} sChannelId
@param {String} sEvent
@param {String} oData
@return {Boolean}


function resolveNamespace(sNamespace) {
  var oObj = root,
    aElements = sNamespace.split('.'),
    sElement;
  while (!!( sElement = aElements.shift() )) {
    oObj = oObj[sElement] !== und ? oObj[sElement] : oObj[sElement] = {};
  }
  return oObj;
}

function resolveNamespace ( sNamespace ) { var oObj = root , aElements = sNamespace . split ( '.' ) , sElement ; while ( ! ! ( sElement = aElements . shift ( ) ) ) { oObj = oObj [ sElement ] !== und ? oObj [ sElement ] : oObj [ sElement ] = { } ; } return oObj ; }

Create or get a namespace by a namespace defined as string
@param {String}sNamespace
@return {Object}
@private


function getResolveDICallback(oMapping) {
  return function (sDependency) {
    var oPromise = getPromise();
    if (!oMapping.__map__[sDependency]) {
      return false;
    }
    oPromise.resolve(oMapping.__map__[sDependency]);
    return oPromise;
  };
}

function getResolveDICallback ( oMapping ) { return function ( sDependency ) { var oPromise = getPromise ( ) ; if ( ! oMapping . __map__ [ sDependency ] ) { return false ; } oPromise . resolve ( oMapping . __map__ [ sDependency ] ) ; return oPromise ; } ; }

Resolve dependency injection by default.
@param {Object} oMapping
@return {Function}
@private

Resolve dependency injection by default .


function getPromiseCallbacks(oContext, sType) {
  return function () {
    var aCompleted, nLenPromises, oDeferred, aPromises, nPromise, oPromise, aResults = [];
    oContext.bCompleted = true;
    oContext.sType = sType;
    oContext.oResult = arguments;
    while (oContext.aPending[0]) {
      oContext.aPending.shift()[sType].apply(oContext, arguments);
    }
    oDeferred = oContext.oDeferred;
    if(oDeferred){
      aCompleted = [];
      aPromises = oDeferred.aPromises;
      nLenPromises = aPromises.length;
      aResults = [];
      for(nPromise = 0; nPromise < nLenPromises; nPromise++){
        oPromise = aPromises[nPromise];
        aCompleted.push(Number(oPromise.bCompleted));
        aResults.push( oPromise.oResult );
      }
      if(aCompleted.join('').indexOf('0') === -1){
        oDeferred[sType].apply(oDeferred, aResults);
      }
    }
  };
}

function getPromiseCallbacks ( oContext , sType ) { return function ( ) { var aCompleted , nLenPromises , oDeferred , aPromises , nPromise , oPromise , aResults = [ ] ; oContext . bCompleted = true ; oContext . sType = sType ; oContext . oResult = arguments ; while ( oContext . aPending [ 0 ] ) { oContext . aPending . shift ( ) [ sType ] . apply ( oContext , arguments ) ; } oDeferred = oContext . oDeferred ; if ( oDeferred ) { aCompleted = [ ] ; aPromises = oDeferred . aPromises ; nLenPromises = aPromises . length ; aResults = [ ] ; for ( nPromise = 0 ; nPromise < nLenPromises ; nPromise ++ ) { oPromise = aPromises [ nPromise ] ; aCompleted . push ( Number ( oPromise . bCompleted ) ) ; aResults . push ( oPromise . oResult ) ; } if ( aCompleted . join ( '' ) . indexOf ( '0' ) === - 1 ) { oDeferred [ sType ] . apply ( oDeferred , aResults ) ; } } } ; }

Returns the promise callback by type
@param {Object}oContext
@param {String} sType
@return {Function}
@private


function (fpSuccess, fpFailure) {
    var oResult = this.oResult;
    if (this.bCompleted) {
      if (this.sType === 'resolve') {
        fpSuccess.apply(fpSuccess, oResult);
      } else {
        fpFailure.apply(fpFailure, oResult);
      }
    } else {
      this.aPending.push({ resolve: fpSuccess, reject: fpFailure});
    }
    return this;
  }

function ( fpSuccess , fpFailure ) { var oResult = this . oResult ; if ( this . bCompleted ) { if ( this . sType === 'resolve' ) { fpSuccess . apply ( fpSuccess , oResult ) ; } else { fpFailure . apply ( fpFailure , oResult ) ; } } else { this . aPending . push ( { resolve : fpSuccess , reject : fpFailure } ) ; } return this ; }

Adds new callbacks to execute when the promise has been completed
@member Promise.prototype
@param {Function} fpSuccess
@param {Function} fpFailure
@return {Promise} Promise instance


function FakeModule(sModuleId, fpCreator) {
  if (isTypeOf(fpCreator, sNotDefined)) {
    throw new Error('Something goes wrong!');
  }
  this.creator = fpCreator;
  this.instances = {};
  this.sModuleId = sModuleId;
}

function
FakeModule
(
sModuleId
,
fpCreator
)
{
if
(
isTypeOf
(
fpCreator
,
sNotDefined
)
)
{
throw
new
Error
(
'Something goes wrong!'
)
;
}
this
.
creator
=
fpCreator
;
this
.
instances
=
{
}
;
this
.
sModuleId
=
sModuleId
;
}

Module to be stored, adds two methods to start and extend modules.
@param {String} sModuleId
@param {Function} fpCreator
@constructor
@class FakeModule
@name FakeModule
@private

Module to be stored adds two methods to start and extend modules .


function isJqueryObject(oObj) {
  var isJquery = false,
    $ = getRoot().jQuery;
  if ($) {
    isJquery = isInstanceOf(oObj, $);
  }
  return isJquery;
}

function isJqueryObject ( oObj ) { var isJquery = false , $ = getRoot ( ) . jQuery ; if ( $ ) { isJquery = isInstanceOf ( oObj , $ ) ; } return isJquery ; }

Use jQuery detection
@param {Object} oObj
@return {Boolean}
@private


function isEvent(oObj) {
  try {
    return isInstanceOf(oObj, Event);
  } catch (erError) {
    // Duck typing detection (If it sounds like a duck and it moves like a duck, it's a duck)
    if (oObj.altKey !== und && ( oObj.srcElement || oObj.target )) {
      return true;
    }
  }
  return false;
}

function isEvent ( oObj ) { try { return isInstanceOf ( oObj , Event ) ; } catch ( erError ) { if ( oObj . altKey !== und && ( oObj . srcElement || oObj . target ) ) { return true ; } } return false ; }

Use Event detection and if it fails it degrades to use duck typing detection to
test if the supplied object is an Event
@param {Object} oObj
@return {Boolean}
@private


function addPropertiesAndMethodsToModule(sModuleId, aDependencies, fpCallback) {
  var oPromise;

  function success(mapping) {
    const oModules = getModules();
    var oModule, fpInitProxy;
    oModule = oModules[sModuleId].creator.apply(oModules[sModuleId], [].slice.call(arguments, 1));
    oModule.__children__ = [];
    oModule.dependencies = aDependencies || [].slice.call(arguments, 1);
    oModule.resolvedDependencies = mapping;
    oModule.__module_id__ = sModuleId;
    fpInitProxy = oModule.init || nullFunc;
    // Provide compatibility with old versions of Hydra.js
    oModule.__action__ = oModule.__sandbox__ = Bus;
    oModule.events = oModule.events || {};
    oModule.init = function () {
      var aArgs = copyArray(arguments).concat(getVars());
      if (oModule.__children__.length === 0) {  // Only subscribe last element of inheritance.
        Bus.subscribe(oModule);
      }
      return fpInitProxy.apply(this, aArgs);
    };
    oModule.handleAction = function (oNotifier) {
      var fpCallback = this.events[oNotifier.type];
      if (isTypeOf(fpCallback, sNotDefined)) {
        return;
      }
      fpCallback.call(this, oNotifier);
    };
    // Provide compatibility with old Hydra versions which used to use "destroy" as onDestroy hook.
    oModule.onDestroy = oModule.onDestroy || oModule.destroy || function () {
      };
    oModule.destroy = function () {
      this.onDestroy();
      Bus.unsubscribe(oModule);
      delete oModules[sModuleId].instances[oModule.__instance_id__];
    };
    fpCallback(oModule);
  }

  oPromise = resolveDependencies(sModuleId, aDependencies);
  oPromise.then(function () {
    success.apply(success, arguments);
  });
}

function addPropertiesAndMethodsToModule ( sModuleId , aDependencies , fpCallback ) { var oPromise ; function success ( mapping ) { const oModules = getModules ( ) ; var oModule , fpInitProxy ; oModule = oModules [ sModuleId ] . creator . apply ( oModules [ sModuleId ] , [ ] . slice . call ( arguments , 1 ) ) ; oModule . __children__ = [ ] ; oModule . dependencies = aDependencies || [ ] . slice . call ( arguments , 1 ) ; oModule . resolvedDependencies = mapping ; oModule . __module_id__ = sModuleId ; fpInitProxy = oModule . init || nullFunc ; oModule . __action__ = oModule . __sandbox__ = Bus ; oModule . events = oModule . events || { } ; oModule . init = function ( ) { var aArgs = copyArray ( arguments ) . concat ( getVars ( ) ) ; if ( oModule . __children__ . length === 0 ) { Bus . subscribe ( oModule ) ; } return fpInitProxy . apply ( this , aArgs ) ; } ; oModule . handleAction = function ( oNotifier ) { var fpCallback = this . events [ oNotifier . type ] ; if ( isTypeOf ( fpCallback , sNotDefined ) ) { return ; } fpCallback . call ( this , oNotifier ) ; } ; oModule . onDestroy = oModule . onDestroy || oModule . destroy || function ( ) { } ; oModule . destroy = function ( ) { this . onDestroy ( ) ; Bus . unsubscribe ( oModule ) ; delete oModules [ sModuleId ] . instances [ oModule . __instance_id__ ] ; } ; fpCallback ( oModule ) ; } oPromise = resolveDependencies ( sModuleId , aDependencies ) ; oPromise . then ( function ( ) { success . apply ( success , arguments ) ; } ) ; }

Add common properties and methods to avoid repeating code in modules
@param {String} sModuleId
@param {Array} aDependencies
@param {Function} fpCallback
@private


function wrapMethod(oInstance, sName, sModuleId, fpMethod) {
  oInstance[sName] = ( function (sName, fpMethod) {
    return function () {
      var aArgs = copyArray(arguments);
      try {
        return fpMethod.apply(this, aArgs);
      }
      catch (erError) {
        const ErrorHandler = errorHandler();
        ErrorHandler.error(sModuleId, sName, erError);
        return false;
      }
    };
  }(sName, fpMethod));
}

function wrapMethod ( oInstance , sName , sModuleId , fpMethod ) { oInstance [ sName ] = ( function ( sName , fpMethod ) { return function ( ) { var aArgs = copyArray ( arguments ) ; try { return fpMethod . apply ( this , aArgs ) ; } catch ( erError ) { const ErrorHandler = errorHandler ( ) ; ErrorHandler . error ( sModuleId , sName , erError ) ; return false ; } } ; } ( sName , fpMethod ) ) ; }

wrapMethod is a method to wrap the original method to avoid failing code.
This will be only called if bDebug flag is set to false.
@param {Object} oInstance
@param {String} sName
@param {String} sModuleId
@param {Function} fpMethod
@private

wrapMethod is a method to wrap the original method to avoid failing code . This will be only called if bDebug flag is set to false .


function register(sModuleId, aDependencies, fpCreator) {
  const oModules = getModules();
  if (isFunction(aDependencies)) {
    fpCreator = aDependencies;
    aDependencies = [ '$$_bus', '$$_module', '$$_log', 'gl_Hydra' ];
  }
  oModules[sModuleId] = new FakeModule(sModuleId, fpCreator);

  oModules[sModuleId].dependencies = aDependencies;
  return oModules[sModuleId];
}

function register ( sModuleId , aDependencies , fpCreator ) { const oModules = getModules ( ) ; if ( isFunction ( aDependencies ) ) { fpCreator = aDependencies ; aDependencies = [ '$$_bus' , '$$_module' , '$$_log' , 'gl_Hydra' ] ; } oModules [ sModuleId ] = new FakeModule ( sModuleId , fpCreator ) ; oModules [ sModuleId ] . dependencies = aDependencies ; return oModules [ sModuleId ] ; }

register is the method that will add the new module to the oModules object.
sModuleId will be the key where it will be stored.
@param {String} sModuleId
@param {Array} aDependencies
@param {Function | *} fpCreator
@return {Object}

register is the method that will add the new module to the oModules object . sModuleId will be the key where it will be stored .


function setInstance(sModuleId, sIdInstance, oInstance) {
  const oModules = getModules();
  var oModule = oModules[sModuleId];
  if (!oModule) {
    fpThrowErrorModuleNotRegistered(sModuleId, true);
  }
  oModule.instances[sIdInstance] = oInstance;
  return oModule;
}

function setInstance ( sModuleId , sIdInstance , oInstance ) { const oModules = getModules ( ) ; var oModule = oModules [ sModuleId ] ; if ( ! oModule ) { fpThrowErrorModuleNotRegistered ( sModuleId , true ) ; } oModule . instances [ sIdInstance ] = oInstance ; return oModule ; }

Method to set an instance of a module
@param {String} sModuleId
@param {String} sIdInstance
@param {Module} oInstance
@return {Module}


function _multiModuleStart(oInstance, aModulesIds, sIdInstance, oData, bSingle) {
  var aInstancesIds, aData, aSingle, nIndex, nLenModules, sModuleId;
  if (isArray(sIdInstance)) {
    aInstancesIds = copyArray(sIdInstance);
  }
  if (isArray(oData)) {
    aData = copyArray(oData);
  }
  if (isArray(bSingle)) {
    aSingle = copyArray(bSingle);
  }
  for (nIndex = 0, nLenModules = aModulesIds.length; nIndex < nLenModules; nIndex++) {
    sModuleId = aModulesIds[nIndex];
    sIdInstance = aInstancesIds && aInstancesIds[nIndex] || generateUniqueKey();
    oData = aData && aData[nIndex] || oData;
    bSingle = aSingle && aSingle[nIndex] || bSingle;
    startSingleModule(oInstance, sModuleId, sIdInstance, oData, bSingle);
  }
}

function _multiModuleStart ( oInstance , aModulesIds , sIdInstance , oData , bSingle ) { var aInstancesIds , aData , aSingle , nIndex , nLenModules , sModuleId ; if ( isArray ( sIdInstance ) ) { aInstancesIds = copyArray ( sIdInstance ) ; } if ( isArray ( oData ) ) { aData = copyArray ( oData ) ; } if ( isArray ( bSingle ) ) { aSingle = copyArray ( bSingle ) ; } for ( nIndex = 0 , nLenModules = aModulesIds . length ; nIndex < nLenModules ; nIndex ++ ) { sModuleId = aModulesIds [ nIndex ] ; sIdInstance = aInstancesIds && aInstancesIds [ nIndex ] || generateUniqueKey ( ) ; oData = aData && aData [ nIndex ] || oData ; bSingle = aSingle && aSingle [ nIndex ] || bSingle ; startSingleModule ( oInstance , sModuleId , sIdInstance , oData , bSingle ) ; } }

start more than one module at the same time.
@param {Object} oInstance
@param {Array<String>} aModulesIds
@param {String} sIdInstance
@param {Object} oData
@param {Boolean} bSingle
@private

start more than one module at the same time .


function beforeInit(oInstance, oData, bSingle) {
  iterateObject(oModifyInit, function (oMember) {
    if (oMember && isTypeOf(oMember, sFunctionType)) {
      oMember(oInstance, oData, bSingle);
    }
  });
}

function beforeInit ( oInstance , oData , bSingle ) { iterateObject ( oModifyInit , function ( oMember ) { if ( oMember && isTypeOf ( oMember , sFunctionType ) ) { oMember ( oInstance , oData , bSingle ) ; } } ) ; }

Method to modify the init method to use it for extend.
@param {Object} oInstance
@param {Object} oData
@param {Boolean} bSingle
@private

Method to modify the init method to use it for extend .


function startSingleModule(oWrapper, sModuleId, sIdInstance, oData, bSingle) {
  const oModules = getModules();
  var oModule;
  oModule = oModules[sModuleId];
  if ( (bSingle && isModuleStarted(sModuleId)) || isModuleStarted(sModuleId, sIdInstance)) {
    oWrapper.stop(sModuleId, sIdInstance);
  }
  if (!isTypeOf(oModule, sNotDefined)) {
    createInstance(sModuleId, undefined, function (oInstance) {
      oModule.instances[sIdInstance] = oInstance;
      oInstance.__instance_id__ = sIdInstance;

      beforeInit(oInstance, oData, bSingle);

      if (!isTypeOf(oData, sNotDefined)) {
        oInstance.init(oData);
      } else {
        oInstance.init();
      }
    });
  } else {
    const ErrorHandler = errorHandler();
    ErrorHandler.error(new Error(), fpThrowErrorModuleNotRegistered(sModuleId));
  }
}

function startSingleModule ( oWrapper , sModuleId , sIdInstance , oData , bSingle ) { const oModules = getModules ( ) ; var oModule ; oModule = oModules [ sModuleId ] ; if ( ( bSingle && isModuleStarted ( sModuleId ) ) || isModuleStarted ( sModuleId , sIdInstance ) ) { oWrapper . stop ( sModuleId , sIdInstance ) ; } if ( ! isTypeOf ( oModule , sNotDefined ) ) { createInstance ( sModuleId , undefined , function ( oInstance ) { oModule . instances [ sIdInstance ] = oInstance ; oInstance . __instance_id__ = sIdInstance ; beforeInit ( oInstance , oData , bSingle ) ; if ( ! isTypeOf ( oData , sNotDefined ) ) { oInstance . init ( oData ) ; } else { oInstance . init ( ) ; } } ) ; } else { const ErrorHandler = errorHandler ( ) ; ErrorHandler . error ( new Error ( ) , fpThrowErrorModuleNotRegistered ( sModuleId ) ) ; } }

startSingleModule is the method that will initialize the module.
When start is called the module instance will be created and the init method is called.
If bSingle is true and the module is started the module will be stopped before instance it again.
This avoid execute the same listeners more than one time.
@param {Object} oWrapper
@param {String} sModuleId
@param {String} sIdInstance
@param {Object} oData
@param {Boolean} bSingle
@private

startSingleModule is the method that will initialize the module . When start is called the module instance will be created and the init method is called . If bSingle is true and the module is started the module will be stopped before instance it again . This avoid execute the same listeners more than one time .


function _singleModuleStart(oInstance, sModuleId, sIdInstance, oData, bSingle) {
  if (!isTypeOf(sIdInstance, 'string')) {
    bSingle = oData;
    oData = sIdInstance;
    sIdInstance = generateUniqueKey();
  }

  startSingleModule(oInstance, sModuleId, sIdInstance, oData, bSingle);
}

function _singleModuleStart ( oInstance , sModuleId , sIdInstance , oData , bSingle ) { if ( ! isTypeOf ( sIdInstance , 'string' ) ) { bSingle = oData ; oData = sIdInstance ; sIdInstance = generateUniqueKey ( ) ; } startSingleModule ( oInstance , sModuleId , sIdInstance , oData , bSingle ) ; }

Start only one module.
@param {Object} oInstance
@param {String} sModuleId
@param {String} sIdInstance
@param {Object} oData
@param {Boolean|*} bSingle
@private


function createInstance(sModuleId, aDependencies, fpCallback) {
  const oModules = getModules();
  if (isTypeOf(oModules[sModuleId], sNotDefined)) {
    fpThrowErrorModuleNotRegistered(sModuleId, true);
  }
  addPropertiesAndMethodsToModule(sModuleId, aDependencies, function (oInstance) {
    if (!getDebug()) {
      iterateObject(oInstance, function (oItem, sName) {
        if (isFunction(oItem)) {
          wrapMethod(oInstance, sName, sModuleId, oInstance[sName]);
        }
      });
    }
    fpCallback(oInstance);
  });
}

function createInstance ( sModuleId , aDependencies , fpCallback ) { const oModules = getModules ( ) ; if ( isTypeOf ( oModules [ sModuleId ] , sNotDefined ) ) { fpThrowErrorModuleNotRegistered ( sModuleId , true ) ; } addPropertiesAndMethodsToModule ( sModuleId , aDependencies , function ( oInstance ) { if ( ! getDebug ( ) ) { iterateObject ( oInstance , function ( oItem , sName ) { if ( isFunction ( oItem ) ) { wrapMethod ( oInstance , sName , sModuleId , oInstance [ sName ] ) ; } } ) ; } fpCallback ( oInstance ) ; } ) ; }

createInstance is the method that will create the module instance and wrap the method if needed.
@param {String} sModuleId
@param {Array|undefined} [aDependencies]
@param {Function} fpCallback
@private

createInstance is the method that will create the module instance and wrap the method if needed .


function getCallbackToSetObjectFromTemplate(oMethodsObject, oPropertiesObject) {
  return function (oValue, sKey) {
    if (typeof oValue === 'function') {
      oMethodsObject[sKey] = getSimpleFunction(oValue);
    } else if (isArray(oValue)) {
      oPropertiesObject[sKey] = copyArray(oValue);
    } else if (typeof oValue === 'object' && oValue !== null ) {
      oPropertiesObject[sKey] = simpleMerge({}, oValue);
    } else if (isInstanceOf(oValue, Date)) {
      oPropertiesObject[sKey] = new Date();
      oPropertiesObject[sKey].setTime(oValue.getTime());
    } else {
      oPropertiesObject[sKey] = oValue;
    }
  };
}

function getCallbackToSetObjectFromTemplate ( oMethodsObject , oPropertiesObject ) { return function ( oValue , sKey ) { if ( typeof oValue === 'function' ) { oMethodsObject [ sKey ] = getSimpleFunction ( oValue ) ; } else if ( isArray ( oValue ) ) { oPropertiesObject [ sKey ] = copyArray ( oValue ) ; } else if ( typeof oValue === 'object' && oValue !== null ) { oPropertiesObject [ sKey ] = simpleMerge ( { } , oValue ) ; } else if ( isInstanceOf ( oValue , Date ) ) { oPropertiesObject [ sKey ] = new Date ( ) ; oPropertiesObject [ sKey ] . setTime ( oValue . getTime ( ) ) ; } else { oPropertiesObject [ sKey ] = oValue ; } } ; }

Sets properties and methods from a template object.
@param {Object} oMethodsObject
@param {Object} oPropertiesObject
@returns {Function}

Sets properties and methods from a template object .


function startAll() {
  const oModules = getModules();
  iterateObject(oModules, function (_oModule, sModuleId) {
    if (!isTypeOf(_oModule, sNotDefined)) {
      start(sModuleId, generateUniqueKey());
    }
  });
}

function startAll ( ) { const oModules = getModules ( ) ; iterateObject ( oModules , function ( _oModule , sModuleId ) { if ( ! isTypeOf ( _oModule , sNotDefined ) ) { start ( sModuleId , generateUniqueKey ( ) ) ; } } ) ; }

startAll is the method that will initialize all the registered modules.
@member Module.prototype

startAll is the method that will initialize all the registered modules .


function stop(sModuleId, sInstanceId) {
  const oModules = getModules();
  var oModule;
  oModule = oModules[sModuleId];
  if (isTypeOf(oModule, sNotDefined)) {
    return false;
  }
  if (!isTypeOf(sInstanceId, sNotDefined)) {
    _singleModuleStop(oModule, sInstanceId);
  } else {
    _multiModuleStop(oModule);
  }
  return true;
}

function stop ( sModuleId , sInstanceId ) { const oModules = getModules ( ) ; var oModule ; oModule = oModules [ sModuleId ] ; if ( isTypeOf ( oModule , sNotDefined ) ) { return false ; } if ( ! isTypeOf ( sInstanceId , sNotDefined ) ) { _singleModuleStop ( oModule , sInstanceId ) ; } else { _multiModuleStop ( oModule ) ; } return true ; }

stop is the method that will finish the module if it was registered and started.
When stop is called the module will call the destroy method and will nullify the instance.
@param {String} sModuleId
@param {String} [sInstanceId]
@return {Boolean}

stop is the method that will finish the module if it was registered and started . When stop is called the module will call the destroy method and will nullify the instance .


function _multiModuleStop(oModule) {
  iterateObject(oModule.instances, function (oInstance) {
    if (!isTypeOf(oModule, sNotDefined) && !isTypeOf(oInstance, sNotDefined)) {
      oInstance.destroy();
    }
  });
  oModule.instances = {};
}

function _multiModuleStop ( oModule ) { iterateObject ( oModule . instances , function ( oInstance ) { if ( ! isTypeOf ( oModule , sNotDefined ) && ! isTypeOf ( oInstance , sNotDefined ) ) { oInstance . destroy ( ) ; } } ) ; oModule . instances = { } ; }

stop more than one module at the same time.
@param {Object} oModule
@private

stop more than one module at the same time .


function _singleModuleStop(oModule, sInstanceId) {
  var oInstance = oModule.instances[sInstanceId];
  if (!isTypeOf(oModule, sNotDefined) && !isTypeOf(oInstance, sNotDefined)) {
    oInstance.destroy();
    delete oModule.instances[sInstanceId];
  }
}

function _singleModuleStop ( oModule , sInstanceId ) { var oInstance = oModule . instances [ sInstanceId ] ; if ( ! isTypeOf ( oModule , sNotDefined ) && ! isTypeOf ( oInstance , sNotDefined ) ) { oInstance . destroy ( ) ; delete oModule . instances [ sInstanceId ] ; } }

Stop only one module.
@param {Object} oModule
@param {String} sInstanceId
@private


function stopAll() {
  const oModules = getModules();
  iterateObject(oModules, function (_oModule, sModuleId) {
    if (!isTypeOf(_oModule, sNotDefined)) {
      _stopOneByOne(_oModule, sModuleId);
    }
  });
}

function stopAll ( ) { const oModules = getModules ( ) ; iterateObject ( oModules , function ( _oModule , sModuleId ) { if ( ! isTypeOf ( _oModule , sNotDefined ) ) { _stopOneByOne ( _oModule , sModuleId ) ; } } ) ; }

stopAll is the method that will finish all the registered and started modules.

stopAll is the method that will finish all the registered and started modules .


function _stopOneByOne(oModule, sModuleId) {
  iterateObject(oModule.instances, function (oItem, sInstanceId) {
    stop(sModuleId, sInstanceId);
  });
}

function _stopOneByOne ( oModule , sModuleId ) { iterateObject ( oModule . instances , function ( oItem , sInstanceId ) { stop ( sModuleId , sInstanceId ) ; } ) ; }

Loops over instances of modules to stop them.
@param {Object} oModule
@param {String} sModuleId
@private

Loops over instances of modules to stop them .


function remove(sModuleId) {
  const oModules = getModules();
  var oModule = oModules[sModuleId];
  if (isTypeOf(oModule, sNotDefined)) {
    return null;
  }
  if (!isTypeOf(oModule, sNotDefined)) {
    try {
      return Module;
    }
    finally {
      _delete(sModuleId);
      createMapping(getMappingMaps(), 'hm_', oModules);
    }
  }
  return null;
}

function remove ( sModuleId ) { const oModules = getModules ( ) ; var oModule = oModules [ sModuleId ] ; if ( isTypeOf ( oModule , sNotDefined ) ) { return null ; } if ( ! isTypeOf ( oModule , sNotDefined ) ) { try { return Module ; } finally { _delete ( sModuleId ) ; createMapping ( getMappingMaps ( ) , 'hm_' , oModules ) ; } } return null ; }

remove is the method that will remove the full module from the oModules object
@param {String} sModuleId
@return {*}


function _delete(sModuleId) {
  const oModules = getModules();
  if (!isTypeOf(oModules[sModuleId], sNotDefined)) {
    delete oModules[sModuleId];
    return true;
  }
  return false;
}

function _delete ( sModuleId ) { const oModules = getModules ( ) ; if ( ! isTypeOf ( oModules [ sModuleId ] , sNotDefined ) ) { delete oModules [ sModuleId ] ; return true ; } return false ; }

_delete is a wrapper method that will call the native delete javascript function
It's important to test the full code.
@param {String} sModuleId
@return {Boolean}

_delete is a wrapper method that will call the native delete javascript function It s important to test the full code .


function main() {
    return __awaiter(this, void 0, void 0, function () {
        var outputDataSize, interval, dataFrame, dateFormat, api;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    outputDataSize = "compact";
                    if (argv.outputDataSize) {
                        outputDataSize = argv.outputDataSize;
                    }
                    interval = '60min';
                    if (argv.interval) {
                        interval = argv.interval;
                    }
                    api = new index_1.AlphaVantageAPI(argv.apiKey, outputDataSize, argv.verbose);
                    if (!(argv.type === 'daily')) return [3 /*break*/, 2];
                    return [4 /*yield*/, api.getDailyDataFrame(argv.symbol)];
                case 1:
                    dataFrame = _a.sent();
                    dateFormat = 'YYYY-MM-DD';
                    return [3 /*break*/, 5];
                case 2:
                    if (!(argv.type === 'intraday')) return [3 /*break*/, 4];
                    return [4 /*yield*/, api.getIntradayDataFrame(argv.symbol, interval)];
                case 3:
                    dataFrame = _a.sent();
                    dateFormat = "YYYY-MM-DD HH:mm:ss";
                    return [3 /*break*/, 5];
                case 4: throw new Error("Unexpected data type: " + argv.type + ", expected it to be either 'daily' or 'intrday'");
                case 5:
                    if (!argv.verbose) {
                        console.log('>> ' + argv.out);
                    }
                    dataFrame
                        .transformSeries({
                        Timestamp: function (t) { return moment(t).format(dateFormat); },
                    })
                        .asCSV()
                        .writeFileSync(argv.out);
                    return [2 /*return*/];
            }
        });
    });
}


function(val) {
                // here you may parse your format when you build your plugin
                var valueInPicker = this.options.itemProperty ? this.pickerValue[this.options.itemProperty] : this.pickerValue;
                return (val ? val : valueInPicker);
            }

function ( val ) { var valueInPicker = this . options . itemProperty ? this . pickerValue [ this . options . itemProperty ] : this . pickerValue ; return ( val ? val : valueInPicker ) ; }

Returns the formatted item value
@returns string


function(val) {
                val = this.setValue(val);
                if ((val !== false) && (val !== '')) {
                    if (this.hasInput()) {
                        this.input.val(this.getValue());
                    } else {
                        this.element.data('pickerValue', this.getValue());
                    }
                    this._trigger('pickerSetSourceValue', {
                        pickerValue: val
                    });
                }
                return val;
            }

function ( val ) { val = this . setValue ( val ) ; if ( ( val !== false ) && ( val !== '' ) ) { if ( this . hasInput ( ) ) { this . input . val ( this . getValue ( ) ) ; } else { this . element . data ( 'pickerValue' , this . getValue ( ) ) ; } this . _trigger ( 'pickerSetSourceValue' , { pickerValue : val } ) ; } return val ; }

Calls setValue and if it's a valid item value, sets the input or element value

Calls setValue and if it s a valid item value sets the input or element value


function(defaultValue) {
                // returns the input or element value, as string
                defaultValue = defaultValue || this.options.defaultValue;
                var val = defaultValue;

                if (this.hasInput()) {
                    val = this.input.val();
                } else {
                    val = this.element.data('pickerValue');
                    val = this.options.itemProperty ? val[this.options.itemProperty] : val;
                }
                if ((val === undefined) || (val === '') || (val === null) || (val === false)) {
                    // if not defined or empty, return default
                    val = defaultValue;
                }
                return val;
            }

function ( defaultValue ) { defaultValue = defaultValue || this . options . defaultValue ; var val = defaultValue ; if ( this . hasInput ( ) ) { val = this . input . val ( ) ; } else { val = this . element . data ( 'pickerValue' ) ; val = this . options . itemProperty ? val [ this . options . itemProperty ] : val ; } if ( ( val === undefined ) || ( val === '' ) || ( val === null ) || ( val === false ) ) { val = defaultValue ; } return val ; }

Returns the input or element item value, without formatting, or defaultValue
if it's empty string, undefined, false or null
@param {type} defaultValue
@returns string|mixed

Returns the input or element item value without formatting or defaultValue if it s empty string undefined false or null


function createMarkdownSerializer(indentCodeBlocks) {
  return {
    serialize: (name, suite) => snapshotToMarkdown(name, suite, indentCodeBlocks),
    deserialize: markdownToSnapshot,
  };
}

function createMarkdownSerializer ( indentCodeBlocks ) { return { serialize : ( name , suite ) => snapshotToMarkdown ( name , suite , indentCodeBlocks ) , deserialize : markdownToSnapshot , } ; }

createMarkdownSerializer create a snapshot serializer.

@param {boolean} indentCodeBlocks Use indentation for code blocks.
@returns Snapshot serializer.

createMarkdownSerializer create a snapshot serializer .


function markdownToSnapshot(content) {
  const tree = mdParser.parse(content);

  const state = {
    name: null,
    suite: null,
    suiteStack: [],
    currentSuite: null,
    currentSnapshotList: null,
    depth: 0
  };

  const children = tree.children;
  for (let i = 0; i < children.length; i++) {
    const c = children[i];
    switch (c.type) {
      case 'heading':
        if (c.depth === 1) {
          enterRootSuite(state, c);
        } else if (c.depth === 2) {
          tryExit(state, suiteDepth(c));
          enterSuite(state, c);
        } else if (c.depth === 4) {
          enterSnapshot(state, c);
        }
        break;
      case 'code':
        pushSnapshotCode(state, c);
        break;
    }
  }

  return { name: state.name, suite: state.suite };
}

function markdownToSnapshot ( content ) { const tree = mdParser . parse ( content ) ; const state = { name : null , suite : null , suiteStack : [ ] , currentSuite : null , currentSnapshotList : null , depth : 0 } ; const children = tree . children ; for ( let i = 0 ; i < children . length ; i ++ ) { const c = children [ i ] ; switch ( c . type ) { case 'heading' : if ( c . depth === 1 ) { enterRootSuite ( state , c ) ; } else if ( c . depth === 2 ) { tryExit ( state , suiteDepth ( c ) ) ; enterSuite ( state , c ) ; } else if ( c . depth === 4 ) { enterSnapshot ( state , c ) ; } break ; case 'code' : pushSnapshotCode ( state , c ) ; break ; } } return { name : state . name , suite : state . suite } ; }

markdownToSnapshot converts snapshot from markdown format into native.

@param {string} content Snapshot in a markdown format.
@returns Snapshot in a native format.

markdownToSnapshot converts snapshot from markdown format into native .


function tryExit(state, depth) {
  while (state.depth >= depth) {
    state.suiteStack.pop();
    state.currentSuite = state.suiteStack[state.suiteStack.length - 1];
    state.currentSnapshotList = null;
    state.depth--;
  }
}

function tryExit ( state , depth ) { while ( state . depth >= depth ) { state . suiteStack . pop ( ) ; state . currentSuite = state . suiteStack [ state . suiteStack . length - 1 ] ; state . currentSnapshotList = null ; state . depth -- ; } }

tryExit tries to pop state until it has correct depth.

@param {SerializerState} state Current state.
@param {number} depth Current depth.

tryExit tries to pop state until it has correct depth .


function enterRootSuite(state, node) {
  const inlineCode = node.children[0];
  const name = inlineCode.value;
  const suite = {
    children: {},
    snapshots: {}
  }
  state.name = name;
  state.suite = suite;
  state.suiteStack.push(suite);
  state.currentSuite = suite;
  state.currentSnapshotList = null;
  state.depth = 0;
}

function enterRootSuite ( state , node ) { const inlineCode = node . children [ 0 ] ; const name = inlineCode . value ; const suite = { children : { } , snapshots : { } } state . name = name ; state . suite = suite ; state . suiteStack . push ( suite ) ; state . currentSuite = suite ; state . currentSnapshotList = null ; state . depth = 0 ; }

enterRootSuite pushes root suite into the current state.

@param {SerializerState} state Current state.
@param {*} node Markdown node.

enterRootSuite pushes root suite into the current state .


function enterSnapshot(state, node) {
  const inlineCode = node.children[0];
  const name = inlineCode.value;
  const snapshotList = [];
  state.currentSuite.snapshots[name] = snapshotList;
  state.currentSnapshotList = snapshotList;
}

function enterSnapshot ( state , node ) { const inlineCode = node . children [ 0 ] ; const name = inlineCode . value ; const snapshotList = [ ] ; state . currentSuite . snapshots [ name ] = snapshotList ; state . currentSnapshotList = snapshotList ; }

enterSnapshot pushes snapshot into the current state.

@param {SerializerState} state Current state.
@param {*} node Markdown node.

enterSnapshot pushes snapshot into the current state .


function pushSnapshotCode(state, node) {
  state.currentSnapshotList.push({
    lang: node.lang,
    code: normalizeNewlines(node.value)
  });
}

function pushSnapshotCode ( state , node ) { state . currentSnapshotList . push ( { lang : node . lang , code : normalizeNewlines ( node . value ) } ) ; }

pushSnapshotCode adds snapshot to the current snapshot.

@param {SerializerState} state Current state.
@param {*} node Markdown node.

pushSnapshotCode adds snapshot to the current snapshot .


function transformSuite(name, suite, depth, indentCodeBlocks) {
  const children = suite.children;
  const snapshots = suite.snapshots;
  const nextDepth = depth + 1;

  let result = suiteHeader(name, depth);
  let keys, i;

  keys = Object.keys(snapshots);
  for (i = 0; i < keys.length; i++) {
    const key = keys[i];
    const snapshotList = snapshots[key];
    result += transformSnapshotList(key, snapshotList, nextDepth, indentCodeBlocks);
  }

  keys = Object.keys(children);
  for (i = 0; i < keys.length; i++) {
    const key = keys[i];
    result += transformSuite(key, children[key], nextDepth, indentCodeBlocks);
  }
  return result;
}

function transformSuite ( name , suite , depth , indentCodeBlocks ) { const children = suite . children ; const snapshots = suite . snapshots ; const nextDepth = depth + 1 ; let result = suiteHeader ( name , depth ) ; let keys , i ; keys = Object . keys ( snapshots ) ; for ( i = 0 ; i < keys . length ; i ++ ) { const key = keys [ i ] ; const snapshotList = snapshots [ key ] ; result += transformSnapshotList ( key , snapshotList , nextDepth , indentCodeBlocks ) ; } keys = Object . keys ( children ) ; for ( i = 0 ; i < keys . length ; i ++ ) { const key = keys [ i ] ; result += transformSuite ( key , children [ key ] , nextDepth , indentCodeBlocks ) ; } return result ; }

transformSuite converts suite from native into markdown format.

@param {string} name Suite name.
@param {*} suite Suite.
@param {number} depth Suite depth.
@param {boolean} indentCodeBlocks  Use indentation for code blocks.
@returns Suite in a markdown format.

transformSuite converts suite from native into markdown format .


function transformSnapshotList(name, snapshotList, depth, indentCodeBlocks) {
  let result = snapshotHeader(name, depth);

  for (let i = 0; i < snapshotList.length; i++) {
    if (i > 0 && indentCodeBlocks) {
      result += '---\n\n';
    }
    const snapshot = snapshotList[i];
    const lang = snapshot.lang;
    const code = snapshot.code;
    const delimiter = safeDelimiter(code);

    if (indentCodeBlocks) {
      const lines = code.split('\n');
      for (let i = 0; i < lines.length; i++) {
        result += '    ' + lines[i] + '\n';
      }
    } else {
      result += delimiter;
      if (lang) {
        result += lang;
      }
      result += '\n' + code + '\n' + delimiter + '\n';
    }

    result += '\n';
  }

  return result;
}

function
transformSnapshotList
(
name
,
snapshotList
,
depth
,
indentCodeBlocks
)
{
let
result
=
snapshotHeader
(
name
,
depth
)
;
for
(
let
i
=
0
;
i
<
snapshotList
.
length
;
i
++
)
{
if
(
i
>
0
&&
indentCodeBlocks
)
{
result
+=
'---\n\n'
;
}
\n
\n
const
snapshot
=
snapshotList
[
i
]
;
const
lang
=
snapshot
.
lang
;
const
code
=
snapshot
.
code
;
const
delimiter
=
safeDelimiter
(
code
)
;
}
if
(
indentCodeBlocks
)
{
const
lines
=
code
.
split
(
'\n'
)
;
\n
}
else
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
++
)
{
result
+=
'    '
+
lines
[
i
]
+
'\n'
;
}
}

transformSnapshotList converts snapshot list from native into markdown format.

@param {number} name Snapshot name.
@param {*} snapshotList Snapshot list.
@param {number} depth Snapshot depth.
@param {boolean} indentCodeBlocks  Use indentation for code blocks.
@returns Snapshot in a markdown format.

transformSnapshotList converts snapshot list from native into markdown format .


function suiteHeader(name, depth) {
  if (depth === -1) {
    return "# " + serializeName(name) + "\n\n";
  }
  return "## " + indent(depth) + serializeName(name) + "\n\n";
}

function
suiteHeader
(
name
,
depth
)
{
if
(
depth
===
1
)
{
return
"# "
+
serializeName
(
name
)
+
"\n\n"
;
}
\n
}

suiteHeader serializes suite header.

@param {string} name Suite name.
@param {number} depth Suite depth.
@returns Serialized suite header.


function safeDelimiter(s, delimiter) {
  if (delimiter === undefined) {
    delimiter = '```';
  }
  while (s.indexOf(delimiter) !== -1) {
    delimiter += '`';
  }
  return delimiter;
}

function safeDelimiter ( s , delimiter ) { if ( delimiter === undefined ) { delimiter = '```' ; } while ( s . indexOf ( delimiter ) !== - 1 ) { delimiter += '`' ; } return delimiter ; }

safeDelimiter tries to find a safe delimiter by appending backticks until it finally finds it.

@param {string} s String that should be delimited.
@param {string} delimiter Initial delimiter.
@returns Safe delimiter.

safeDelimiter tries to find a safe delimiter by appending backticks until it finally finds it .


function defaultPathResolver(basePath, suiteName) {
  const suiteSourcePath = path.join(basePath, suiteName);
  const suiteSourceDir = path.dirname(suiteSourcePath);
  const sourceFileName = path.basename(suiteName);

  return path.join(suiteSourceDir, "__snapshots__", sourceFileName + ".md");
}

function defaultPathResolver ( basePath , suiteName ) { const suiteSourcePath = path . join ( basePath , suiteName ) ; const suiteSourceDir = path . dirname ( suiteSourcePath ) ; const sourceFileName = path . basename ( suiteName ) ; return path . join ( suiteSourceDir , "__snapshots__" , sourceFileName + ".md" ) ; }

defaultPathResolver is a default path resolver for snapshot files.

@param {string} basePath Base path.
@param {string} suiteName Name of the suite.
@returns Full path to snapshot file.

defaultPathResolver is a default path resolver for snapshot files .


function formatSnapshotList(list, limit) {
  limit = (typeof limit != 'undefined') ? limit : -1;

  const limitedList = limit > 0 ? list.slice(0, limit) : list;
  const hasMore = list.length > limitedList.length;
  const buildList = (snapshots) => snapshots.map((s) => s.join(' > ')).join('\n');

  if (hasMore) {
    return buildList(limitedList.slice(0, -1)) + `\n +${list.length - limitedList.length + 1} more`;
  }

  return buildList(limitedList);
}

function
formatSnapshotList
(
list
,
limit
)
{
limit
=
(
typeof
limit
!=
'undefined'
)
limit
:
1
;
const
limitedList
=
limit
>
0
list
.
slice
(
0
,
limit
)
:
list
;
const
hasMore
=
list
.
length
>
limitedList
.
length
;
const
buildList
=
(
snapshots
)
=>
snapshots
.
map
(
(
s
)
=>
s
.
join
(
' > '
)
)
.
join
(
'\n'
)
;
\n
if
(
hasMore
)
{
return
buildList
(
limitedList
.
slice
(
0
,
1
)
)
+
`
\n
${
list
.
length
limitedList
.
length
+
1
}
`
;
}
}

Renders a list of snapshots up to specified limit of lines
@param list {array} list of snapshots
@param limit {number} maximum number of lines rendered under summary
@returns {string}


function formatUnusedSnapshotsWarning(list, limit) {
  if (limit == 0) {
    return `Found ${list.length} unused snapshots`;
  }

  const prunedList = formatSnapshotList(list, limit);
  return `Found ${list.length} unused snapshots:\n${prunedList}`;
}

function formatUnusedSnapshotsWarning ( list , limit ) { if ( limit == 0 ) { return ` ${ list . length } ` ; } const prunedList = formatSnapshotList ( list , limit ) ; return ` ${ list . length } \n ${ prunedList } ` ; }

Renders the message for unused snapshots warning
@param list {array} list of snapshots
@param limit {number} maximum number of lines rendered under summary
@returns {string}


function snapshotPreprocessor(basePath, loggerFactory) {
  const logger = loggerFactory.create('preprocessor.snapshot');

  return function (content, file, done) {
    const root = snapshotSerializer.deserialize(content);
    done(iifeWrapper('window.__snapshot__.addSuite("' + root.name + '",' + JSON.stringify(root.suite) + ');'));
  };
}

function snapshotPreprocessor ( basePath , loggerFactory ) { const logger = loggerFactory . create ( 'preprocessor.snapshot' ) ; return function ( content , file , done ) { const root = snapshotSerializer . deserialize ( content ) ; done ( iifeWrapper ( 'window.__snapshot__.addSuite("' + root . name + '",' + JSON . stringify ( root . suite ) + ');' ) ) ; } ; }

Snapshot preprocessor.

@param {string} basePath Base path.
@param {*} loggerFactory Karma logger factory.
@returns Karma preprocessor.


function singleLinePlugin (options = {}) {
  options = Object.assign({}, defaultOptions, options)

  return {
    /**
     * Return a compatible blockRenderMap
     *
     * NOTE: Needs to be explicitly applied, the plugin system doesn’t do
     * anything with this at the moment.
     *
     * @type {ImmutableMap}
     */
    blockRenderMap: Map({
      'unstyled': {
        element: 'div',
      },
    }),

    /**
     * onChange
     *
     * Condense multiple blocks into a single block and (optionally) strip all
     * entities from the content of that block.
     *
     * @param  {EditorState} editorState The current state of the editor
     * @return {EditorState} A new editor state
     */
    onChange (editorState) {
      const blocks = editorState.getCurrentContent().getBlocksAsArray()

      // If we have more than one block, compress them
      if (blocks.length > 1) {
        editorState = condenseBlocks(editorState, blocks, options)
      } else {
        // We only have one content block
        let contentBlock = blocks[0]
        let text = contentBlock.getText()
        let characterList = contentBlock.getCharacterList()
        let hasEntitiesToStrip = options.stripEntities && characterListhasEntities(characterList)

        if (NEWLINE_REGEX.test(text) || hasEntitiesToStrip) {
          // Replace the text stripped of its newlines. Note that we replace
          // one '\n' with one ' ' so we don't need to modify the characterList
          text = replaceNewlines(text)

          // Strip entities?
          if (options.stripEntities) {
            characterList = characterList.map(stripEntityFromCharacterMetadata)
          }

          // Create a new content block based on the old one
          contentBlock = new ContentBlock({
            key: genKey(),
            text: text,
            type: 'unstyled',
            characterList: characterList,
            depth: 0,
          })

          // Update the editor state with the compressed version
          // const selection = editorState.getSelection()
          const newContentState = ContentState.createFromBlockArray([contentBlock])

          // Create the new state as an undoable action
          editorState = EditorState.push(editorState, newContentState, 'insert-characters')
        }
      }

      return editorState
    },

    /**
     * Stop new lines being inserted by always handling the return
     *
     * @param  {KeyboardEvent} e Synthetic keyboard event from draftjs
     * @return {String} Did we handle the return or not? (pro-trip: yes, we did)
     */
    handleReturn (e) {
      return 'handled'
    },
  }
}

function singleLinePlugin ( options = { } ) { options = Object . assign ( { } , defaultOptions , options ) return { blockRenderMap : Map ( { 'unstyled' : { element : 'div' , } , } ) , onChange ( editorState ) { const blocks = editorState . getCurrentContent ( ) . getBlocksAsArray ( ) if ( blocks . length > 1 ) { editorState = condenseBlocks ( editorState , blocks , options ) } else { let contentBlock = blocks [ 0 ] let text = contentBlock . getText ( ) let characterList = contentBlock . getCharacterList ( ) let hasEntitiesToStrip = options . stripEntities && characterListhasEntities ( characterList ) if ( NEWLINE_REGEX . test ( text ) || hasEntitiesToStrip ) { text = replaceNewlines ( text ) if ( options . stripEntities ) { characterList = characterList . map ( stripEntityFromCharacterMetadata ) } contentBlock = new ContentBlock ( { key : genKey ( ) , text : text , type : 'unstyled' , characterList : characterList , depth : 0 , } ) const newContentState = ContentState . createFromBlockArray ( [ contentBlock ] ) editorState = EditorState . push ( editorState , newContentState , 'insert-characters' ) } } return editorState } , handleReturn ( e ) { return 'handled' } , } }

Single Line Plugin
@param  {Object} options Per-instance options to override the defaults
@return {Object} Compatible draft-js-editor-plugin object


function replaceNewlines(str) {
  var replacement = arguments.length <= 1 || arguments[1] === undefined ? ' ' : arguments[1];

  return str.replace(NEWLINE_REGEX, replacement);
}

function
replaceNewlines
(
str
)
{
var
replacement
=
arguments
.
length
<=
1
||
arguments
[
1
]
===
undefined
' '
:
arguments
[
1
]
;
return
str
.
replace
(
NEWLINE_REGEX
,
replacement
)
;
}

Replace newline characters with the passed string
@param  {String} str String to replace
@param  {String} replacement Replacement characters
@return {String} Modified string


function condenseBlocks(editorState, blocks, options) {
  blocks = blocks || editorState.getCurrentContent().getBlocksAsArray();
  var text = (0, _immutable.List)();
  var characterList = (0, _immutable.List)();

  // Gather all the text/characterList and concat them
  blocks.forEach(function (block) {
    // Atomic blocks should be ignored (stripped)
    if (block.getType() !== 'atomic') {
      text = text.push(replaceNewlines(block.getText()));
      characterList = characterList.concat(block.getCharacterList());
    }
  });

  // Strip entities?
  if (options.stripEntities) {
    characterList = characterList.map(stripEntityFromCharacterMetadata);
  }

  // Create a new content block
  var contentBlock = new _draftJs.ContentBlock({
    key: (0, _draftJs.genKey)(),
    text: text.join(''),
    type: 'unstyled',
    characterList: characterList,
    depth: 0
  });

  // Update the editor state with the compressed version
  var newContentState = _draftJs.ContentState.createFromBlockArray([contentBlock]);
  // Create the new state as an undoable action
  editorState = _draftJs.EditorState.push(editorState, newContentState, 'remove-range');
  // Move the selection to the end
  return _draftJs.EditorState.moveFocusToEnd(editorState);
}

function condenseBlocks ( editorState , blocks , options ) { blocks = blocks || editorState . getCurrentContent ( ) . getBlocksAsArray ( ) ; var text = ( 0 , _immutable . List ) ( ) ; var characterList = ( 0 , _immutable . List ) ( ) ; blocks . forEach ( function ( block ) { if ( block . getType ( ) !== 'atomic' ) { text = text . push ( replaceNewlines ( block . getText ( ) ) ) ; characterList = characterList . concat ( block . getCharacterList ( ) ) ; } } ) ; if ( options . stripEntities ) { characterList = characterList . map ( stripEntityFromCharacterMetadata ) ; } var contentBlock = new _draftJs . ContentBlock ( { key : ( 0 , _draftJs . genKey ) ( ) , text : text . join ( '' ) , type : 'unstyled' , characterList : characterList , depth : 0 } ) ; var newContentState = _draftJs . ContentState . createFromBlockArray ( [ contentBlock ] ) ; editorState = _draftJs . EditorState . push ( editorState , newContentState , 'remove-range' ) ; return _draftJs . EditorState . moveFocusToEnd ( editorState ) ; }

Condense an array of content blocks into a single block
@param  {EditorState} editorState draft-js EditorState instance
@param  {Array} blocks Array of ContentBlocks
@param  {Object} options
@return {EditorState} A modified EditorState instance


function characterListhasEntities(characterList) {
  var hasEntities = false;
  characterList.forEach(function (characterMeta) {
    if (characterMeta.get('entity') !== null) {
      hasEntities = true;
    }
  });
  return hasEntities;
}

function characterListhasEntities ( characterList ) { var hasEntities = false ; characterList . forEach ( function ( characterMeta ) { if ( characterMeta . get ( 'entity' ) !== null ) { hasEntities = true ; } } ) ; return hasEntities ; }

Check if a CharacterList contains entities
@param  {CharacterList} characterList The list of characters to check
@return {Boolean} Contains entities?


function hexRgb(hex){
    let shorthandCheck = /^([a-f\d])([a-f\d])([a-f\d])$/i,
        rgbRegex = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,
        rgb;

    hex = hex.replace(shorthandCheck, function(m, r, g, b) {
      return r + r + g + g + b + b;
    });

    rgb = hex.replace(/^\s+|\s+$/g, '').match(rgbRegex);

    // Convert it
    return rgb ? [
      parseInt(rgb[1], 16),
      parseInt(rgb[2], 16),
      parseInt(rgb[3], 16)
    ] : false;
  }

function hexRgb ( hex ) { let shorthandCheck = / ^([a-f\d])([a-f\d])([a-f\d])$ / i , rgbRegex = / ^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$ / i , rgb ; hex = hex . replace ( shorthandCheck , function ( m , r , g , b ) { return r + r + g + g + b + b ; } ) ; rgb = hex . replace ( / ^\s+|\s+$ / g , '' ) . match ( rgbRegex ) ; return rgb ? [ parseInt ( rgb [ 1 ] , 16 ) , parseInt ( rgb [ 2 ] , 16 ) , parseInt ( rgb [ 3 ] , 16 ) ] : false ; }

Hex to RGB converter
@param  {string} hex hexidecimal string without #
@return {array} RGB values


function ruleHandler(decl, result) {
    let input = decl.value;

    // Get the raw hex values and replace them
    let output = input.replace(/rgba\(#(.*?),/g, (match, hex) => {
      let rgb = hexRgb(hex),
          matchHex = new RegExp('#' + hex);

      // If conversion fails, emit a warning
      if (!rgb) {
        result.warn('not a valid hex', { node: decl });
        return match;
      }

      rgb = rgb.toString();

      return match.replace(matchHex, rgb);
    });

    decl.replaceWith({
      prop: decl.prop,
      value: output,
      important: decl.important
    });
  }

function
ruleHandler
(
decl
,
result
)
{
let
input
=
decl
.
value
;
let
output
=
input
.
replace
(
/
rgba\(#(.*?),
/
g
,
(
match
,
hex
)
=>
{
let
rgb
=
hexRgb
(
hex
)
,
matchHex
=
new
RegExp
(
'#'
+
hex
)
;
if
(
!
rgb
)
{
result
.
warn
(
'not a valid hex'
,
{
node
:
decl
}
)
;
return
match
;
}
rgb
=
rgb
.
toString
(
)
;
return
match
.
replace
(
matchHex
,
rgb
)
;
}
)
;
decl
.
replaceWith
(
{
prop
:
decl
.
prop
,
value
:
output
,
important
:
decl
.
important
}
)
;
}

CSS rule handler
@param  {string} decl CSS delcaration


function () {
            for (var i = 0; i < this.config.methods.length; i++) {
                var key = this.config.methods[i];

                // Only create analytics stub if it doesn't already exist
                if (!analytics[key]) {
                    analytics[key] = analytics.factory(key);
                }

                this[key] = this.factory(key);
            }
        }

function ( ) { for ( var i = 0 ; i < this . config . methods . length ; i ++ ) { var key = this . config . methods [ i ] ; if ( ! analytics [ key ] ) { analytics [ key ] = analytics . factory ( key ) ; } this [ key ] = this . factory ( key ) ; } }


function debug(namespace) {

  // define the `disabled` version
  function disabled() {
  }
  disabled.enabled = false;

  // define the `enabled` version
  function enabled() {

    var self = enabled;

    // set `diff` timestamp
    var curr = +new Date();
    var ms = curr - (prevTime || curr);
    self.diff = ms;
    self.prev = prevTime;
    self.curr = curr;
    prevTime = curr;

    // add the `color` if not set
    if (null == self.useColors) self.useColors = exports.useColors();
    if (null == self.color && self.useColors) self.color = selectColor();

    var args = new Array(arguments.length);
    for (var i = 0; i < args.length; i++) {
      args[i] = arguments[i];
    }

    args[0] = exports.coerce(args[0]);

    if ('string' !== typeof args[0]) {
      // anything else let's inspect with %o
      args = ['%o'].concat(args);
    }

    // apply any `formatters` transformations
    var index = 0;
    args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
      // if we encounter an escaped % then don't increase the array index
      if (match === '%%') return match;
      index++;
      var formatter = exports.formatters[format];
      if ('function' === typeof formatter) {
        var val = args[index];
        match = formatter.call(self, val);

        // now we need to remove `args[index]` since it's inlined in the `format`
        args.splice(index, 1);
        index--;
      }
      return match;
    });

    // apply env-specific formatting
    args = exports.formatArgs.apply(self, args);

    var logFn = enabled.log || exports.log || console.log.bind(console);
    logFn.apply(self, args);
  }
  enabled.enabled = true;

  var fn = exports.enabled(namespace) ? enabled : disabled;

  fn.namespace = namespace;

  return fn;
}

function debug ( namespace ) { function disabled ( ) { } disabled . enabled = false ; function enabled ( ) { var self = enabled ; var curr = + new Date ( ) ; var ms = curr - ( prevTime || curr ) ; self . diff = ms ; self . prev = prevTime ; self . curr = curr ; prevTime = curr ; if ( null == self . useColors ) self . useColors = exports . useColors ( ) ; if ( null == self . color && self . useColors ) self . color = selectColor ( ) ; var args = new Array ( arguments . length ) ; for ( var i = 0 ; i < args . length ; i ++ ) { args [ i ] = arguments [ i ] ; } args [ 0 ] = exports . coerce ( args [ 0 ] ) ; if ( 'string' !== typeof args [ 0 ] ) { args = [ '%o' ] . concat ( args ) ; } var index = 0 ; args [ 0 ] = args [ 0 ] . replace ( / %([a-z%]) / g , function ( match , format ) { if ( match === '%%' ) return match ; index ++ ; var formatter = exports . formatters [ format ] ; if ( 'function' === typeof formatter ) { var val = args [ index ] ; match = formatter . call ( self , val ) ; args . splice ( index , 1 ) ; index -- ; } return match ; } ) ; args = exports . formatArgs . apply ( self , args ) ; var logFn = enabled . log || exports . log || console . log . bind ( console ) ; logFn . apply ( self , args ) ; } enabled . enabled = true ; var fn = exports . enabled ( namespace ) ? enabled : disabled ; fn . namespace = namespace ; return fn ; }

Create a debugger with the given `namespace`.

@param {String} namespace
@return {Function}
@api public

Create a debugger with the given namespace .


function isBuf$1(obj) {
  return (commonjsGlobal.Buffer && commonjsGlobal.Buffer.isBuffer(obj)) ||
         (commonjsGlobal.ArrayBuffer && obj instanceof ArrayBuffer);
}

function isBuf$1 ( obj ) { return ( commonjsGlobal . Buffer && commonjsGlobal . Buffer . isBuffer ( obj ) ) || ( commonjsGlobal . ArrayBuffer && obj instanceof ArrayBuffer ) ; }

Returns true if obj is a buffer or an arraybuffer.

@api private

Returns true if obj is a buffer or an arraybuffer .


function encode$1(num) {
  var encoded = '';

  do {
    encoded = alphabet[num % length] + encoded;
    num = Math.floor(num / length);
  } while (num > 0);

  return encoded;
}

function encode$1 ( num ) { var encoded = '' ; do { encoded = alphabet [ num % length ] + encoded ; num = Math . floor ( num / length ) ; } while ( num > 0 ) ; return encoded ; }

Return a string representing the specified number.

@param {Number} num The number to convert.
@returns {String} The string representation of the number.
@api public

Return a string representing the specified number .


function decode$1(str) {
  var decoded = 0;

  for (i = 0; i < str.length; i++) {
    decoded = decoded * length + map[str.charAt(i)];
  }

  return decoded;
}

function decode$1 ( str ) { var decoded = 0 ; for ( i = 0 ; i < str . length ; i ++ ) { decoded = decoded * length + map [ str . charAt ( i ) ] ; } return decoded ; }

Return the integer value specified by the given string.

@param {String} str The string to convert.
@returns {Number} The integer value represented by the string.
@api public

Return the integer value specified by the given string .


function Polling$1 (opts) {
  var forceBase64 = (opts && opts.forceBase64);
  if (!hasXHR2 || forceBase64) {
    this.supportsBinary = false;
  }
  Transport.call(this, opts);
}

function Polling$1 ( opts ) { var forceBase64 = ( opts && opts . forceBase64 ) ; if ( ! hasXHR2 || forceBase64 ) { this . supportsBinary = false ; } Transport . call ( this , opts ) ; }

Polling interface.

@param {Object} opts
@api private


function onupgrade (to) {
    if (transport$$1 && to.name !== transport$$1.name) {
      debug$2('"%s" works - aborting "%s"', to.name, transport$$1.name);
      freezeTransport();
    }
  }

function
onupgrade
(
to
)
{
if
(
transport$$1
&&
to
.
name
!==
transport$$1
.
name
)
{
debug$2
(
'"%s" works - aborting "%s"'
,
to
.
name
,
transport$$1
.
name
)
;
freezeTransport
(
)
;
}
}

When the socket is upgraded while we're probing

When the socket is upgraded while we re probing


function cleanup () {
    transport$$1.removeListener('open', onTransportOpen);
    transport$$1.removeListener('error', onerror);
    transport$$1.removeListener('close', onTransportClose);
    self.removeListener('close', onclose);
    self.removeListener('upgrading', onupgrade);
  }

function cleanup ( ) { transport$$1 . removeListener ( 'open' , onTransportOpen ) ; transport$$1 . removeListener ( 'error' , onerror ) ; transport$$1 . removeListener ( 'close' , onTransportClose ) ; self . removeListener ( 'close' , onclose ) ; self . removeListener ( 'upgrading' , onupgrade ) ; }

Remove all listeners on the transport and on self


function Backoff$1(opts) {
  opts = opts || {};
  this.ms = opts.min || 100;
  this.max = opts.max || 10000;
  this.factor = opts.factor || 2;
  this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
  this.attempts = 0;
}

function Backoff$1 ( opts ) { opts = opts || { } ; this . ms = opts . min || 100 ; this . max = opts . max || 10000 ; this . factor = opts . factor || 2 ; this . jitter = opts . jitter > 0 && opts . jitter <= 1 ? opts . jitter : 0 ; this . attempts = 0 ; }

Initialize backoff timer with `opts`.

- `min` initial timeout in milliseconds [100]
- `max` max timeout [10000]
- `jitter` [0]
- `factor` [2]

@param {Object} opts
@api public


function extract(str, options) {
  const res = babylon.parse(str, options);
  return res.comments;
}

function extract ( str , options ) { const res = babylon . parse ( str , options ) ; return res . comments ; }

Extract code comments from the given `string`.

```js
var extract = require('babel-extract-comments');
console.log(extract('// this is a code comment'));
// [{ type: 'CommentBlock',
//  value: '!\n * babel-extract-comments <https://github.com/jonschlinkert/babel-extract-comments>\n *\n *
// Copyright (c) 2014-2018, Jon Schlinkert.\n * Released under the MIT License.\n ',
//   start: 0,
//   end: 173,
//   loc: SourceLocation { start: [Position], end: [Position] } }]
```
@param  {String} `string` String of javascript
@return {Array} Array of code comment objects.
@api public

Extract code comments from the given string .


function bindNgModelControls(api) {
      ngModel.$render = () => {
        api.set(ngModel.$modelValue);
      };

      api.on('update', () => {
        const positions = api.get();
        ngModel.$setViewValue(positions);
      });
    }

function bindNgModelControls ( api ) { ngModel . $render = ( ) => { api . set ( ngModel . $modelValue ) ; } ; api . on ( 'update' , ( ) => { const positions = api . get ( ) ; ngModel . $setViewValue ( positions ) ; } ) ; }

Add ngModel controls to the directive. This allows the use of ngModel to set and get the
value in the slider. It uses the noUiSlider API's get and set functions, so no custom
formatters need to be defined for ngModel. The ngModelOptions can be used.

@param {Object} api The API instance returned by the `noUiSlider.create()` method

Add ngModel controls to the directive . This allows the use of ngModel to set and get the value in the slider . It uses the noUiSlider API s get and set functions so no custom formatters need to be defined for ngModel . The ngModelOptions can be used .


function createInstance() {
      const api = extendApi(noUiSlider.create(htmlElement, options));

      setCreatedWatcher(api);
      setOptionsWatcher(api);

      if (ngModel !== null) {
        bindNgModelControls(api);
      }
    }

function createInstance ( ) { const api = extendApi ( noUiSlider . create ( htmlElement , options ) ) ; setCreatedWatcher ( api ) ; setOptionsWatcher ( api ) ; if ( ngModel !== null ) { bindNgModelControls ( api ) ; } }


function(w) {
    let vow = /[aeiouy]$/;
    let chars = w.split('');
    let before = '';
    let after = '';
    let current = '';
    for (let i = 0; i < chars.length; i++) {
      before = chars.slice(0, i).join('');
      current = chars[i];
      after = chars.slice(i + 1, chars.length).join('');
      let candidate = before + chars[i];

      //it's a consonant that comes after a vowel
      if (before.match(ends_with_vowel) && !current.match(ends_with_vowel)) {
        if (after.match(starts_with_e_then_specials)) {
          candidate += 'e';
          after = after.replace(starts_with_e, '');
        }
        all.push(candidate);
        return doer(after);
      }

      //unblended vowels ('noisy' vowel combinations)
      if (candidate.match(ends_with_noisy_vowel_combos)) { //'io' is noisy, not in 'ion'
        all.push(before);
        all.push(current);
        return doer(after); //recursion
      }

      // if candidate is followed by a CV, assume consecutive open syllables
      if (candidate.match(ends_with_vowel) && after.match(starts_with_consonant_vowel)) {
        all.push(candidate);
        return doer(after);
      }
    }
    //if still running, end last syllable
    if (str.match(aiouy) || str.match(ends_with_ee)) { //allow silent trailing e
      all.push(w);
    } else {
      all[all.length - 1] = (all[all.length - 1] || '') + w; //append it to the last one
    }
    return null;
  }

function ( w ) { let vow = / [aeiouy]$ / ; let chars = w . split ( '' ) ; let before = '' ; let after = '' ; let current = '' ; for ( let i = 0 ; i < chars . length ; i ++ ) { before = chars . slice ( 0 , i ) . join ( '' ) ; current = chars [ i ] ; after = chars . slice ( i + 1 , chars . length ) . join ( '' ) ; let candidate = before + chars [ i ] ; if ( before . match ( ends_with_vowel ) && ! current . match ( ends_with_vowel ) ) { if ( after . match ( starts_with_e_then_specials ) ) { candidate += 'e' ; after = after . replace ( starts_with_e , '' ) ; } all . push ( candidate ) ; return doer ( after ) ; } if ( candidate . match ( ends_with_noisy_vowel_combos ) ) { all . push ( before ) ; all . push ( current ) ; return doer ( after ) ; } if ( candidate . match ( ends_with_vowel ) && after . match ( starts_with_consonant_vowel ) ) { all . push ( candidate ) ; return doer ( after ) ; } } if ( str . match ( aiouy ) || str . match ( ends_with_ee ) ) { all . push ( w ) ; } else { all [ all . length - 1 ] = ( all [ all . length - 1 ] || '' ) + w ; } return null ; }

method is nested because it's called recursively

method is nested because it s called recursively


function addApi(self, apiName, api) {
  for (var name in api) {
    var fn = api[name];
    if (typeof fn === "function")
      api[name] = api[name].bind(self);
  }

  var tmp = null;
  api.replied = new Promise((resolve, reject) => {
    tmp = { resolve, reject };
  });
  api.replied.resolve = tmp.resolve;
  api.replied.reject = tmp.reject;

  self[apiName] = api;
}

function addApi ( self , apiName , api ) { for ( var name in api ) { var fn = api [ name ] ; if ( typeof fn === "function" ) api [ name ] = api [ name ] . bind ( self ) ; } var tmp = null ; api . replied = new Promise ( ( resolve , reject ) => { tmp = { resolve , reject } ; } ) ; api . replied . resolve = tmp . resolve ; api . replied . reject = tmp . reject ; self [ apiName ] = api ; }

Used by ProxyDomain-derived classes to create an API method called apiName; the API
can have methods `send` and `reply` which are bound to `self`; a promise is created
in `api.replied` which is satisfied after the `reply` method has been called

@param self
@param apiName
@param api
@returns

Used by ProxyDomain - derived classes to create an API method called apiName ; the API can have methods send and reply which are bound to self ; a promise is created in api . replied which is satisfied after the reply method has been called


function getJson(path) {
      return httpGet({
        hostname: t.options.remoteClientHostname,
        port: t.options.remoteClientPort,
        path: path,
        method: 'GET'
      }).then((obj) => {
        var contentType = getContentType(obj.response);
        if (contentType !== "application/json")
          LOG.warn("Expecting JSON from " + path + " but found wrong content type: " + contentType);

        try {
          return JSON.parse(obj.data);
        } catch(ex) {
          LOG.warn("Cannot parse JSON returned from " + path);
          return null;
        }
      });
    }

function
getJson
(
path
)
{
return
httpGet
(
{
hostname
:
t
.
options
.
remoteClientHostname
,
port
:
t
.
options
.
remoteClientPort
,
path
:
path
,
method
:
'GET'
}
)
.
then
(
(
obj
)
=>
{
var
contentType
=
getContentType
(
obj
.
response
)
;
if
(
contentType
!==
"application/json"
)
LOG
.
warn
(
"Expecting JSON from "
+
path
+
" but found wrong content type: "
+
contentType
)
;
try
{
return
JSON
.
parse
(
obj
.
data
)
;
}
catch
(
ex
)
{
LOG
.
warn
(
"Cannot parse JSON returned from "
+
path
)
;
return
;
}
}
)
;
}


function splitName(method) {
  var pos = method.indexOf('.');
  if (pos < 0)
    return [ null, method ];
  var domainName = method.substring(0, pos);
  var methodName = method.substring(pos + 1);
  return [ domainName, methodName ];
}

function splitName ( method ) { var pos = method . indexOf ( '.' ) ; if ( pos < 0 ) return [ null , method ] ; var domainName = method . substring ( 0 , pos ) ; var methodName = method . substring ( pos + 1 ) ; return [ domainName , methodName ] ; }


function copyToClient(req, res) {
        return httpGet({
          hostname: t.options.remoteClientHostname,
          port: t.options.remoteClientPort,
          path: req.originalUrl,
          method: 'GET'
        }).then(function (obj) {
          var contentType = getContentType(obj.response);
          if (contentType) res.set("Content-Type", contentType);
          res.send(obj.data);
        });
      }

function copyToClient ( req , res ) { return httpGet ( { hostname : t . options . remoteClientHostname , port : t . options . remoteClientPort , path : req . originalUrl , method : 'GET' } ) . then ( function ( obj ) { var contentType = getContentType ( obj . response ) ; if ( contentType ) res . set ( "Content-Type" , contentType ) ; res . send ( obj . data ) ; } ) ; }

Gets data from the remote server and copies it to the client


function () {
    // Save original Error.prepareStackTrace
    const origPrepareStackTrace = Error.prepareStackTrace
    // Override with function that just returns `stack`
    Error.prepareStackTrace = (_, stack) => stack

    // Create a new `Error`, which automatically gets `stack`
    const err = new Error()
    // Evaluate `err.stack`, which calls our new `Error.prepareStackTrace`
    const stack = err.stack
    // Restore original `Error.prepareStackTrace`
    Error.prepareStackTrace = origPrepareStackTrace
    // Remove superfluous function call on stack
    stack.shift() // getStack --> Error
    return stack
  }

function ( ) { const origPrepareStackTrace = Error . prepareStackTrace Error . prepareStackTrace = ( _ , stack ) => stack const err = new Error ( ) const stack = err . stack Error . prepareStackTrace = origPrepareStackTrace stack . shift ( ) return stack }

Get native stack
@returns array of javascript calls


function captureStdio(opts, exec) {
  var streams = [
    process.stdout,
    process.stderr
  ];

  var outputs = capture(streams, opts, exec);

  return {
    stdout: outputs.shift(),
    stderr: outputs.shift()
  };
}

function captureStdio ( opts , exec ) { var streams = [ process . stdout , process . stderr ] ; var outputs = capture ( streams , opts , exec ) ; return { stdout : outputs . shift ( ) , stderr : outputs . shift ( ) } ; }

Captures stdout and stderr into an object for
the provided execution scope.

@param opts to set flags on the capture.
@param exec the function execute inside the capture.
@returns {{stdout: String, stderr: String}}

Captures stdout and stderr into an object for the provided execution scope .


function hook(stream, opts, exec) {
  var args = _shift(opts, exec);

  opts = args[0];
  exec = args[1];

  var old_write = stream.write;

  stream.write = (function override(stream, writer) {
    return function write(string, encoding, fd) {
      exec(string, encoding, fd);

      if (!opts['quiet']) {
        writer.apply(stream, [ string, encoding, fd ]);
      }
    }
  })(stream, stream.write);

  return function unhook() {
    stream.write = old_write;
    return true;
  }
}

function hook ( stream , opts , exec ) { var args = _shift ( opts , exec ) ; opts = args [ 0 ] ; exec = args [ 1 ] ; var old_write = stream . write ; stream . write = ( function override ( stream , writer ) { return function write ( string , encoding , fd ) { exec ( string , encoding , fd ) ; if ( ! opts [ 'quiet' ] ) { writer . apply ( stream , [ string , encoding , fd ] ) ; } } } ) ( stream , stream . write ) ; return function unhook ( ) { stream . write = old_write ; return true ; } }

Listens to a provided stream, and executes the provided
function for every write call. Accepts options to silence
the output going to the console.

Returns a function to call when you wish to stop listening
to the call.

@param stream a stream to listen on.
@param opts to set flags on the capture.
@param exec the function to call with the output.
@returns {Function}

Listens to a provided stream and executes the provided function for every write call . Accepts options to silence the output going to the console .


function startCapture(stream, opts, exec) {
  var unhook = hook(stream, opts, exec);
  var str_id = random.generate();

  unhooks[str_id] = unhook;
  stream._id = str_id;

  return true;
}

function startCapture ( stream , opts , exec ) { var unhook = hook ( stream , opts , exec ) ; var str_id = random . generate ( ) ; unhooks [ str_id ] = unhook ; stream . _id = str_id ; return true ; }

Starts a capture on the provided stream using the
provided options and stream execution.

@param stream a stream to listen on.
@param opts to set flags on the capture.
@param exec the function to call with the output.
@returns {boolean}

Starts a capture on the provided stream using the provided options and stream execution .


function _wrapIntercept(func, stream, opts, exec) {
  var idex = Number(arguments.length > 3);
  var args = _shift(arguments[idex + 1], arguments[idex + 2]);

  opts = args[0];
  exec = args[1];

  opts.quiet = true;

  return idex
    ? func(stream, opts, exec)
    : func(opts, exec);
}

function _wrapIntercept ( func , stream , opts , exec ) { var idex = Number ( arguments . length > 3 ) ; var args = _shift ( arguments [ idex + 1 ] , arguments [ idex + 2 ] ) ; opts = args [ 0 ] ; exec = args [ 1 ] ; opts . quiet = true ; return idex ? func ( stream , opts , exec ) : func ( opts , exec ) ; }

Wraps capturing functions with quiet flags to
allow for interception.

@param func the function to delegate to.
@param stream a stream to listen on.
@param opts to set flags on the capture.
@param exec the function to call with the output.
@returns {*}
@private

Wraps capturing functions with quiet flags to allow for interception .


function getNearest($select, value) {
                var delta = {};
                $select.children('option').each(function(i, opt){
                    var optValue = $(opt).attr('value'),
                    distance;

                    if(optValue === '') return;
                    distance = Math.abs(optValue - value);
                    if(typeof delta.distance === 'undefined' || distance < delta.distance) {
                        delta = {value: optValue, distance: distance};
                    }
                });
                return delta.value;
            }

function getNearest ( $select , value ) { var delta = { } ; $select . children ( 'option' ) . each ( function ( i , opt ) { var optValue = $ ( opt ) . attr ( 'value' ) , distance ; if ( optValue === '' ) return ; distance = Math . abs ( optValue - value ) ; if ( typeof delta . distance === 'undefined' || distance < delta . distance ) { delta = { value : optValue , distance : distance } ; } } ) ; return delta . value ; }

function to find nearest value in select options


function evenRound ( x ) { if ( ( x > 0 && ( x % 1 ) === + 0.5 && ( x & 1 ) === 0 ) || ( x < 0 && ( x % 1 ) === - 0.5 && ( x & 1 ) === 1 ) ) { return censorNegativeZero ( Math . floor ( x ) ) ; } return censorNegativeZero ( Math . round ( x ) ) ; }

Round x to the nearest integer, choosing the even integer if it lies halfway between two.

Round x to the nearest integer choosing the even integer if it lies halfway between two .


function addFrameAt(time, value, delay, array)
{
	array.push({ time:time, value:value, delay:delay });
}

function addFrameAt ( time , value , delay , array ) { array . push ( { time : time , value : value , delay : delay } ) ; }


function sentiment(options) {
  return transformer

  function transformer(node) {
    var concatenate = concatenateFactory()

    visit(node, any(options))
    visit(node, concatenate)

    concatenate.done()
  }
}

function sentiment ( options ) { return transformer function transformer ( node ) { var concatenate = concatenateFactory ( ) visit ( node , any ( options ) ) visit ( node , concatenate ) concatenate . done ( ) } }

Patch `polarity` and `valence` properties on nodes with a value and word-nodes.  Then, patch the same properties on their parents.

Patch polarity and valence properties on nodes with a value and word - nodes . Then patch the same properties on their parents .