Utility.js
1 // Generated by CoffeeScript 1.12.7 2 (function() { 3 var assign, isArray, isEmpty, isFunction, isObject, isPlainObject, 4 slice = [].slice, 5 hasProp = {}.hasOwnProperty; 6 7 assign = function() { 8 var i, key, len, source, sources, target; 9 target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : []; 10 if (isFunction(Object.assign)) { 11 Object.assign.apply(null, arguments); 12 } else { 13 for (i = 0, len = sources.length; i < len; i++) { 14 source = sources[i]; 15 if (source != null) { 16 for (key in source) { 17 if (!hasProp.call(source, key)) continue; 18 target[key] = source[key]; 19 } 20 } 21 } 22 } 23 return target; 24 }; 25 26 isFunction = function(val) { 27 return !!val && Object.prototype.toString.call(val) === '[object Function]'; 28 }; 29 30 isObject = function(val) { 31 var ref; 32 return !!val && ((ref = typeof val) === 'function' || ref === 'object'); 33 }; 34 35 isArray = function(val) { 36 if (isFunction(Array.isArray)) { 37 return Array.isArray(val); 38 } else { 39 return Object.prototype.toString.call(val) === '[object Array]'; 40 } 41 }; 42 43 isEmpty = function(val) { 44 var key; 45 if (isArray(val)) { 46 return !val.length; 47 } else { 48 for (key in val) { 49 if (!hasProp.call(val, key)) continue; 50 return false; 51 } 52 return true; 53 } 54 }; 55 56 isPlainObject = function(val) { 57 var ctor, proto; 58 return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object)); 59 }; 60 61 module.exports.assign = assign; 62 63 module.exports.isFunction = isFunction; 64 65 module.exports.isObject = isObject; 66 67 module.exports.isArray = isArray; 68 69 module.exports.isEmpty = isEmpty; 70 71 module.exports.isPlainObject = isPlainObject; 72 73 }).call(this);