function tmpName(options, callback) {
  var
    args = _parseArguments(options, callback),
    opts = args[0],
    cb = args[1],
    tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;

  if (isNaN(tries) || tries < 0)
    return cb(new Error('Invalid tries'));

  if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
    return cb(new Error('Invalid template provided'));

  (function _getUniqueName() {
    const name = _generateTmpName(opts);

    // check whether the path exists then retry if needed
    fs.stat(name, function (err) {
      if (!err) {
        if (tries-- > 0) return _getUniqueName();

        return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name));
      }

      cb(null, name);
    });
  }());
}
/**
 * Gets a temporary file name.
 *
 * @param {(Options|tmpNameCallback)} options options or callback
 * @param {?tmpNameCallback} callback the callback function
 */
Gets a temporary file name.
@param {(Options|tmpNameCallback)} options options or callback
@param {?tmpNameCallback} callback the callback function
Gets a temporary file name . @param { ( Options|tmpNameCallback ) } options options or callback @param { ?tmpNameCallback } callback the callback function
function tmpName(options, callback) {
  var
    args = _parseArguments(options, callback),
    opts = args[0],
    cb = args[1],
    tries = opts.name ? 1 : opts.tries || DEFAULT_TRIES;
  if (isNaN(tries) || tries < 0)
    return cb(new Error('Invalid tries'));
  if (opts.template && !opts.template.match(TEMPLATE_PATTERN))
    return cb(new Error('Invalid template provided'));
  (function _getUniqueName() {
    const name = _generateTmpName(opts);
    fs.stat(name, function (err) {
      if (!err) {
        if (tries-- > 0) return _getUniqueName();
        return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name));
      }
      cb(null, name);
    });
  }());
}
function tmpName ( options , callback ) { var args = _parseArguments ( options , callback ) , opts = args [ 0 ] , cb = args [ 1 ] , tries = opts . name ? 1 : opts . tries || DEFAULT_TRIES ; if ( isNaN ( tries ) || tries < 0 ) return cb ( new Error ( 'Invalid tries' ) ) ; if ( opts . template && ! opts . template . match ( TEMPLATE_PATTERN ) ) return cb ( new Error ( 'Invalid template provided' ) ) ; ( function _getUniqueName ( ) { const name = _generateTmpName ( opts ) ; fs . stat ( name , function ( err ) { if ( ! err ) { if ( tries -- > 0 ) return _getUniqueName ( ) ; return cb ( new Error ( 'Could not get a unique tmp filename, max tries reached ' + name ) ) ; } cb ( null , name ) ; } ) ; } ( ) ) ; }
Gets a temporary file name.
Gets a temporary file name .
// check whether the path exists then retry if needed