Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
[debugger] optimize context's properties initialization, make 'list' …
Browse files Browse the repository at this point in the history
…a function, not a getter
  • Loading branch information
indutny authored and ry committed Sep 21, 2011
1 parent 3148f14 commit 79fd1f7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/_debugger.js
Expand Up @@ -737,13 +737,16 @@ function Interface() {

function defineProperty(key, protoKey) {
// Check arity
var fn = proto[protoKey].bind(self);

if (proto[protoKey].length === 0) {
Object.defineProperty(self.repl.context, key, {
get: proto[protoKey].bind(self),
enumerable: true
get: fn,
enumerable: true,
configurable: false
});
} else {
self.repl.context[key] = proto[protoKey].bind(self);
self.repl.context[key] = fn;
}
};

Expand Down Expand Up @@ -1021,12 +1024,13 @@ Interface.prototype.version = function() {
};

// List source code
Interface.prototype.list = function() {
Interface.prototype.list = function(delta) {
if (!this.requireConnection()) return;

delta || (delta = 5);

var self = this,
client = this.client,
delta = arguments[0] || 5,
from = client.currentSourceLine - delta + 1,
to = client.currentSourceLine + delta + 1;

Expand Down

0 comments on commit 79fd1f7

Please sign in to comment.