UMD

A standard for Node Module such that the package will work with both browser (AMD (Asynchronous Module Definition) ) and node.js (CommonJS (CJS) )

The pattern goes as follows:

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD
        define(['exports'], factory);
    } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
        // CommonJS
        factory(exports);
    } else {
        // Browser global
        root.myModule = {};
        factory(root.myModule);
    }
}(typeof self !== 'undefined' ? self : this, function (exports) {
    // Module code here

    // Function to add two numbers
    function add(a, b) {
        return a + b;
    }

    // Export the add function
    exports.add = add;
}));

the pattern use an immediate invoke function expression (IIFE) with if statement to define which type of environment it's dealing with.