mhulse / js-patterns

Some of my favorite JavaScript plugin design patterns: The Facade Pattern, The Revealing Module Pattern, Immediately-invoked Function Expressions (IIFE)s, The Module Pattern imports and exports …
3 stars 1 forks source link

'nother … AMD/Node/CommonJS/Browser boilerplate pattern #7

Open mhulse opened 7 years ago

mhulse commented 7 years ago
(function( factory ){
    if ( typeof define === 'function' && define.amd ) {
        // AMD
        define( ['jquery', 'datatables', 'datatables-editor'], factory );
    }
    else if ( typeof exports === 'object' ) {
        // Node / CommonJS
        module.exports = function ($, dt) {
            if ( ! $ ) { $ = require('jquery'); }
            factory( $, dt || $.fn.dataTable || require('datatables') );
        };
    }
    else if ( jQuery ) {
        // Browser standard
        factory( jQuery, jQuery.fn.dataTable );
    }
}(function( $, DataTable ) {
'use strict';

var

    create: function ( conf ) {
    },

    get: function ( conf ) {

    },

    set: function ( conf, val ) {
    },

    enable: function ( conf ) {
    },

    disable: function ( conf ) {
    },

    inst: function ( conf ) {
    },
    update: function ( conf, data ) {
    },

    focus: function ( conf ) {
    }
};

}));