Return the id corresponding to a provided URI.
var uri2id = require( '@stdlib/_tools/links/uri2id' );Returns the id corresponding to a provided URI.
uri2id( 'http://www.bibtex.org/', clbk );
function clbk( error, id ) {
if ( error ) {
throw error;
}
console.log( id );
// => 'bibtex'
}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'
};
uri2id( 'http://www.bibtex.org/', opts, clbk );
function clbk( error, id ) {
if ( error ) {
throw error;
}
console.log( id );
}Synchronously returns the id which corresponds to a provided URI.
var id = uri2id.sync( 'http://www.bibtex.org/' );
if ( id instanceof Error ) {
throw id;
}
console.log( id );
// => 'bibtex'The method accepts the same options as uri2id() above.
- If a function is unable to resolve an
id, 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 uri2id = require( '@stdlib/_tools/links/uri2id' );
uri2id( 'https://github.com/stdlib-js/stdlib', clbk );
function clbk( error, id ) {
if ( error ) {
throw error;
}
console.log( id );
}Usage: uri2id [options] [<uri>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--database filepath Database filepath.
- If invoked without a URI, the CLI will interactively prompt for argument input.
$ uri2id http://www.bibtex.org/