function mock( options, clbk ) {
	var opts;
	var data;
	var repl;

	if ( !isFunction( clbk ) ) {
		throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', clbk ) );
	}
	opts = assign( defaults(), options );
	if ( !opts.input ) {
		throw new Error( 'invalid argument. Options argument must specify an input stream.' );
	}
	// If we were not provided an output stream, create a default output stream...
	if ( !opts.output ) {
		opts.output = inspectSinkStream( onWrite );
		if ( opts.tty ) {
			// Mock a TTY write stream (see https://nodejs.org/api/tty.html#class-ttywritestream):
			opts.output.columns = opts.tty.columns;
			opts.output.rows = opts.tty.rows;
		}
	}
	// Initialize an array for storing streamed data:
	data = [];

	// Create a new REPL instance:
	repl = new REPL( opts );

	// Add a listener for when the REPL exits:
	repl.on( 'exit', onExit );

	// Return the REPL instance:
	return repl;

	/**
	* Callback invoked upon receiving streamed data.
	*
	* @private
	* @param {(Buffer|string)} chunk - data
	* @returns {void}
	*/
	function onWrite( chunk ) {
		data.push( chunk.toString() );
	}

	/**
	* Callback invoked when a REPL exits.
	*
	* @private
	*/
	function onExit() {
		if ( isFunction( opts.output.end ) ) {
			opts.output.end();
		}
		clbk( null, data );
	}
}
Returns a REPL instance connected to debugging IO streams.

@private
@param {Options} options - REPL options
@param {WritableStream} options.input - input stream
@param {Object} [options.tty] - TTY options
@param {integer} [options.tty.columns] - number of terminal columns
@param {integer} [options.tty.rows] - number of terminal rows
@param {Callback} clbk - callback to invoke upon closing a REPL
@throws {Error} must provide an input stream
@throws {TypeError} second argument must be a function
@returns {REPL} REPL instance

@example
var DebugStream = require( '@stdlib/streams/node/debug' );

// Define a callback for receiving REPL input on close:
function onClose( error, data ) {
    if ( error ) {
        return console.error( error.message );
    }
    console.log( data.join( '\n' ) );
}

// Create a stream for writing REPL input:
var istream = new DebugStream({
    'name': 'repl-input-stream'
});

// Create a test REPL instance:
var opts = {
    'input': istream
};
var repl = mock( opts, onClose );

// Simulate a user entering a command in the REPL:
istream.write( '2+2\n' );

// Close the REPL:
repl.close();