(function (global, factory) {
    if (typeof define === "function" && define.amd) {
        define(["module"], factory);
    } else if (typeof exports !== "undefined") {
        factory(module);
    } else {
        var mod = {
            exports: {}
        };
        factory(mod);
        global.Jimple = mod.exports;
    }
})(this, function (module) {
    "use strict";

    function _classCallCheck(instance, Constructor) {
        if (!(instance instanceof Constructor)) {
            throw new TypeError("Cannot call a class as a function");
        }
    }

    var _createClass = function () {
        function defineProperties(target, props) {
            for (var i = 0; i < props.length; i++) {
                var descriptor = props[i];
                descriptor.enumerable = descriptor.enumerable || false;
                descriptor.configurable = true;
                if ("value" in descriptor) descriptor.writable = true;
                Object.defineProperty(target, descriptor.key, descriptor);
            }
        }

        return function (Constructor, protoProps, staticProps) {
            if (protoProps) defineProperties(Constructor.prototype, protoProps);
            if (staticProps) defineProperties(Constructor, staticProps);
            return Constructor;
        };
    }();

    function isFunction(fn) {
        return Object.prototype.toString.call(fn) === "[object Function]";
    }
    function isPlainObject(value) {
        if (Object.prototype.toString.call(value) !== '[object Object]') {
            return false;
        } else {
            var prototype = Object.getPrototypeOf(value);
            return prototype === null || prototype === Object.prototype;
        }
    }
    function checkDefined(container, key) {
        if (!container.has(key)) {
            throw new Error("Identifier '" + key + "' is not defined.");
        }
    }

    var Jimple = function () {
        function Jimple(values) {
            _classCallCheck(this, Jimple);

            this.items = {};
            this.instances = new Map();
            this.factories = new Set();
            this.protected = new Set();
            values = isPlainObject(values) ? values : {};
            Object.keys(values).forEach(function (key) {
                this.set(key, values[key]);
            }, this);
        }

        _createClass(Jimple, [{
            key: "get",
            value: function get(key) {
                checkDefined(this, key);
                var item = this.items[key];
                var obj = undefined;
                if (isFunction(item)) {
                    if (this.protected.has(item)) {
                        obj = item;
                    } else if (this.instances.has(item)) {
                        obj = this.instances.get(item);
                    } else {
                        obj = item(this);
                        if (!this.factories.has(item)) {
                            this.instances.set(item, obj);
                        }
                    }
                } else {
                    obj = item;
                }
                return obj;
            }
        }, {
            key: "set",
            value: function set(key, val) {
                this.items[key] = val;
            }
        }, {
            key: "has",
            value: function has(key) {
                return this.items.hasOwnProperty(key);
            }
        }, {
            key: "factory",
            value: function factory(fn) {
                if (!isFunction(fn)) {
                    throw new Error("Service definition is not a Closure or invokable object");
                }
                this.factories.add(fn);
                return fn;
            }
        }, {
            key: "protect",
            value: function protect(fn) {
                if (!isFunction(fn)) {
                    throw new Error("Callable is not a Closure or invokable object");
                }
                this.protected.add(fn);
                return fn;
            }
        }, {
            key: "keys",
            value: function keys() {
                return Object.keys(this.items);
            }
        }, {
            key: "extend",
            value: function extend(key, fn) {
                checkDefined(this, key);
                var originalItem = this.items[key];
                if (!isFunction(originalItem)) {
                    throw new Error("Identifier '" + key + "' does not contain an object definition");
                }
                if (!isFunction(fn)) {
                    throw new Error("The 'new' service definition for '" + key + "' is not a invokable object.");
                }
                this.items[key] = function (app) {
                    return fn(originalItem(app), app);
                };
                if (this.factories.has(originalItem)) {
                    this.factories.delete(originalItem);
                    this.factories.add(this.items[key]);
                }
            }
        }, {
            key: "register",
            value: function register(provider) {
                provider.register(this);
            }
        }, {
            key: "raw",
            value: function raw(key) {
                checkDefined(this, key);
                return this.items[key];
            }
        }]);

        return Jimple;
    }();

    module.exports = Jimple;
});
@@ -1878,32 +1878,245 @@
 %0A        %7D%0A    %7D
+%0A    function addFunctionTo(set, fn) %7B%0A        if (!isFunction(fn)) %7B%0A            throw new Error(%22Service definition is not a Closure or invokable object%22);%0A        %7D%0A        set.add(fn);%0A        return fn;%0A    %7D
 %0A%0A    var Jimple
@@ -3745,210 +3745,48 @@
     
-if (!isFunction(fn)) %7B%0A                    throw new Error(%22Service definition is not a Closure or invokable object%22);%0A                %7D%0A                this.factories.add(fn);%0A                return
+return addFunctionTo(this.factories,
  fn
+)
 ;%0A  
@@ -3900,200 +3900,48 @@
     
-if (!isFunction(fn)) %7B%0A                    throw new Error(%22Callable is not a Closure or invokable object%22);%0A                %7D%0A                this.protected.add(fn);%0A                return fn
+return addFunctionTo(this.protected, fn)
 ;%0A  

Build for browsers