id2uri

Return the URI corresponding to a provided id.

Usage

var id2uri = require( '@stdlib/_tools/links/id2uri' );

id2uri( id, [options,] clbk )

Returns the URI corresponding to a provided id.

id2uri( 'bibtex', clbk );

function clbk( error, uri ) {
    if ( error ) {
        throw error;
    }
    console.log( uri );
    // => 'http://www.bibtex.org/'
}

The function accepts the following options:

  • database: path to a link database.

To use an alternative link database, set the database option.

var opts = {
    'database': './path/to/link/database/json'
};

id2uri( 'bibtex', opts, clbk );

function clbk( error, uri ) {
    if ( error ) {
        throw error;
    }
    console.log( uri );
}

id2uri.sync( id[, options] )

Synchronously returns the URI which corresponds to a provided id.

var uri = id2uri.sync( 'bibtex' );
if ( uri instanceof Error ) {
    throw id;
}
console.log( uri );
// => 'http://www.bibtex.org/'

The method accepts the same options as id2uri() above.

Notes

  • If a function is unable to resolve a URI, the function returns null.
  • A link database is resolved relative to the current working directory of the calling process and should be a JSON file.

Examples

var id2uri = require( '@stdlib/_tools/links/id2uri' );

id2uri( 'stdlib', clbk );

function clbk( error, uri ) {
    if ( error ) {
        throw error;
    }
    console.log( uri );
}

CLI

Usage

Usage: id2uri [options] [<id>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --database filepath   Database filepath.

Notes

  • If invoked without an id, the CLI will interactively prompt for argument input.

Examples

$ id2uri bibtex