src/core.js
function baron(user) {
    var withParams = !!user
    var tryNode = (user && user[0]) || user
    var isNode = typeof user == 'string' || tryNode instanceof HTMLElement
    var params = isNode ? { root: user } : clone(user)
    var jQueryMode
    var rootNode
    var defaultParams = {
        direction: 'v',
        barOnCls: '_scrollbar',
        resizeDebounce: 0,
        event: event,
        cssGuru: false,
        impact: 'scroller',
        position: 'static'
    }

    params = params || {}

    // Extending default params by user-defined params
    for (var key in defaultParams) {
        if (params[key] == null) { // eslint-disable-line
            params[key] = defaultParams[key]
        }
    }

    if (process.env.NODE_ENV !== 'production') {
        if (params.position == 'absolute' && params.impact == 'clipper') {
            log('error', [
                'Simultaneous use of `absolute` position and `clipper` impact values detected.',
                'Those values cannot be used together.',
                'See more https://github.com/Diokuz/baron/issues/138'
            ].join(' '), params)
        }
    }

    // `this` could be a jQuery instance
    jQueryMode = this && this instanceof scopedWindow.jQuery

    if (params._chain) {
        rootNode = params.root
    } else if (jQueryMode) {
        params.root = rootNode = this[0]
    } else {
        rootNode = qs(params.root || params.scroller)
    }

    if (process.env.NODE_ENV !== 'production') {
        if (!rootNode) {
            log('error', [
                'Baron initialization failed: root node not found.'
            ].join(', '), params)

            return // or return baron-shell?
        }
    }

    var attr = manageAttr(rootNode, params.direction)
    var id = +attr // Could be NaN

    params.index = id

    // baron() can return existing instances,
    // @TODO update params on-the-fly
    // https://github.com/Diokuz/baron/issues/124
    if (id == id && attr !== null && instances[id]) {
        if (process.env.NODE_ENV !== 'production') {
            if (withParams) {
                log('error', [
                    'repeated initialization for html-node detected',
                    'https://github.com/Diokuz/baron/blob/master/docs/logs/repeated.md'
                ].join(', '), params.root)
            }
        }

        return instances[id]
    }

    // root and scroller can be different nodes
    if (params.root && params.scroller) {
        params.scroller = qs(params.scroller, rootNode)
        if (process.env.NODE_ENV !== 'production') {
            if (!params.scroller) {
                log('error', 'Scroller not found!', rootNode, params.scroller)
            }
        }
    } else {
        params.scroller = rootNode
    }

    params.root = rootNode

    var instance = init(params)

    if (instance.autoUpdate) {
        instance.autoUpdate()
    }

    return instance
}
function baron(user) {
    var withParams = !!user
    var tryNode = (user && user[0]) || user
    var isNode = typeof user == 'string' || tryNode instanceof HTMLElement
    var params = isNode ? { root: user } : clone(user)
    var jQueryMode
    var rootNode
    var defaultParams = {
        direction: 'v',
        barOnCls: '_scrollbar',
        resizeDebounce: 0,
        event: event,
        cssGuru: false,
        impact: 'scroller',
        position: 'static'
    }

    params = params || {}

    // Extending default params by user-defined params
    for (var key in defaultParams) {
        if (params[key] == null) { // eslint-disable-line
            params[key] = defaultParams[key]
        }
    }

    if (process.env.NODE_ENV !== 'production') {
        if (params.position == 'absolute' && params.impact == 'clipper') {
            log('error', [
                'Simultaneous use of `absolute` position and `clipper` impact values detected.',
                'Those values cannot be used together.',
                'See more https://github.com/Diokuz/baron/issues/138'
            ].join(' '), params)
        }
    }

    // `this` could be a jQuery instance
    jQueryMode = this && this instanceof scopedWindow.jQuery

    if (params._chain) {
        rootNode = params.root
    } else if (jQueryMode) {
        params.root = rootNode = this[0]
    } else {
        rootNode = qs(params.root || params.scroller)
    }

    if (process.env.NODE_ENV !== 'production') {
        if (!rootNode) {
            log('error', [
                'Baron initialization failed: root node not found.'
            ].join(', '), params)

            return // or return baron-shell?
        }
    }

    var attr = manageAttr(rootNode, params.direction)
    var id = +attr // Could be NaN

    params.index = id

    // baron() can return existing instances,
    // @TODO update params on-the-fly
    // https://github.com/Diokuz/baron/issues/124
    if (id == id && attr !== null && instances[id]) {
        if (process.env.NODE_ENV !== 'production') {
            if (withParams) {
                log('error', [
                    'repeated initialization for html-node detected',
                    'https://github.com/Diokuz/baron/blob/master/docs/logs/repeated.md'
                ].join(', '), params.root)
            }
        }

        return instances[id]
    }

    // root and scroller can be different nodes
    if (params.root && params.scroller) {
        params.scroller = qs(params.scroller, rootNode)
        if (process.env.NODE_ENV !== 'production') {
            if (!params.scroller) {
                log('error', 'Scroller not found!', rootNode, params.scroller)
            }
        }
    } else {
        params.scroller = rootNode
    }

    params.root = rootNode

    var instance = init(params)

    if (instance.autoUpdate) {
        instance.autoUpdate()
    }

    return instance
}
function baron ( user ) { var withParams = ! ! user var tryNode = ( user && user [ 0 ] ) || user var isNode = typeof user == 'string' || tryNode instanceof HTMLElement var params = isNode ? { root : user } : clone ( user ) var jQueryMode var rootNode var defaultParams = { direction : 'v' , barOnCls : '_scrollbar' , resizeDebounce : 0 , event : event , cssGuru : false , impact : 'scroller' , position : 'static' } params = params || { } // Extending default params by user-defined params for ( var key in defaultParams ) { if ( params [ key ] == null ) { // eslint-disable-line params [ key ] = defaultParams [ key ] } } if ( process . env . NODE_ENV !== 'production' ) { if ( params . position == 'absolute' && params . impact == 'clipper' ) { log ( 'error' , [ 'Simultaneous use of `absolute` position and `clipper` impact values detected.' , 'Those values cannot be used together.' , 'See more https://github.com/Diokuz/baron/issues/138' ] . join ( ' ' ) , params ) } } // `this` could be a jQuery instance jQueryMode = this && this instanceof scopedWindow . jQuery if ( params . _chain ) { rootNode = params . root } else if ( jQueryMode ) { params . root = rootNode = this [ 0 ] } else { rootNode = qs ( params . root || params . scroller ) } if ( process . env . NODE_ENV !== 'production' ) { if ( ! rootNode ) { log ( 'error' , [ 'Baron initialization failed: root node not found.' ] . join ( ', ' ) , params ) return // or return baron-shell? } } var attr = manageAttr ( rootNode , params . direction ) var id = + attr // Could be NaN params . index = id // baron() can return existing instances, // @TODO update params on-the-fly // https://github.com/Diokuz/baron/issues/124 if ( id == id && attr !== null && instances [ id ] ) { if ( process . env . NODE_ENV !== 'production' ) { if ( withParams ) { log ( 'error' , [ 'repeated initialization for html-node detected' , 'https://github.com/Diokuz/baron/blob/master/docs/logs/repeated.md' ] . join ( ', ' ) , params . root ) } } return instances [ id ] } // root and scroller can be different nodes if ( params . root && params . scroller ) { params . scroller = qs ( params . scroller , rootNode ) if ( process . env . NODE_ENV !== 'production' ) { if ( ! params . scroller ) { log ( 'error' , 'Scroller not found!' , rootNode , params . scroller ) } } } else { params . scroller = rootNode } params . root = rootNode var instance = init ( params ) if ( instance . autoUpdate ) { instance . autoUpdate ( ) } return instance }
window.baron and jQuery.fn.baron points to this function
window . baron and jQuery . fn . baron points to this function