Code coverage report for ./src/util.js

Statements: 90.24% (37 / 41)      Branches: 73.91% (17 / 23)      Functions: 85.71% (12 / 14)      Lines: 90.24% (37 / 41)      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 861 1   1 1 1   1 378     1 489       489 93 21       468     1 468     1 468     1 1 1       1 1106     1 1106     1 288 288       288 288 288 288         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) {
                Iif (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 bind(fn) {
                var args = slice.call(arguments, 1);
                Iif (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 CircularError(message, component) {
                this.message = message;
                this.component = component;
            }
 
            CircularError.prototype = Error.prototype;
 
            CircularError.prototype.print = function () {
                warn(this.message);
            };
 
            return {
                CircularError: CircularError,
                hasOwnProperty: hasOwnProperty,
                contains: contains,
                addToSet: addToSet,
                isObject: isObject,
                bind: bind,
                indexOf: indexOf,
                hasReference: hasReference,
                warn: warn
            };
        });
 
}(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory; });