Export the type checking functions from util.js
.
As per discussion at: http://groups.google.com/group/nodejs-dev/browse_thread/thread/b08970166e4670cf
This commit is contained in:
parent
b3ddb895d2
commit
b8f3e18a5d
@ -383,24 +383,28 @@ function isArray(ar) {
|
|||||||
Array.isArray(ar) ||
|
Array.isArray(ar) ||
|
||||||
(ar && ar !== Object.prototype && isArray(ar.__proto__));
|
(ar && ar !== Object.prototype && isArray(ar.__proto__));
|
||||||
}
|
}
|
||||||
|
exports.isArray = isArray;
|
||||||
|
|
||||||
|
|
||||||
function isRegExp(re) {
|
function isRegExp(re) {
|
||||||
return re instanceof RegExp ||
|
return re instanceof RegExp ||
|
||||||
(typeof re === 'object' && objectToString(re) === '[object RegExp]');
|
(typeof re === 'object' && objectToString(re) === '[object RegExp]');
|
||||||
}
|
}
|
||||||
|
exports.isRegExp = isRegExp;
|
||||||
|
|
||||||
|
|
||||||
function isDate(d) {
|
function isDate(d) {
|
||||||
return d instanceof Date ||
|
return d instanceof Date ||
|
||||||
(typeof d === 'object' && objectToString(d) === '[object Date]');
|
(typeof d === 'object' && objectToString(d) === '[object Date]');
|
||||||
}
|
}
|
||||||
|
exports.isDate = isDate;
|
||||||
|
|
||||||
|
|
||||||
function isError(e) {
|
function isError(e) {
|
||||||
return e instanceof Error ||
|
return e instanceof Error ||
|
||||||
(typeof e === 'object' && objectToString(e) === '[object Error]');
|
(typeof e === 'object' && objectToString(e) === '[object Error]');
|
||||||
}
|
}
|
||||||
|
exports.isError = isError;
|
||||||
|
|
||||||
|
|
||||||
function objectToString(o) {
|
function objectToString(o) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user