MCPcopy Index your code
hub / github.com/nodejs/node / resetContext

Method resetContext

lib/repl.js:1180–1217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1178 return context;
1179 }
1180 resetContext() {
1181 this.context = this.createContext();
1182 this.underscoreAssigned = false;
1183 this.underscoreErrAssigned = false;
1184 // TODO(BridgeAR): Deprecate the lines.
1185 this.lines = [];
1186 this.lines.level = [];
1187
1188 ObjectDefineProperty(this.context, '_', {
1189 __proto__: null,
1190 configurable: true,
1191 get: () => this.last,
1192 set: (value) => {
1193 this.last = value;
1194 if (!this.underscoreAssigned) {
1195 this.underscoreAssigned = true;
1196 this.output.write('Expression assignment to _ now disabled.\n');
1197 }
1198 },
1199 });
1200
1201 ObjectDefineProperty(this.context, '_error', {
1202 __proto__: null,
1203 configurable: true,
1204 get: () => this.lastError,
1205 set: (value) => {
1206 this.lastError = value;
1207 if (!this.underscoreErrAssigned) {
1208 this.underscoreErrAssigned = true;
1209 this.output.write(
1210 'Expression assignment to _error now disabled.\n');
1211 }
1212 },
1213 });
1214
1215 // Allow REPL extensions to extend the new context
1216 this.emit('reset', this.context);
1217 }
1218 displayPrompt(preserveCursor) {
1219 let prompt = this._initialPrompt;
1220 if (this[kBufferedCommandSymbol].length) {

Callers 5

constructorMethod · 0.80
defineDefaultCommandsFunction · 0.80
testResetFunction · 0.80
testResetGlobalFunction · 0.80

Calls 3

createContextMethod · 0.95
writeMethod · 0.45
emitMethod · 0.45

Tested by

no test coverage detected