Generating a new filename to avoid names in the list by adding sequenced number
@param {string[]} list - Filenames already in use
@param {string} name - New filenames about to use
@returns {string} - Generated new filename
510249
function getNewFilename(list, name) {
  if (list.indexOf(name) === -1) {
    return name;
  }
  const parsed = parseFilename(name);
  const base = parsed.base;
  const ext = parsed.ext;
  if (!base) {
    const newName = getNextNumberName(ext);
    return getNewFilename(list, newName);
  } else {
    const basename = getNextNumberName(base);
    return getNewFilename(list, `${basename}${ext}`);
  }
}
1199289
function generateHoistNameBasedOn(path, suffix = "") {
  const names = [];
  if (suffix) {
    names.push(suffix);
  }

  let current = path;
  while (!(current.isIdentifier() || current.isJSXIdentifier())) {
    names.push(current.node.property.name);
    current = current.get("object");
  }
  names.push(current.node.name);

  return path.scope.generateUidIdentifier(names.reverse().join("$"));
}
395719
function newfile(filepath) {
  let dir = path.dirname(filepath);
  if (path.extname(filepath) === '.shp') dir = path.resolve(dir, '..');
  const name = crypto.randomBytes(8).toString('hex');
  return path.join(dir, name);
}
883101
function List(name, expiry, maxLength) {
  this.name = name;
  this.expiry = expiry;
  this.maxLength = maxLength;
  this.idGen = new IdGen('id_gen:/'+name);
}
498521
def output_filename(name)
      path = File.expand_path(name, output_dir)
      output File.new(path, 'a+')
    end
196600
function (names) {
            var ret = [].concat(names),
                i,
                m,
                alias,
                ok = 0,
                j;
            while (!ok) {
                ok = 1;
                for (i = ret.length - 1; i >= 0; i--) {
                    if ((m = Utils.createModuleInfo(ret[i])) && ((alias = m.getAlias()) !== undefined)) {
                        ok = 0;
                        if (typeof alias === 'string') {
                            alias = [alias];
                        }
                        for (j = alias.length - 1; j >= 0; j--) {
                            if (!alias[j]) {
                                alias.splice(j, 1);
                            }
                        }
                        ret.splice.apply(ret, [i, 1].concat(addIndexAndRemoveJsExt(alias)));
                    }
                }
            }
            return ret;
        }
771602
function(name) {
    var nameList = name.split('.');

    return nameList
      .map(function(item, i, list) {
        return list.slice(0, i+1).join('.');
      })
      .filter(function(item) {
        return item !== null;
      });
  }
870206
function verifyFileName (fileName)
{
    // if fileName undefined or null, throw exception
    if ((fileName === undefined) || (fileName === null)) {
        var message1 = format (cc.MSG_INVALID_NAME);
        throw new SafeFileError (cc.INVALID_NAME, message1);
    }
}
1127157
function _getSafeFileName(filename, directory) {
        var deferred = q.defer();
    
        fs.readdir(directory, function(err, files) {
    
            if(err) {
              // This means the directory doesn't exist
              if (err.errno === 34 && err.code === 'ENOENT') {
                deferred.resolve(filename);
              }
              else {
                deferred.reject(err);
              }
            }
            else {
              var index = files.indexOf(filename);
              if (index > -1) { 
    
                // Get filename and extension (if it has one)
                var name, extension;
                var splitString = filename.split('.');
    
                // Has extension
                if (splitString.length > 1) {
                  extension = splitString.pop(); 
                  name = splitString.join('.');
    
                  // Wait! Is this a hidden file?
                  if (!name) {
                    name = '.' + extension;
                    extension = '';
                  }
                }
                // No extension
                else {
                  name = filename;
                  extension = '';
                }
    
                // Get the copy number appended to the name and increment, if any
                var matches = name.match(/\((\d+)\)$/);
                if (matches) {
                  var copyNumber = Number(matches[1]) + 1;
                  name = name.replace(/\((\d+)\)$/, '(' + copyNumber + ')'); 
                }
                else {
                  name += '(1)';
                }
    
                // Assemble new filename
                if (extension) {
                  filename = name + '.' + extension;
                }
                else {
                  filename = name;
                }
    			deferred.resolve(_getSafeFileName(filename, directory));
              }
    		  else {
              	deferred.resolve(filename);
    		  }
            }       
          });
    
        return deferred.promise;
      }
576992
private ModelNode addNewAliasToList(ModelNode list, String alias) {

        // check for empty string
        if (alias == null || alias.equals(""))
            return list ;

        // check for undefined list (AS7-3476)
        if (!list.isDefined()) {
            list.setEmptyList();
        }

        ModelNode newList = list.clone() ;
        List<ModelNode> listElements = list.asList();

        boolean found = false;
        for (ModelNode listElement : listElements) {
            if (listElement.asString().equals(alias)) {
                found = true;
            }
        }
        if (!found) {
            newList.add().set(alias);
        }
        return newList ;
    }
