File tree Expand file tree Collapse file tree 2 files changed +33
-29
lines changed
Expand file tree Collapse file tree 2 files changed +33
-29
lines changed Original file line number Diff line number Diff line change 45434543 }
45444544 var type = string_case ( string ) ;
45454545 var result = [ ] ;
4546+ loop:
45464547 for ( var j = string . length ; j < array [ 0 ] . length ; ++ j ) {
4547- var push = false ;
4548- var pushCandidate = array [ 0 ] . charAt ( j ) ;
45494548 for ( var i = 1 ; i < array . length ; ++ i ) {
4550- var currentChar = array [ i ] . charAt ( j ) ;
4551- push = true ;
4552- if ( pushCandidate !== currentChar ) {
4549+ var a = array [ 0 ] . charAt ( j ) ;
4550+ var b = array [ i ] . charAt ( j ) ;
4551+ if ( a !== b ) {
45534552 if ( matchCase || type === 'mixed' ) {
4554- push = false ;
4555- break ;
4556- } else if ( pushCandidate . toLowerCase ( ) === currentChar . toLowerCase ( ) ) {
4553+ break loop;
4554+ } else if ( a . toLowerCase ( ) === b . toLowerCase ( ) ) {
45574555 if ( type === 'lower' ) {
4558- pushCandidate = pushCandidate . toLowerCase ( ) ;
4559- } else if ( type === 'upper' ) {
4560- pushCandidate = pushCandidate . toUpperCase ( ) ;
4556+ result . push ( a . toLowerCase ( ) ) ;
45614557 } else {
4562- push = false ;
4563- break ;
4558+ result . push ( a . toUpperCase ( ) ) ;
45644559 }
4565- } else {
4566- push = false ;
4567- break ;
45684560 }
4561+ } else {
4562+ result . push ( a ) ;
45694563 }
45704564 }
4571- if ( push ) {
4572- result . push ( pushCandidate ) ;
4573- }
45744565 }
45754566 return string + result . join ( '' ) ;
45764567 }
Original file line number Diff line number Diff line change 45434543 }
45444544 var type = string_case ( string ) ;
45454545 var result = [ ] ;
4546- loop:
45474546 for ( var j = string . length ; j < array [ 0 ] . length ; ++ j ) {
4547+ var push = false ;
4548+ var candidate = array [ 0 ] . charAt ( j ) ,
4549+ candidateLower = candidate . toLowerCase ( ) ;
4550+
45484551 for ( var i = 1 ; i < array . length ; ++ i ) {
4549- var a = array [ 0 ] . charAt ( j ) ;
4550- var b = array [ i ] . charAt ( j ) ;
4551- if ( a !== b ) {
4552+ push = true ;
4553+ var current = array [ i ] . charAt ( j ) ,
4554+ currentLower = current . toLowerCase ( ) ;
4555+
4556+ if ( candidate !== current ) {
45524557 if ( matchCase || type === 'mixed' ) {
4553- break loop;
4554- } else if ( a . toLowerCase ( ) === b . toLowerCase ( ) ) {
4558+ push = false ;
4559+ break ;
4560+ } else if ( candidateLower === currentLower ) {
45554561 if ( type === 'lower' ) {
4556- result . push ( a . toLowerCase ( ) ) ;
4562+ candidate = candidate . toLowerCase ( ) ;
4563+ } else if ( type === 'upper' ) {
4564+ candidate = candidate . toUpperCase ( ) ;
45574565 } else {
4558- result . push ( a . toUpperCase ( ) ) ;
4566+ push = false ;
4567+ break ;
45594568 }
4569+ } else {
4570+ push = false ;
4571+ break ;
45604572 }
4561- } else {
4562- result . push ( a ) ;
45634573 }
45644574 }
4575+ if ( push ) {
4576+ result . push ( candidate ) ;
4577+ }
45654578 }
45664579 return string + result . join ( '' ) ;
45674580 }
You can’t perform that action at this time.
0 commit comments