setup-dotnet/node_modules/xmlbuilder/lib/Utility.js

89 lines
2.3 KiB
JavaScript
Raw Normal View History

2019-09-10 00:27:23 +07:00
// Generated by CoffeeScript 2.4.1
(function() {
// Copies all enumerable own properties from `sources` to `target`
var assign, getValue, isArray, isEmpty, isFunction, isObject, isPlainObject,
hasProp = {}.hasOwnProperty;
assign = function(target, ...sources) {
var i, key, len, source;
if (isFunction(Object.assign)) {
Object.assign.apply(null, arguments);
} else {
for (i = 0, len = sources.length; i < len; i++) {
source = sources[i];
if (source != null) {
for (key in source) {
if (!hasProp.call(source, key)) continue;
target[key] = source[key];
}
}
}
}
return target;
};
// Determines if `val` is a Function object
isFunction = function(val) {
return !!val && Object.prototype.toString.call(val) === '[object Function]';
};
// Determines if `val` is an Object
isObject = function(val) {
var ref;
return !!val && ((ref = typeof val) === 'function' || ref === 'object');
};
// Determines if `val` is an Array
isArray = function(val) {
if (isFunction(Array.isArray)) {
return Array.isArray(val);
} else {
return Object.prototype.toString.call(val) === '[object Array]';
}
};
// Determines if `val` is an empty Array or an Object with no own properties
isEmpty = function(val) {
var key;
if (isArray(val)) {
return !val.length;
} else {
for (key in val) {
if (!hasProp.call(val, key)) continue;
return false;
}
return true;
}
};
// Determines if `val` is a plain Object
isPlainObject = function(val) {
var ctor, proto;
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));
};
// Gets the primitive value of an object
getValue = function(obj) {
if (isFunction(obj.valueOf)) {
return obj.valueOf();
} else {
return obj;
}
};
module.exports.assign = assign;
module.exports.isFunction = isFunction;
module.exports.isObject = isObject;
module.exports.isArray = isArray;
module.exports.isEmpty = isEmpty;
module.exports.isPlainObject = isPlainObject;
module.exports.getValue = getValue;
}).call(this);