Write the item to disk asynchronously.

@param {String} `fp` Destination filepath.
@param {Function} `cb` Callback function
@returns {Object} Returns the instance for chaining.
@api public
965210
function (fp, cb) {
    if (typeof fp === 'function') {
      cb = fp;
      fp = null;
    }

    if (typeof cb !== 'function') {
      throw new Error('async `write` was called without a callback function.');
    }

    var dest = fp || this.dest.path;
    var src = this.src.path;
    var str = this.content;

    if (str) {
      lazy.write(dest, str, cb);
    } else {
      lazy.copy(src, dest, cb);
    }

    this.emit('write', dest);
    return this;
  }
1293663
function (fp, opts) {
    var dest = path.resolve(this.dest(fp || this.path, opts));
    var file = { contents: this.content, path: dest };
    opts = extend({ ask: true, silent: false }, this.options, opts);

    utils.detect(file, opts, function (err) {
      if (file.contents) {
        utils.writeSync(dest, file.contents);
        utils.success('file written to', utils.bold(dest));
      } else {
        utils.copy.sync(this.path, dest);
        utils.success('file copied to', utils.bold(dest));
      }
    });
    return this;
  }
826039
function writeFile(ngindoxObj, encoding, callback) {
	fs.writeFile(filePath, fileString, encoding, function(err) {
		if (err) {
			return callback(err);
		}
		return write(ngindoxObj, callback);
	});
}
57933
function copyFile(source, target) {
    var deferred,
        rd,
        wr;

    if (typeof fs.copyFile === 'function') {
        return Q.ninvoke(fs, 'copyFile', source, target);
    }

    deferred = Q.defer();

    rd = fs.createReadStream(source);
    wr = fs.createWriteStream(target);

    rd.on('error', function (err) {
        deferred.reject(err);
    });

    wr.on('error', function (err) {
        deferred.reject(err);
    });
    wr.on('close', function () {
        deferred.resolve();
    });

    rd.pipe(wr);

    return deferred.promise;
}
970734
function fsReaddir(path, cb) {
    if (path === '/') return cb(new Error('Reading filesystem at / is disallowed to prevent mistakes.'));
    fs.readdir(path, function(err, dir) { if (err) return cb(err);
      var ab = asyncbuilder(cb);
      u.each(dir, function(name) {
        var push = ab.asyncAppend();
        fs.stat(u.join(path, name), function(err, stats) {
          var entry = !err && { name:name, type:(stats.isDirectory() ? 'dir' : stats.isFile() ? 'file' : 'other') };
          push(err, entry);
        });
      });
      ab.complete();
    });
  }
174346
function (data, fragmentKey, cachePath, callback) {
    debug('  write content in file system');
    var basePath =  path.dirname(fragmentKey);
    if (basePath){
      mkdirp.sync(cachePath + '/' + basePath);
    }
    fs.writeFile(cachePath + '/' + fragmentKey, data, function (err) {
      if (err) {
        callback(err);
      } else {
        callback(null, data);
      }
    });
  }
1201493
function writeblobs(data, cb) {
    var ab = asyncbuilder(cb);
    var reqQ = new Queue( { concurrency: 5 } );

    u.each(data, function(file) {
      var append = ab.asyncAppend();
      var blob = { encoding: file.buffer ? 'base64' : 'utf-8',
                   content: file.buffer ? file.buffer.toString('base64') : (file.text || '') };

      reqQ.push(function(reqDone) {
        post(self.endpoint + '/git/blobs', blob, function(err, ghblob) {
          if (ghblob) { file.sha = ghblob.sha; }
          append(err, file);
          reqDone();
        });
      });

    });
    ab.complete();
  }
985500
public function writeChunkToFd($fd, $cb = null)
    {
        return false; // It is not supported yet (callback missing in EventBuffer->write())
        if (!$this->curChunkSize) {
            return false;
        }
        $this->write($fd, $this->curChunkSize);
        $this->curChunkSize = null;
        return true;
    }
69015
function writev (chunks, cb) {
    var buffers = new Array(chunks.length)
    for (var i = 0; i < chunks.length; i++) {
      if (typeof chunks[i].chunk === 'string') {
        buffers[i] = Buffer.from(chunks[i], 'utf8')
      } else {
        buffers[i] = chunks[i].chunk
      }
    }

    this._write(Buffer.concat(buffers), 'binary', cb)
  }
