'use strict';

// MODULES //

var r = require( 'repl' );
var getKeys = require( 'object-keys' ).shim();
var namespace = require( '@stdlib/namespace' );
var defaults = require( './defaults.js' );


// REPL //

/**
* Starts a REPL environment.
*
* @returns {Object} REPL server
*
* @example
* repl();
*/
function repl() {
	var context;
	var server;
	var opts;
	var keys;
	var key;
	var i;

	opts = defaults();
	server = r.start( opts );

	// Create a REPL context:
	context = namespace( {} );

	// Bind all context values to the REPL server...
	keys = getKeys( context );
	for ( i = 0; i < keys.length; i++ ) {
		key = keys[ i ];
		server.context[ key ] = context[ key ];
	}
	return server;
} // end FUNCTION repl()


// EXPORTS //

module.exports = repl;

'use strict';

// MODULES //

var r = require( 'repl' );
var getKeys = require( 'object-keys' ).shim();
var namespace = require( '@stdlib/namespace' );
var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
var defaults = require( './defaults.js' );


// REPL //

/**
* Starts a REPL environment.
*
* @returns {Object} REPL server
*
* @example
* repl();
*/
function repl() {
	var context;
	var server;
	var opts;
	var keys;
	var key;
	var i;

	opts = defaults();
	server = r.start( opts );

	// Create a REPL context:
	context = namespace( {} );

	// Bind all context values to the REPL server...
	keys = getKeys( context );
	for ( i = 0; i < keys.length; i++ ) {
		key = keys[ i ];
		setReadOnly( server.context, key, context[ key ] );
	}
	return server;
} // end FUNCTION repl()


// EXPORTS //

module.exports = repl;

Make REPL context properties read-only
Make REPL context properties read-only
