bundles/org.eclipse.orion.client.ui/web/orion/fileCommands.js
function(children) {
				var attempt = 0;
				var uniqueName = prefix;
				
				// find a unique name for the new artifact
				var possiblyCollidingNames = children.filter(function(child){
					return 0 === child.Name.indexOf(prefix);
				}).map(function(child){
					return child.Name;
				});
				
				while (-1 !== possiblyCollidingNames.indexOf(uniqueName)){
					attempt++;
					uniqueName = prefix.concat(" (").concat(attempt).concat(")");  //$NON-NLS-1$ //$NON-NLS-0$
				}
				
				return uniqueName;
			}
function(children) {
				var attempt = 0;
				var uniqueName = prefix;
				
				// find a unique name for the new artifact
				var possiblyCollidingNames = children.filter(function(child){
					return 0 === child.Name.indexOf(prefix);
				}).map(function(child){
					return child.Name;
				});
				
				while (-1 !== possiblyCollidingNames.indexOf(uniqueName)){
					attempt++;
					uniqueName = prefix.concat(" (").concat(attempt).concat(")");  //$NON-NLS-1$ //$NON-NLS-0$
				}
				
				return uniqueName;
			}
function ( children ) { var attempt = 0 ; var uniqueName = prefix ; // find a unique name for the new artifact var possiblyCollidingNames = children . filter ( function ( child ) { return 0 === child . Name . indexOf ( prefix ) ; } ) . map ( function ( child ) { return child . Name ; } ) ; while ( - 1 !== possiblyCollidingNames . indexOf ( uniqueName ) ) { attempt ++ ; uniqueName = prefix . concat ( " (" ) . concat ( attempt ) . concat ( ")" ) ; //$NON-NLS-1$ //$NON-NLS-0$ } return uniqueName ; }
get the list of files that already exists in the selected directory and ensure that the new file's initial name is unique within that directory
get the list of files that already exists in the selected directory and ensure that the new file s initial name is unique within that directory