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AK,KACE,MAGN,OAAO,SACR,OAAO,OAAS,SAAU,GACtB,IAAI,EAAK,WAAa,EAItB,OAFA,EAAG,UAAY,EAER,IAAI,CACf,GAGG,OAAO,OAAQ,KAAS,MACnC,EASA,IAAK,SAAU,GACX,GAAK,GAAa,KAAK,KAIvB,OAAO,KAAK,sBAAsB,EACtC,EASA,QAAS,WACL,OAAO,KAAK,eAAe,KAAK,KAAM,KAAM,CAAC,YACjD,EAUA,KAAM,SAAU,GACZ,SAAK,IAAa,KAAK,YAOR,IAFL,KAAK,sBAAsB,EAGzC,EASA,WAAY,WACR,OAAO,KAAK,eAAe,KAAK,KAAM,CAAC,YAC3C,EAYA,IAAK,SAAU,EAAU,GACrB,GAAK,GAAa,KAAK,KAAvB,CASA,IAHA,IAAI,EAAa,EAAS,MAAM,KAC5B,EAAU,KAAK,KAEV,EAAI,EAAG,EAAI,EAAW,OAAS,EAAG,IAIlC,EAAQ,eAAe,EAAW,MACnC,EAAQ,EAAW,IAAM,CAAC,GAG9B,EAAU,EAAQ,EAAW,IAGjC,EAAQ,EAAW,IAAM,CAlBzB,CAmBJ,EASA,KAAM,WACF,OAAO,KAAK,KAChB,EAER,EAKkB,oBAAX,aAAoD,IAAnB,OAAO,QAC/C,OAAO,QAAU,EAEjB,OAAO,WAAa,CAE3B,CAlRD","file":"/npm/reflectionjs@1.0.0/lib/reflection.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/reflectionjs@1.0.0/lib/reflection.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\r\n * @author       Pablo Oliveira <pablo.oliveira@outlook.com.br>\r\n * @copyright    2015 Pablo Oliveira\r\n * @license      {@link https://github.com/poliveira/reflection-js/blob/master/LICENSE|MIT License}\r\n */\r\n\r\n/**\r\n * @class reflection\r\n */\r\n(function () {\r\n    \"use strict\";\r\n\r\n    var reflection = (function () {\r\n        var reflection = function (obj) {\r\n\r\n            return {\r\n\r\n                /**\r\n                 * Reference to the object\r\n                 *\r\n                 * @property _obj\r\n                 * @memberof reflection\r\n                 * @private\r\n                 */\r\n                _obj: obj,\r\n\r\n                /**\r\n                 * Returns a reference for the given property name\r\n                 *\r\n                 * @method _getPropertyReference\r\n                 * @memberof reflection\r\n                 * @param {string} property - The property name\r\n                 * @private\r\n                 */\r\n                _getPropertyReference: function (property) {\r\n                    var namespaces = property.split(\".\");\r\n                    var context = this._obj;\r\n\r\n                    for (var i = 0; i < namespaces.length - 1; i++) {\r\n                        if (!context.hasOwnProperty(namespaces[i])) {\r\n                            return;\r\n                        }\r\n\r\n                        context = context[namespaces[i]];\r\n                    }\r\n\r\n                    return context[namespaces[i]];\r\n                },\r\n\r\n                /**\r\n                 * Returns an array of all object properties, respecting the filters\r\n                 * provided.\r\n                 *\r\n                 * @method _getProperties\r\n                 * @memberof reflection\r\n                 * @private\r\n                 */\r\n                _getProperties: function (obj, exclude, include) {\r\n                    include = include || [];\r\n                    exclude = exclude || [];\r\n\r\n                    var properties = [];\r\n\r\n                    var skip;\r\n\r\n                    for (var property in obj) {\r\n                        skip = false;\r\n\r\n                        if (!obj.hasOwnProperty(property)) {\r\n                            continue;\r\n                        }\r\n\r\n                        for (var i = 0; i < exclude.length; i++) {\r\n\r\n                            // If this property type is any of the excluded\r\n                            // ones, skip to the next one\r\n                            if (typeof obj[property] === exclude[i]) {\r\n                                skip = true;\r\n                                break;\r\n                            }\r\n                        }\r\n\r\n                        if (skip) {\r\n                            continue;\r\n                        }\r\n\r\n                        if (include.length > 0) {\r\n                            for (var i = 0; i < include.length; i++) {\r\n\r\n                                // Include the property if its type is one\r\n                                // of the included types\r\n                                if (typeof obj[property] === include[i]) {\r\n                                    properties.push(property);\r\n                                }\r\n                            }\r\n                        } else {\r\n                            properties.push(property);\r\n                        }\r\n                    }\r\n\r\n                    return properties;\r\n\r\n                },\r\n\r\n                _type: Object.prototype.toString.call(obj).slice(8, -1),\r\n                \r\n                /**\r\n                 * Runs a function by name.\r\n                 *\r\n                 * @method call\r\n                 * @memberof reflection\r\n                 * @param {string} functionName\r\n                 * @param {Array} [args]\r\n                 */\r\n                call: function (functionName) {\r\n                    if (!functionName || !this.owns(functionName)) {\r\n                        return;\r\n                    }\r\n\r\n                    var args = [].slice.call(arguments).splice(1);\r\n\r\n                    // Creates an array containing all namespace\r\n                    // levels\r\n                    var namespaces = functionName.split(\".\");\r\n\r\n                    // Picks the last name in the namespaces so\r\n                    // it can be called below within the reference\r\n                    // of the current context\r\n                    var fn = namespaces.pop();\r\n\r\n                    // Context is created at the top level\r\n                    // of the current object\r\n                    var context = this._obj;\r\n\r\n                    // Iterates through the namespace array, updateing\r\n                    // the context reference in each iteration. Get out\r\n                    // of the loop one step earlier to keep the reference\r\n                    // to the context\r\n                    for (var i = 0; i < namespaces.length; i++) {\r\n\r\n                        // Set context to the current namespace\r\n                        context = context[namespaces[i]];\r\n                    }\r\n\r\n                    return context[fn].apply(this, args);\r\n                },\r\n\r\n                /**\r\n                 * Clones the object and remove its reference.\r\n                 *\r\n                 * @method clone\r\n                 * @memberof reflection\r\n                 * @return {object} - A clone of the current object\r\n                 */\r\n                clone: function () {\r\n                    if (this._obj === null) {\r\n                        return null;\r\n                    }\r\n                    \r\n                    if (!Object.create) {\r\n                        Object.create = function (obj) {\r\n                            var fn = function () {};\r\n\r\n                            fn.prototype = obj;\r\n\r\n                            return new fn();\r\n                        };\r\n                    }\r\n\r\n                    return Object.create((this._obj));;\r\n                },\r\n\r\n                /**\r\n                 * Gets a reference for a given property name.\r\n                 *\r\n                 * @method get\r\n                 * @memberof reflection\r\n                 * @param {string} property - The property name\r\n                 */\r\n                get: function (property) {\r\n                    if (!property || !this._obj) {\r\n                        return;\r\n                    }\r\n\r\n                    return this._getPropertyReference(property);\r\n                },\r\n\r\n                /**\r\n                 * Returns an Array contaning all the methods names.\r\n                 *\r\n                 * @method methods\r\n                 * @memberof reflection\r\n                 * @return {Array}\r\n                 */\r\n                methods: function () {\r\n                    return this._getProperties(this._obj, null, [\"function\"]);\r\n                },\r\n\r\n                /**\r\n                 * Returns true if the object owns the given property, otherwise false\r\n                 *\r\n                 * @method owns\r\n                 * @memberof reflection\r\n                 * @param {string} property - Property name\r\n                 * @return {boolean}\r\n                 */\r\n                owns: function (property) {\r\n                    if (!property || !this._obj) {\r\n                        return false;\r\n                    }\r\n\r\n                    // Gets a reference for the property\r\n                    var ref = this._getPropertyReference(property);\r\n\r\n                    return ref !== undefined;\r\n                },\r\n\r\n                /**\r\n                 * Returns an Array contaning all the property names.\r\n                 *\r\n                 * @method properties\r\n                 * @memberof reflection\r\n                 * @return {Array}\r\n                 */\r\n                properties: function () {\r\n                    return this._getProperties(this._obj, [\"function\"]);\r\n                },\r\n\r\n                /**\r\n                 * Sets the value of a given property. If the property does not exists, it\r\n                 * will created, even if it is a nested property.\r\n                 *\r\n                 * @method set\r\n                 * @memberof reflection\r\n                 * @param {string} property - Property name\r\n                 * @param {boolean | number | object | string} value - The value to be setted\r\n                 * @return {undefined}\r\n                 */\r\n                set: function (property, value) {\r\n                    if (!property || !this._obj) {\r\n                        return;\r\n                    }\r\n\r\n                    // TODO: should find a way to use the _getPropertyReference method\r\n                    //       and keep a reference to the object\r\n                    var namespaces = property.split(\".\");\r\n                    var context = this._obj;\r\n\r\n                    for (var i = 0; i < namespaces.length - 1; i++) {\r\n\r\n                        // Create the property if the object does not \r\n                        // have it\r\n                        if (!context.hasOwnProperty(namespaces[i])) {\r\n                            context[namespaces[i]] = {};\r\n                        }\r\n\r\n                        context = context[namespaces[i]];\r\n                    }\r\n\r\n                    context[namespaces[i]] = value;\r\n                },\r\n\r\n                /**\r\n                 * Returns a string with the name of the type of the current object.\r\n                 *\r\n                 * @method type\r\n                 * @memberof reflection\r\n                 * @return {string}\r\n                 */\r\n                type: function () {\r\n                    return this._type;\r\n                }\r\n            }\r\n        };\r\n\r\n        return reflection;\r\n    })();\r\n\r\n    if (typeof module !== \"undefined\" && typeof module.exports !== \"undefined\") {\r\n        module.exports = reflection;\r\n    } else {\r\n        window.reflection = reflection;\r\n    }\r\n})();"]}