@@ -54,6 +54,7 @@ const regexpUID = /^\d{14,}[a-z]{3}[01]{1}$/;
5454const regexpZIP = / ^ \d { 5 } (?: [ - \s ] \d { 4 } ) ? $ / ;
5555const regexpXML = / \w + \= \" .* ?\" / g;
5656const regexpDECODE = / & g t ; | \& l t ; | \& q u o t ; | & a p o s ; | & a m p ; / g;
57+ const regexpPARAM = / \{ { 2 } [ ^ } \n ] * \} { 2 } / g;
5758const SOUNDEX = { a : '' , e : '' , i : '' , o : '' , u : '' , b : 1 , f : 1 , p : 1 , v : 1 , c : 2 , g : 2 , j : 2 , k : 2 , q : 2 , s : 2 , x : 2 , z : 2 , d : 3 , t : 3 , l : 4 , m : 5 , n : 5 , r : 6 } ;
5859const ENCODING = 'utf8' ;
5960const NEWLINE = '\r\n' ;
@@ -1168,7 +1169,7 @@ exports.httpStatus = function(code, addCode) {
11681169 */
11691170exports . extend = function ( target , source , rewrite ) {
11701171
1171- if ( target === null || source === null )
1172+ if ( ! target || ! source )
11721173 return target ;
11731174
11741175 if ( typeof ( target ) !== 'object' || typeof ( source ) !== 'object' )
@@ -1318,7 +1319,7 @@ exports.reduce = function(source, prop, reverse) {
13181319 */
13191320exports . assign = function ( obj , path , fn ) {
13201321
1321- if ( obj === null || obj === undefined )
1322+ if ( obj == null )
13221323 return obj ;
13231324
13241325 var arr = path . split ( '.' ) ;
@@ -1431,7 +1432,7 @@ exports.streamer = function(beg, end, callback) {
14311432 */
14321433exports . encode = function ( str ) {
14331434
1434- if ( str === undefined )
1435+ if ( str == null )
14351436 return '' ;
14361437
14371438 var type = typeof ( str ) ;
@@ -1449,7 +1450,7 @@ exports.encode = function(str) {
14491450 */
14501451exports . decode = function ( str ) {
14511452
1452- if ( str === undefined )
1453+ if ( str == null )
14531454 return '' ;
14541455
14551456 var type = typeof ( str ) ;
@@ -1476,7 +1477,7 @@ exports.isStaticFile = function(url) {
14761477 * @return {Number }
14771478 */
14781479exports . parseInt = function ( obj , def ) {
1479- if ( obj === undefined || obj === null )
1480+ if ( obj == null )
14801481 return def || 0 ;
14811482 var type = typeof ( obj ) ;
14821483 if ( type === 'number' )
@@ -1486,11 +1487,10 @@ exports.parseInt = function(obj, def) {
14861487
14871488exports . parseBool = exports . parseBoolean = function ( obj , def ) {
14881489
1489- if ( obj === undefined || obj === null )
1490+ if ( obj == null )
14901491 return def === undefined ? false : def ;
14911492
14921493 var type = typeof ( obj ) ;
1493-
14941494 if ( type === 'boolean' )
14951495 return obj ;
14961496
@@ -1509,11 +1509,10 @@ exports.parseBool = exports.parseBoolean = function(obj, def) {
15091509 */
15101510exports . parseFloat = function ( obj , def ) {
15111511
1512- if ( obj === undefined || obj === null )
1512+ if ( obj == null )
15131513 return def || 0 ;
15141514
15151515 var type = typeof ( obj ) ;
1516-
15171516 if ( type === 'number' )
15181517 return obj ;
15191518
@@ -1755,7 +1754,7 @@ function validate_builder_default(name, value, entity) {
17551754 if ( type === 'boolean' )
17561755 return value === true ;
17571756
1758- if ( value === null || value === undefined )
1757+ if ( value == null )
17591758 return false ;
17601759
17611760 if ( value instanceof Array )
@@ -2497,7 +2496,7 @@ Date.prototype.format = function(format, resource) {
24972496 format = format . substring ( 1 ) ;
24982497 }
24992498
2500- if ( format === undefined || format === null || format === '' )
2499+ if ( ! format )
25012500 return self . getFullYear ( ) + '-' + ( self . getMonth ( ) + 1 ) . toString ( ) . padLeft ( 2 , '0' ) + '-' + self . getDate ( ) . toString ( ) . padLeft ( 2 , '0' ) + 'T' + self . getHours ( ) . toString ( ) . padLeft ( 2 , '0' ) + ':' + self . getMinutes ( ) . toString ( ) . padLeft ( 2 , '0' ) + ':' + self . getSeconds ( ) . toString ( ) . padLeft ( 2 , '0' ) + '.' + self . getMilliseconds ( ) . toString ( ) . padLeft ( 3 , '0' ) + 'Z' ;
25022501
25032502 var h = self . getHours ( ) ;
@@ -2963,9 +2962,7 @@ String.prototype.format = function() {
29632962 var arg = arguments ;
29642963 return this . replace ( regexpSTRINGFORMAT , function ( text ) {
29652964 var value = arg [ + text . substring ( 1 , text . length - 1 ) ] ;
2966- if ( value === null || value === undefined )
2967- value = '' ;
2968- return value ;
2965+ return value == null ? '' : value ;
29692966 } ) ;
29702967} ;
29712968
@@ -3027,11 +3024,10 @@ String.prototype.urlDecode = function() {
30273024String . prototype . params = function ( obj ) {
30283025 var formatted = this ;
30293026
3030- if ( obj === undefined || obj === null )
3027+ if ( obj == null )
30313028 return formatted ;
30323029
3033- var reg = / \{ { 2 } [ ^ } \n ] * \} { 2 } / g;
3034- return formatted . replace ( reg , function ( prop ) {
3030+ return formatted . replace ( regexpPARAM , function ( prop ) {
30353031
30363032 var isEncode = false ;
30373033 var name = prop . substring ( 2 , prop . length - 2 ) . trim ( ) ;
@@ -3069,7 +3065,7 @@ String.prototype.params = function(obj) {
30693065 val = obj [ arr [ 0 ] ] [ arr [ 1 ] ] [ arr [ 2 ] ] [ arr [ 3 ] ] [ arr [ 4 ] ] ;
30703066 }
30713067 } else
3072- val = name . length === 0 ? obj : obj [ name ] ;
3068+ val = name . length ? obj [ name ] : obj ;
30733069
30743070 if ( typeof ( val ) === 'function' )
30753071 val = val ( index ) ;
@@ -3078,7 +3074,6 @@ String.prototype.params = function(obj) {
30783074 return prop ;
30793075
30803076 if ( format . length ) {
3081-
30823077 var type = typeof ( val ) ;
30833078 if ( type === 'string' ) {
30843079 var max = + format ;
@@ -3683,7 +3678,7 @@ Number.prototype.format = function(decimals, separator, separatorDecimal) {
36833678
36843679Number . prototype . add = function ( value , decimals ) {
36853680
3686- if ( value === undefined || value === null )
3681+ if ( value == null )
36873682 return this ;
36883683
36893684 if ( typeof ( value ) === 'number' )
@@ -3962,7 +3957,7 @@ Number.prototype.parseDate = function(plus) {
39623957 return new Date ( this + ( plus || 0 ) ) ;
39633958} ;
39643959
3965- if ( typeof ( Number . prototype . toRad ) === 'undefined' ) {
3960+ if ( ! Number . prototype . toRad ) {
39663961 Number . prototype . toRad = function ( ) {
39673962 return this * Math . PI / 180 ;
39683963 } ;
@@ -4808,7 +4803,7 @@ Async.prototype.await = function(name, fn, cb) {
48084803 name = exports . GUID ( 6 ) ;
48094804 }
48104805
4811- if ( self . tasksPending [ name ] !== undefined )
4806+ if ( self . tasksPending [ name ] )
48124807 return false ;
48134808
48144809 self . tasksPending [ name ] = new AsyncTask ( self , name , fn , cb , null ) ;
@@ -4831,7 +4826,7 @@ Async.prototype.wait = function(name, waitingFor, fn, cb) {
48314826 waitingFor = null ;
48324827 }
48334828
4834- if ( self . tasksPending [ name ] !== undefined )
4829+ if ( self . tasksPending [ name ] )
48354830 return false ;
48364831
48374832 self . tasksPending [ name ] = new AsyncTask ( self , name , fn , cb , waitingFor ) ;
@@ -4917,7 +4912,7 @@ Async.prototype.refresh = function(name) {
49174912 break ;
49184913
49194914 var task = self . tasksPending [ name ] ;
4920- if ( task === undefined )
4915+ if ( ! task )
49214916 break ;
49224917
49234918 if ( self . isCanceled || task . isCanceled ) {
@@ -5253,9 +5248,7 @@ function queue_next(name) {
52535248 item . running ++ ;
52545249 ( function ( name ) {
52555250 setImmediate ( function ( ) {
5256- fn ( function ( ) {
5257- queue_next ( name ) ;
5258- } ) ;
5251+ fn ( ( ) => queue_next ( name ) ) ;
52595252 } ) ;
52605253 } ) ( name ) ;
52615254}
@@ -5276,7 +5269,7 @@ exports.queue = function(name, max, fn) {
52765269 return true ;
52775270 }
52785271
5279- if ( exports . queuecache [ name ] === undefined )
5272+ if ( ! exports . queuecache [ name ] )
52805273 exports . queuecache [ name ] = { limit : max , running : 0 , pending : [ ] } ;
52815274
52825275 var item = exports . queuecache [ name ] ;
0 commit comments