function registerBehaviours(aoBehaviour, bAutoBind = true)
{
    // 1. iterate through behaviours
    aoBehaviour.forEach(function(oBehaviour)
    {
        // a. default things out
        oBehaviour = Object.assign({
            defaults: {},
            namespace: '',
        }, oBehaviour);

        // b. if we don’t have a name or init
        if ((oBehaviour.name === undefined) || (oBehaviour.init === undefined))
        {
            throw new TypeError('No name or initialiser found for behaviour');
        }

        // c. if we already know about that behaviour
        if (oRegisteredBehaviours[oBehaviour.name] !== undefined)
        {
            throw new TypeError(`Duplicate behaviour ‘${oBehaviour.name}’`);
        }

        // d. register it
        oRegisteredBehaviours[oBehaviour.name] = oBehaviour;
        console.group(`Registered behaviour ‘${oBehaviour.name}’`);
        console.debug('Defaults:',  oBehaviour.defaults);
        console.debug('Namespace:', oBehaviour.namespace);
        console.groupEnd();
    });

    // 2. if we’re autobinding, do so
    (bAutoBind && bindBehaviours());
    return true;
}
/**
 * Registers an array of behaviours, optionally with autobinding.
 *
 * @param {Array} aoBehaviour - an array of behaviour objects
 * @param {boolean} bAutoBind - whether or not to immediately autobind to the document (default: true)
 * @return {boolean} true on success, false otherwise
 */
Registers an array of behaviours, optionally with autobinding.
@param {Array} aoBehaviour - an array of behaviour objects
@param {boolean} bAutoBind - whether or not to immediately autobind to the document (default: true)
@return {boolean} true on success, false otherwise
Registers an array of behaviours optionally with autobinding . @param { Array } aoBehaviour - an array of behaviour objects @param { boolean } bAutoBind - whether or not to immediately autobind to the document ( default : true ) @return { boolean } true on success false otherwise
function registerBehaviours(aoBehaviour, bAutoBind = true)
{
    aoBehaviour.forEach(function(oBehaviour)
    {
        oBehaviour = Object.assign({
            defaults: {},
            namespace: '',
        }, oBehaviour);
        if ((oBehaviour.name === undefined) || (oBehaviour.init === undefined))
        {
            throw new TypeError('No name or initialiser found for behaviour');
        }
        if (oRegisteredBehaviours[oBehaviour.name] !== undefined)
        {
            throw new TypeError(`Duplicate behaviour ‘${oBehaviour.name}’`);
        }
        oRegisteredBehaviours[oBehaviour.name] = oBehaviour;
        console.group(`Registered behaviour ‘${oBehaviour.name}’`);
        console.debug('Defaults:',  oBehaviour.defaults);
        console.debug('Namespace:', oBehaviour.namespace);
        console.groupEnd();
    });
    (bAutoBind && bindBehaviours());
    return true;
}
function registerBehaviours ( aoBehaviour , bAutoBind = true ) { aoBehaviour . forEach ( function ( oBehaviour ) { oBehaviour = Object . assign ( { defaults : { } , namespace : '' , } , oBehaviour ) ; if ( ( oBehaviour . name === undefined ) || ( oBehaviour . init === undefined ) ) { throw new TypeError ( 'No name or initialiser found for behaviour' ) ; } if ( oRegisteredBehaviours [ oBehaviour . name ] !== undefined ) { throw new TypeError ( ` oB ehaviour.n a me}’ ` } oRegisteredBehaviours [ oBehaviour . name ] = oBehaviour ; console . group ( ` oB ehaviour.n a me}’ ` console . debug ( 'Defaults:' , oBehaviour . defaults ) ; console . debug ( 'Namespace:' , oBehaviour . namespace ) ; console . groupEnd ( ) ; } ) ; ( bAutoBind && bindBehaviours ( ) ) ; return true ; }
Registers an array of behaviours, optionally with autobinding.
Registers an array of behaviours optionally with autobinding .
// 1. iterate through behaviours // a. default things out // b. if we don’t have a name or init // c. if we already know about that behaviour // d. register it // 2. if we’re autobinding, do so