Permalink
Browse files

Function name confict, switch `typeof` back to `is`

  • Loading branch information...
1 parent 2bbb3c8 commit e760b683202dda7703cee229e5241f1d0a10180f @ben-lin ben-lin committed Oct 8, 2012
Showing with 32 additions and 32 deletions.
  1. +5 −5 lib/cli/migrate/lib.js
  2. +1 −1 lib/controller/filter.js
  3. +5 −5 lib/logger.js
  4. +21 −21 lib/utils/index.js
View
@@ -31,15 +31,15 @@ process.on( 'message', function ( msg ){
},
series : function ( action ){
- if( this.utils.typeof( action ) !== 'function' ){
+ if( this.utils.is( action ) !== 'function' ){
return this.exit();
}
this.flow.series( action );
},
parallel : function ( action ){
- if( this.utils.typeof( action ) !== 'function' ){
+ if( this.utils.is( action ) !== 'function' ){
return this.exit();
}
@@ -69,7 +69,7 @@ process.on( 'message', function ( msg ){
self.flow.end( function ( args ){
var db = self.utils.db();
- if( self.utils.typeof( action ) !== 'function' ){
+ if( self.utils.is( action ) !== 'function' ){
return self.reset( db );
}
@@ -108,7 +108,7 @@ process.on( 'message', function ( msg ){
self.flow.end( function ( args ){
var db = self.utils.db();
- if( self.utils.typeof( action ) !== 'function' ){
+ if( self.utils.is( action ) !== 'function' ){
return self.reset( db );
}
@@ -146,7 +146,7 @@ process.on( 'message', function ( msg ){
var end = function ( action ){
var db = self.utils.db();
- if( self.utils.typeof( action ) !== 'function' ){
+ if( self.utils.is( action ) !== 'function' ){
return self.reset( db, function (){
flow.end();
});
View
@@ -60,7 +60,7 @@ var Filter = Class.extend({
* @param {Object} options Filter options.
*/
_filter : function ( type, handler, options ){
- UTILS.typeof( handler ) !== 'function' &&
+ UTILS.is( handler ) !== 'function' &&
LOG.error( 500,
'[route][filter][' + type + ']',
'handler must be a function.' );
View
@@ -95,11 +95,11 @@ if( NODE_ENV === 'dev' ){
if( !msg ){
_msg = '';
}else{
- _msg = UTILS.typeof( msg ) === 'error' ?
+ _msg = UTILS.is( msg ) === 'error' ?
msg : json( msg, null, 2 );
}
- var detail = UTILS.typeof( res ) === 'string' ?
+ var detail = UTILS.is( res ) === 'string' ?
( $title( '- id: ' ) +
$desc( res ) + '\n' ) :
( $title( '- id: ' ) +
@@ -132,7 +132,7 @@ if( NODE_ENV === 'dev' ){
debug = config.debug ? function ( res, msg, obj ){
var detail;
- if( UTILS.typeof( res ) === 'string' ){
+ if( UTILS.is( res ) === 'string' ){
detail = '';
obj = msg;
msg = res;
@@ -225,7 +225,7 @@ if( NODE_ENV === 'dev' ){
msg : json( msg, null, 2 );
}
- var detail = UTILS.typeof( res ) === 'string' ?
+ var detail = UTILS.is( res ) === 'string' ?
( '\n- id: ' + res ) :
( '\n- id: ' + res._id +
'\n- time: ' + ( Date.now() - res._start ) + 'ms' +
@@ -248,7 +248,7 @@ if( NODE_ENV === 'dev' ){
debug = config.debug ? function ( res, msg, obj ){
var detail;
- if( UTILS.typeof( res ) === 'string' ){
+ if( UTILS.is( res ) === 'string' ){
detail = '';
obj = msg;
msg = res;
View
@@ -55,6 +55,27 @@ var utils = {
db : require( './db' ),
/**
+ * Use this instead of the untrusted typeof.
+ * @public
+ * @this {utils}
+ * @param {Object} obj The target object.
+ * @returns {String} Returns the capitalized type name.
+ * @example
+ *
+ * var type = UTILS.is( 'i\'m a string' );
+ */
+ is : function ( obj ){
+ if( obj === null ) return 'null';
+ if( obj === undefined ) return 'undefined';
+
+ var ret = {}.toString.call( obj ).match( /^\[object\s+(.*?)\]$/ )[ 1 ];
+
+ ret = ret ? ret.toLowerCase() : '';
+
+ return ret == 'number' && isNaN( obj ) ? 'NaN' : ret;
+ },
+
+/**
* Shows the client ip address.
* @public
* @this {utils}
@@ -117,27 +138,6 @@ var utils = {
},
/**
- * Use this instead of the untrusted typeof.
- * @public
- * @this {utils}
- * @param {Object} obj The target object.
- * @returns {String} Returns the capitalized type name.
- * @example
- *
- * var type = UTILS.typeof( 'i\'m a string' );
- */
- typeof : function ( obj ){
- if( obj === null ) return 'null';
- if( obj === undefined ) return 'undefined';
-
- var ret = {}.toString.call( obj ).match( /^\[object\s+(.*?)\]$/ )[ 1 ];
-
- ret = ret ? ret.toLowerCase() : '';
-
- return ret == 'number' && isNaN( obj ) ? 'NaN' : ret;
- },
-
-/**
* Generate a unic ID string.
* @public
* @this {utils}

0 comments on commit e760b68

Please sign in to comment.