• Jump To … +
    loader.js App.js Constructor.js Mediator.js parser.js addChildren.js applyAttribute.js applyBinders.js applyElement.js applyParent.js setBinders.js setRoutes.js utils.js
  • utils.js

  • ¶
    /**
     * Created by guntars on 10/10/2014.
     */
    define(function () {
        function extend(obj) {
            var type = typeof obj;
            if (!(type === 'function' || type === 'object' && !!obj)) {
                return obj;
            }
            var source, prop;
            for (var i = 1, length = arguments.length; i < length; i++) {
                source = arguments[i];
                for (prop in source) {
                    obj[prop] = source[prop];
                }
            }
            return obj;
        };
    
        function fnExtend(protoProps, staticProps) {
            var parent = this;
            var child;
            if (protoProps && protoProps != null &&
                hasOwnProperty.call(protoProps, 'constructor')) {
                child = protoProps.constructor;
            } else {
                child = function () {
                    return parent.apply(this, arguments);
                };
            }
    
            extend(child, parent, staticProps);
    
            var Surrogate = function () {
                this.constructor = child;
            };
            Surrogate.prototype = parent.prototype;
            child.prototype = new Surrogate;
            if (protoProps) {
                extend(child.prototype, protoProps);
            }
    
            child.__super__ = parent.prototype;
            return child;
        };
    
        function isString(obj) {
            return toString.call(obj) === '[object String]';
    
        }
    
        function isObject(obj) {
            return obj === Object(obj);
        }
    
        function isArray(obj) {
            return (Array.isArray) ? Array.isArray(obj) : toString.call(obj) === '[object Array]';
        }
    
    
        return {
            fnExtend: fnExtend,
  • ¶

    Extend a given object with all the properties in passed-in object(s).

            extend:   extend,
  • ¶

    Check if it’s String

            isString: isString,
  • ¶

    Check if I’t Object

            isObject: isObject,
  • ¶

    Check if it’s Array

            isArray:  isArray
        };
    });