Return the URI corresponding to a provided id.
var id2uri = require( '@stdlib/_tools/links/id2uri' );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 );
}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.
- If a function is unable to resolve a
URI, the function returnsnull. - A link database is resolved relative to the current working directory of the calling process and should be a JSON file.
var id2uri = require( '@stdlib/_tools/links/id2uri' );
id2uri( 'stdlib', clbk );
function clbk( error, uri ) {
if ( error ) {
throw error;
}
console.log( uri );
}Usage: id2uri [options] [<id>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--database filepath Database filepath.
- If invoked without an id, the CLI will interactively prompt for argument input.
$ id2uri bibtex