text: /**
  * @license Apache-2.0
  *
  * Copyright (c) 2018 The Stdlib Authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
  
  'use strict';
  
  // MODULES //
  
  var resolve = require( 'path' ).resolve;
  var getKeys = require( '@stdlib/utils/keys' );
  var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
  var readJSON = require( '@stdlib/fs/read-json' ).sync;
  var instanceOf = require( '@stdlib/assert/instance-of' );
  var cwd = require( '@stdlib/process/cwd' );
  var config = require( './defaults.js' );
  var validate = require( './validate.js' );
  
  
  // MAIN //
  
  /**
  * Synchronously returns the URI corresponding to a provided id.
  *
  * @param {string} id - id
  * @param {Options} [options] - options
  * @param {string} [options.database] - path to a link database file (JSON)
  * @throws {TypeError} must provide a string
  * @throws {TypeError} options argument must be an object
  * @throws {TypeError} must provide valid options
  * @returns {(Error|string|null)} result
  *
  * @example
  * var uri = id2uri( 'bibtex' );
  * // returns 'http://www.bibtex.org/'
  */
  function id2uri( id, options ) {
  	var fopts;
  	var opts;
  	var keys;
  	var err;
  	var db;
  	var i;
  	if ( !isString( id ) ) {
  		throw new TypeError( 'invalid argument. First argument must be a string. Value: `'+id+'`.' );
  	}
  	opts = {
  		'database': config.database
  	};
  	if ( arguments.length > 1 ) {
  		err = validate( opts, options );
  		if ( err ) {
  			throw err;
  		}
  	}
  	opts.database = resolve( cwd(), opts.database );
  	fopts = {
  		'encoding': 'utf8'
  	};
  	db = readJSON( opts.database, fopts );
  	if ( instanceOf( db, Error ) ) {
  		return db;
  	}
  	keys = getKeys( db );
  	for ( i = 0; i < keys.length; i++ ) {
  		if ( db[ keys[i] ].id === id ) {
  			return keys[ i ];
  		}
  	}
  	return null;
  }
  
  
  // EXPORTS //
  
  module.exports = id2uri;
  