async function(filename, length) {
      if (await this.safeStat(filename) && length > 1) {
        var lastFile = null;
        for (var i = length; i > 0; i--) {
          var tmp = filename + "." + i;
          if (i == length) {
            await this.safeUnlink(tmp);
          } else if (await this.safeStat(tmp)) {
            await rename(tmp, lastFile);
          }
          lastFile = tmp;
        }
        await rename(filename, lastFile);
      }
    }
async function(filename, length) {
      if (await this.safeStat(filename) && length > 1) {
        var lastFile = null;
        for (var i = length; i > 0; i--) {
          var tmp = filename + "." + i;
          if (i == length) {
            await this.safeUnlink(tmp);
          } else if (await this.safeStat(tmp)) {
            await rename(tmp, lastFile);
          }
          lastFile = tmp;
        }
        await rename(filename, lastFile);
      }
    }
async function ( filename , length ) { if ( await this . safeStat ( filename ) && length > 1 ) { var lastFile = null ; for ( var i = length ; i > 0 ; i -- ) { var tmp = filename + "." + i ; if ( i == length ) { await this . safeUnlink ( tmp ) ; } else if ( await this . safeStat ( tmp ) ) { await rename ( tmp , lastFile ) ; } lastFile = tmp ; } await rename ( filename , lastFile ) ; } }
Rotates files so that this file does not exist, by renaming the existing file to have a ".1"
appended, and the ".1" to be renamed to ".2" etc, up to `length` versions

@param filename {String} filename to rotate
@param length {Integer} maximum number of files
@async
Rotates files so that this file does not exist by renaming the existing file to have a . 1 appended and the . 1 to be renamed to . 2 etc up to length versions