soot-shared
Version:
68 lines (66 loc) • 1.68 kB
JavaScript
var NO_OP = "$NO_OP";
var ERROR_MSG = "Error";
var isArray = Array.isArray;
function isStatefulComponent(o) {
return !isUndefined(o.prototype) && !isUndefined(o.prototype.render);
}
function isStringOrNumber(o) {
var type = typeof o;
return type === "string" || type === "number";
}
function isNullOrUndef(o) {
return isUndefined(o) || isNull(o);
}
function isInvalid(o) {
return isNull(o) || o === false || isTrue(o) || isUndefined(o);
}
function isFunction(o) {
return typeof o === "function";
}
function isString(o) {
return typeof o === "string";
}
function isNumber(o) {
return typeof o === "number";
}
function isNull(o) {
return o === null;
}
function isTrue(o) {
return o === true;
}
function isUndefined(o) {
return o === void 0;
}
function isObject(o) {
return typeof o === "object";
}
/**
* Throws error
* @param {string?} message
*/
function throwError(message) {
if (!message) {
message = ERROR_MSG;
}
throw new Error("Soot Error: " + message);
}
function warning(message) {
// tslint:disable-next-line:no-console
console.warn(message);
}
function combineFrom(first, second) {
var out = {};
if (first) {
for (var key in first) {
out[key] = first[key];
}
}
if (second) {
for (var key in second) {
out[key] = second[key];
}
}
return out;
}
export { NO_OP, ERROR_MSG, isArray, isStatefulComponent, isStringOrNumber, isNullOrUndef, isInvalid, isFunction, isString, isNumber, isNull, isTrue, isUndefined, isObject, throwError, warning, combineFrom };