From 9f3cfbe69d591d5aea9fc3aef34fc7f1d25eddbf Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sat, 5 May 2012 00:07:38 -0700 Subject: Favor composition over inheritence --- lib/completion.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib/completion.js') diff --git a/lib/completion.js b/lib/completion.js index a00f2dab..bc9b6fc6 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -145,18 +145,20 @@ var completion = (function() { }); /** A fuzzy history completer */ - var FuzzyHistoryCompletionSource = AsyncCompletionSource.extend({ + var FuzzyHistoryCompletionSource = Class.extend({ init: function(maxResults) { - this._super(); + this.asyncCompleter = new AsyncCompletionSource(); this.maxResults = maxResults; }, + filter: function(query, callback) { return this.asyncCompleter.filter(query, callback); }, + refresh: function() { - this.reset(); + this.asyncCompleter.reset(); historyCache.use(function(history) { - this.resultsReady(history.slice(-this.maxResults).map(function(item) { - return this.createInternalMatch("history", item); + this.asyncCompleter.resultsReady(history.slice(-this.maxResults).map(function(item) { + return this.asyncCompleter.createInternalMatch("history", item); }.proxy(this))); }.proxy(this)); } -- cgit v1.2.3