Code coverage report for ./src/util.js

Statements: 80% (40 / 50)      Branches: 76% (19 / 25)      Functions: 81.25% (13 / 16)      Lines: 80% (40 / 50)      Ignored: none     

All files » ./src\ » util.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 1041 1   1 1 1   1 513     1 634 634                       1 608     1 608     1 1 1       1 2479     1 1415     1 1064     1 679 679 679                   1 57 57 114 114 874       57       1 1 1     1   1       1                              
void function (define, undefined) {
    define(
        function () {
            var nativeIndexOf = Array.prototype.indexOf;
            var slice = Array.prototype.slice;
            var nativeBind = Function.prototype.bind;
 
            function hasOwnProperty(object, key) {
                return Object.prototype.hasOwnProperty.call(object, key);
            }
 
            function indexOf(arr, el) {
                Eif (typeof nativeIndexOf === 'function' && arr.indexOf === nativeIndexOf) {
                    return arr.indexOf(el);
                }
 
                for (var i = 0, len = arr.length; i < len; ++i) {
                    if (arr[i] === el) {
                        return i;
                    }
                }
 
                return -1;
            }
 
            function contains(arr, el) {
                return indexOf(arr, el) > -1;
            }
 
            function addToSet(arr, el) {
                !contains(arr, el) && arr.push(el);
            }
 
            function warn() {
                Eif (typeof console !== 'undefined') {
                    console.warn.apply(console, arguments);
                }
            }
 
            function isObject(obj) {
                return obj !== null && obj !== undefined && Object.prototype.toString.call(obj) === '[object Object]';
            }
 
            function hasReference(obj) {
                return isObject(obj) && typeof obj.$ref === 'string';
            }
 
            function hasImport(obj) {
                return isObject(obj) && typeof obj.$import === 'string';
            }
 
            function bind(fn) {
                var args = slice.call(arguments, 1);
                Eif (typeof fn.bind === 'function' && fn.bind === nativeBind) {
                    return fn.bind.apply(fn, args);
                }
 
                return function () {
                    var scope = args.shift();
                    args.push.apply(args, arguments);
                    fn.apply(scope, args);
                };
            }
 
            function merge() {
                var ret = {};
                for (var i = 0, len = arguments.length; i < len; ++i) {
                    var arg = arguments[i];
                    for (var k in arg) {
                        ret[k] = arg[k];
                    }
                }
 
                return ret;
            }
 
            // 循环依赖错误
            function CircularError(message, component) {
                this.message = message;
                this.component = component;
            }
 
            CircularError.prototype = Error.prototype;
 
            CircularError.prototype.print = function () {
                warn(this.message);
            };
 
            return {
                CircularError: CircularError,
                hasOwn: hasOwnProperty,
                contains: contains,
                addToSet: addToSet,
                merge: merge,
                isObject: isObject,
                bind: bind,
                indexOf: indexOf,
                hasReference: hasReference,
                hasImport: hasImport,
                warn: warn
            };
        });
 
}(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory; });