0.9.1 • Published 4 years ago

concat-define v0.9.1

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
4 years ago

concat-define

concat-define provides an implementation of AMD's define function that concatenates modules into a single module that can be loaded using AMD or directly into the global context.

Usage

internal.js

define(function () {

    function Internal() {

        this.hello = function() {

            return "Hello world.";
        };
    }

    return Internal;
});

public.js

define(["./internal"], function Public(Internal) {

    return {

        public : new Internal().hello()
    }
});

The two modules above combine to give the following output:

(function(factory) {

 	if (typeof define === "function" && define.amd) {

 		define([], factory);
 	} else if (typeof module === "object" && module.exports) {

 		module.exports = factory();
 	} else {

 		factory(this);
 	}
 })(function(context) {

    context = context || {};

    var internal = (function () {

        function Internal() {

            this.hello = function() {

                return "Hello world.";
            };
        }

        return Internal;
    })();

    context.Public = (function (Internal) {

        return {

            public : new Internal().hello()
        }
    })(internal);

    return context;
});
0.9.1

4 years ago

0.9.0

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

6 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago