query-engine
Version:
Query-Engine is a NoSQL and MongoDb compliant query engine. It can run on the server-side with Node.js, or on the client-side within web browsers
100 lines (92 loc) • 2.8 kB
JavaScript
// Generated by CoffeeScript 1.6.2
/*
NOTES:
Instanceof is often broken and doesn't return the right value
For instance it does not work in node virtual machines
*/
(function() {
var balUtilTypes,
__hasProp = {}.hasOwnProperty;
balUtilTypes = {
toString: function(value) {
return Object.prototype.toString.call(value);
},
getType: function(value) {
var result, type, _i, _len, _ref;
result = 'object';
_ref = ['Array', 'RegExp', 'Date', 'Function', 'Boolean', 'Number', 'Error', 'String', 'Null', 'Undefined'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
type = _ref[_i];
if (balUtilTypes['is' + type](value)) {
result = type.toLowerCase();
break;
}
}
return result;
},
isPlainObject: function(value) {
return balUtilTypes.isObject(value) && value.__proto__ === Object.prototype;
},
isObject: function(value) {
return value && typeof value === 'object';
},
isError: function(value) {
return value instanceof Error;
},
isDate: function(value) {
return balUtilTypes.toString(value) === '[object Date]';
},
isArguments: function(value) {
return balUtilTypes.toString(value) === '[object Arguments]';
},
isFunction: function(value) {
return balUtilTypes.toString(value) === '[object Function]';
},
isRegExp: function(value) {
return balUtilTypes.toString(value) === '[object RegExp]';
},
isArray: function(value) {
if (Array.isArray != null) {
return Array.isArray(value);
} else {
return balUtilTypes.toString(value) === '[object Array]';
}
},
isNumber: function(value) {
return typeof value === 'number' || balUtilTypes.toString(value) === '[object Number]';
},
isString: function(value) {
return typeof value === 'string' || balUtilTypes.toString(value) === '[object String]';
},
isBoolean: function(value) {
return value === true || value === false || balUtilTypes.toString(value) === '[object Boolean]';
},
isNull: function(value) {
return value === null;
},
isUndefined: function(value) {
return typeof value === 'undefined';
},
isEmpty: function(value) {
return value != null;
},
isEmptyObject: function(value) {
var empty, key;
empty = true;
if (value != null) {
for (key in value) {
if (!__hasProp.call(value, key)) continue;
value = value[key];
empty = false;
break;
}
}
return empty;
}
};
if (typeof module !== "undefined" && module !== null) {
module.exports = balUtilTypes;
} else {
this.balUtilTypes = balUtilTypes;
}
}).call(this);