729004
function(file, list) {
        console.debug('replacing: ', file);
        try {
            var f;
            f =(f=file.split(/\//))[f.length-1];
            var isJS = /\.js/.test(f.substring(f.length-3));
            var isJSON = /\.js/.test(f.substring(f.length-5));

            if ( isJS || isJSON && /config\/app\.json/.test(file) ) {
                var contentFile = fs.readFileSync(file, 'utf8').toString();
                //var contentFile = require(file).toSource();
                var dic = {
                    "Bundle" : self.bundle.substring(0, 1).toUpperCase() + self.bundle.substring(1),
                    "bundle" : self.bundle
                };

                contentFile = whisper(dic, contentFile);//data
                //rewrite file
                fs.writeFileSync(file, contentFile)
            }

            if ( list != undefined && list.indexOf(file) > -1 ) { //end of current dir
                list.splice( list.indexOf(file), 1 )
            }
            return list

        } catch(err) {
            console.error(err.stack);
            process.exit(1)
        }
    }
510316
function renameFiles(files)
{
  files.forEach(function (file)
  {
    var originalName = path.basename(file);
    var newFileName = originalName.toLowerCase();
    var directory = path.dirname(file);
    if (originalName != newFileName)
    {
      fs.renameSync(file, directory + "/" + newFileName); //, function(err)

      if (debug)
        console.log('Renamed: %s --> %s', originalName, newFileName);

      originalFiles.push(originalName);
      renamedFiles.push(newFileName);
    }
  });
}
45605
def _encode_list(name, value, check_keys, opts):
    """"""
    lname = gen_list_name()
    data = b"".join([_name_value_to_bson(next(lname), item,
                                         check_keys, opts)
                     for item in value])
    return b"\x04" + name + _PACK_INT(len(data) + 5) + data + b"\x00"
1100812
protected void appendList(StringBuilder buff, String name, List list) {
    buff.append(',');
    buff.append(name);
    buff.append("=[");
    if (list != null) {
      // Take a copy of the array, to be very sure it doesn't change under us
      Object[] items = list.toArray();
      for (int i = 0; i < items.length; i++) {
        if (i != 0) buff.append(',');
        if (items[i] instanceof byte[]) {
          // Print out the bytes in hex.
          buff.append(HexUtil.toString((byte[])items[i]));
        }
        else {
          // Just use the default toString
          buff.append(items[i]);
        }
      }
    }
    buff.append(']');
  }
}
268354
void genCode(String name, ArrayList<JFile> ilist,
               ArrayList<JRecord> rlist, String destDir, ArrayList<String> options)
    throws IOException {
    name = new File(destDir, (new File(name)).getName()).getAbsolutePath();

    FileWriter cc = new FileWriter(name+".cc");
    try {
      FileWriter hh = new FileWriter(name+".hh");
      
      try {
        String fileName = (new File(name)).getName();
        hh.write("#ifndef __"+fileName.toUpperCase().replace('.','_')+"__\n");
        hh.write("#define __"+fileName.toUpperCase().replace('.','_')+"__\n");
        hh.write("#include \"recordio.hh\"\n");
        hh.write("#include \"recordTypeInfo.hh\"\n");
        for (Iterator<JFile> iter = ilist.iterator(); iter.hasNext();) {
          hh.write("#include \""+iter.next().getName()+".hh\"\n");
        }
        
        cc.write("#include \""+fileName+".hh\"\n");
        cc.write("#include \"utils.hh\"\n");
        
        for (Iterator<JRecord> iter = rlist.iterator(); iter.hasNext();) {
          iter.next().genCppCode(hh, cc, options);
        }
        
        hh.write("#endif //"+fileName.toUpperCase().replace('.','_')+"__\n");
      } finally {
        hh.close();
      }
    } finally {
      cc.close();
    }
  }
8854
function makeFilenameRegex(name) {
  if (!_.isString(name)) {
    throw new TypeError('name parameter must be of type "String"');
  }

  const regexString = `^${name}(?:[.](.+))?.(${fileExtensions.join('|')})$`;
  return new RegExp(regexString);
}
1298604
function listToArray(list) {
  if(isFunction(list)) {
    return function(x) {
      const m = list(x)

      if(!isSameType(List, m)) {
        throw new TypeError('listToArray: List returning function required')
      }

      return m.toArray()
    }
  }

  if(isSameType(List, list)) {
    return list.toArray()
  }

  throw new TypeError('listToArray: List or List returning function required')
}