396629
function writeFile(file, content) {
    fs.writeFileSync(file, content);
    files.push(path.relative(app.components.get('path'), file));
}
585919
function copyTemplateDir (srcDir, outDir, vars, cb) {
  if (!cb) {
    if (!vars) vars = noop
    cb = vars
    vars = {}
  }

  assert.equal(typeof srcDir, 'string')
  assert.equal(typeof outDir, 'string')
  assert.equal(typeof vars, 'object')
  assert.equal(typeof cb, 'function')

  // create directory
  mkdirp(outDir, function (err) {
    if (err) return cb(err)

    const rs = readdirp({ root: srcDir })
    const streams = []
    const createdFiles = []

    // create a new stream for every file emitted
    rs.on('data', function (file) {
      createdFiles.push(path.join(outDir, maxstache(removeUnderscore(file.path), vars)))
      streams.push(writeFile(outDir, vars, file))
    })

    // delegate errors & close streams
    eos(rs, function (err) {
      if (err) return cb(err)
      parallel(streams, function (err) {
        if (err) return cb(err)
        cb(null, createdFiles)
      })
    })
  })
}
175045
function (data, callback) {
    if (typeof txDataQueue != "undefined" || txInProgress) {
      if (txDataQueue === undefined)
        txDataQueue = "";
      txDataQueue += data;
      return callback();
    } else {
      txDataQueue = data;
    }

    function writeChunk() {
      var chunk;
      var CHUNKSIZE = 20;
      if (txDataQueue.length <= CHUNKSIZE) {
        chunk = txDataQueue;
        txDataQueue = undefined;
      } else {
        chunk = txDataQueue.substr(0, CHUNKSIZE);
        txDataQueue = txDataQueue.substr(CHUNKSIZE);
      }
      txInProgress = true;
      console.log("BT> Sending " + JSON.stringify(chunk));
      try {
        winnus.write(chunk);
        setTimeout(function() {
          txInProgress = false;
          if (txDataQueue)
            writeChunk();
        }, 20);
      } catch (e) {
        console.log("BT> ERROR " + e);
        txDataQueue = undefined;
      }
    }
    writeChunk();
    return callback();
  }
1024809
function writeFile(filepath, data, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }

  if (!Buffer.isBuffer(data)) {
    return callback(new TypeError('Data must be a Buffer'));
  }

  if (!options) {
    options = {};
  }

  // Default the same as node
  var mode = options.mode || constants.DEFAULT_FILE_MODE;
  var flags = options.flags || 'w';
  var position = APPEND_MODE_REGEXP.test(flags) ? null : 0;

  fs.open(filepath, flags, mode, onOpen);

  function onOpen(openErr, fd) {
    if (openErr) {
      return onComplete(openErr);
    }

    fs.write(fd, data, 0, data.length, position, onComplete);

    function onComplete(writeErr) {
      callback(writeErr, fd);
    }
  }
}
1282581
function(file, content, callback) {
			fs.writeFile(file, content, 'ascii', function(err) {
				callback(err ? err : null);
			});
		}
948814
function writeFile(cvs, data, callback) {
    if (typeof data.path !== 'string') {
      return callback(new TypeError('Invalid path type: ' + typeof data.path));
    }

    var fd, buff;

    // Write the buffer to the open file stream once both prerequisites are met.
    function writeBuffer() {
      fs.write(fd, buff, 0, buff.length, 0, function (error) {
        fs.close(fd);

        callback(error);
      });
    }

    // Create a buffer of the canvas' data.
    cvs.toBuffer(function (error, _buff) {
      if (error) return callback(error);

      buff = _buff;
      if (fd) {
        writeBuffer();
      }
    });

    // Open a stream for the file to be written.
    fs.open(data.path, 'w', WRITE_MODE, function (error, _fd) {
      if (error) return callback(error);

      fd = _fd;
      if (buff) {
        writeBuffer();
      }
    });
  }
93131
function(p, cb)
{
  //Get the status of the path
  return fs.stat(p, function(error, stat)
  {
    //Check the error
    if(error)
    {
      //Check the error code
      if(error.code !== 'ENOENT')
      {
        //Do the callback with the error
        return cb(error, false, stat);
      }
      else
      {
        //Do the callback without error
        return cb(null, false, stat);
      }
    }

    //Do the callback with the stat
    return cb(null, true, stat);
  });
}
272693
function writeToDisk(output, data, callback) {
  fs.mkdirp(path.dirname("" + output), function (err) {
    if (err) {
      if (callback) {
        callback(err);
      }
      return console.log(err);
    }
    fs.writeFile("" + output, data, function (err) {
      if (err) {
        if (callback) {
          callback(err);
        }
        return console.log(err);
      } else {
        if (callback) {
          callback();
        }
      }
    });
  });
}