'string_decoder', 'tls', 'tty', 'url', 'util', 'vm', 'zlib'];
-function REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined) {
+function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
if (!(this instanceof REPLServer)) {
- return new REPLServer(prompt, stream, eval, useGlobal, ignoreUndefined);
+ return new REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined);
}
EventEmitter.call(this);
stream = options.stream || options.socket;
input = options.input;
output = options.output;
- eval = options.eval;
+ eval_ = options.eval;
useGlobal = options.useGlobal;
ignoreUndefined = options.ignoreUndefined;
prompt = options.prompt;
self.useGlobal = !!useGlobal;
self.ignoreUndefined = !!ignoreUndefined;
- self.eval = eval || function(code, context, file, cb) {
+ self.eval = eval_ || function(code, context, file, cb) {
var err, result;
try {
if (self.useGlobal) {
// prompt is a string to print on each line for the prompt,
// source is a stream to use for I/O, defaulting to stdin/stdout.
-exports.start = function(prompt, source, eval, useGlobal, ignoreUndefined) {
- var repl = new REPLServer(prompt, source, eval, useGlobal, ignoreUndefined);
+exports.start = function(prompt, source, eval_, useGlobal, ignoreUndefined) {
+ var repl = new REPLServer(prompt, source, eval_, useGlobal, ignoreUndefined);
if (!exports.repl) exports.repl = repl;
return repl;
};
expr = bits.join('.');
}
- // console.log("expression completion: completeOn='" + completeOn +
- // "' expr='" + expr + "'");
-
// Resolve expr and get its completions.
var obj, memberGroups = [];
if (!expr) {
completionGroups.push(Object.getOwnPropertyNames(contextProto));
}
completionGroups.push(Object.getOwnPropertyNames(this.context));
- addStandardGlobals();
+ addStandardGlobals(completionGroups, filter);
completionGroupsLoaded();
} else {
this.eval('.scope', this.context, 'repl', function(err, globals) {
if (err || !globals) {
- addStandardGlobals();
+ addStandardGlobals(completionGroups, filter);
} else if (Array.isArray(globals[0])) {
// Add grouped globals
globals.forEach(function(group) {
});
} else {
completionGroups.push(globals);
- addStandardGlobals();
+ addStandardGlobals(completionGroups, filter);
}
completionGroupsLoaded();
});
}
-
- function addStandardGlobals() {
- // Global object properties
- // (http://www.ecma-international.org/publications/standards/Ecma-262.htm)
- completionGroups.push(['NaN', 'Infinity', 'undefined',
- 'eval', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'decodeURI',
- 'decodeURIComponent', 'encodeURI', 'encodeURIComponent',
- 'Object', 'Function', 'Array', 'String', 'Boolean', 'Number',
- 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
- 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
- 'Math', 'JSON']);
- // Common keywords. Exclude for completion on the empty string, b/c
- // they just get in the way.
- if (filter) {
- completionGroups.push(['break', 'case', 'catch', 'const',
- 'continue', 'debugger', 'default', 'delete', 'do', 'else',
- 'export', 'false', 'finally', 'for', 'function', 'if',
- 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
- 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined',
- 'var', 'void', 'while', 'with', 'yield']);
- }
- }
-
} else {
this.eval(expr, this.context, 'repl', function(e, obj) {
// if (e) console.log(e);
}
};
+function addStandardGlobals(completionGroups, filter) {
+ // Global object properties
+ // (http://www.ecma-international.org/publications/standards/Ecma-262.htm)
+ completionGroups.push(['NaN', 'Infinity', 'undefined',
+ 'eval', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'decodeURI',
+ 'decodeURIComponent', 'encodeURI', 'encodeURIComponent',
+ 'Object', 'Function', 'Array', 'String', 'Boolean', 'Number',
+ 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError',
+ 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError',
+ 'Math', 'JSON']);
+ // Common keywords. Exclude for completion on the empty string, b/c
+ // they just get in the way.
+ if (filter) {
+ completionGroups.push(['break', 'case', 'catch', 'const',
+ 'continue', 'debugger', 'default', 'delete', 'do', 'else',
+ 'export', 'false', 'finally', 'for', 'function', 'if',
+ 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return',
+ 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined',
+ 'var', 'void', 'while', 'with', 'yield']);
+ }
+}
function defineDefaultCommands(repl) {
// TODO remove me after 0.3.x