function pkgIndex() {
	var options;
	var opts;
	var clbk;
	var err;

	opts = copy( defaults );
	if ( arguments.length < 2 ) {
		clbk = arguments[ 0 ];
	} else {
		options = arguments[ 0 ];
		clbk = arguments[ 1 ];
		err = validate( opts, options );
		if ( err ) {
			throw err;
		}
	}
	if ( !isFunction( clbk ) ) {
		throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );
	}
	if ( opts.dir ) {
		opts.dir = path.resolve( cwd(), opts.dir );
	} else {
		opts.dir = cwd();
	}
	debug( 'Searching for READMEs...' );
	findReadmes( opts, onReadmes );

	/**
	* Callback invoked after finding package READMEs.
	*
	* @private
	* @param {(Error|null)} error - error object
	* @param {StringArray} files - list of file paths
	* @returns {void}
	*/
	function onReadmes( error, files ) {
		if ( error ) {
			debug( 'Encountered an error when searching for READMEs. Error: %s', error.message );
			return done( error );
		}
		debug( 'Found %d READMEs.', files.length );
		if ( files.length === 0 ) {
			return done( null, null );
		}
		debug( 'Files: %s', JSON.stringify( files ) );
		debug( 'Reading file contents...' );
		readFileList( files, FOPTS, onFiles );
	}

	/**
	* Callback invoked after retrieving file contents.
	*
	* @private
	* @param {(Error|null)} error - error object
	* @param {ObjectArray} files - list of files and their contents
	* @returns {void}
	*/
	function onFiles( error, files ) {
		var idx;
		if ( error ) {
			debug( 'Encountered an error when reading README file contents. Error: %s', error.message );
			return done( error );
		}
		debug( 'Creating search index.' );
		idx = createIndex( files );
		debug( 'Successfully created search index.' );
		done( null, idx );
	}

	/**
	* Callback invoked upon completion.
	*
	* @private
	* @param {(Error|null)} error - error object
	* @param {(Object|null)} idx - serialized search index
	* @returns {void}
	*/
	function done( error, idx ) {
		if ( error ) {
			return clbk( error );
		}
		clbk( null, idx );
	}
}
Creates a serialized search index for all packages.

@param {Options} [options] - function options
@param {string} [options.dir] - root directory at which to start indexing
@param {string} [options.pattern='**\/package.json'] - glob pattern
@param {StringArray} [options.ignore] - glob pattern(s) to exclude matches
@param {Callback} clbk - callback function
@throws {Error} must provide valid options
@throws {TypeError} options argument must be an object
@throws {TypeError} callback argument must be a function

@example
var resolve = require( 'path' ).resolve;

var opts = {
    'dir': resolve( __dirname, '..' )
};
pkgIndex( opts, clbk );

function clbk( error, idx ) {
    if ( error ) {
        console.error( error.message );
        return;
    }
    console.log( idx );
}