Prototype is a good way, in alternative this is the pattern I use:
var QueryPreprocessing = {
init: function () {
return this;
}, // set config variables for closures here
var initparam = 'whatever';
return {
removeStopWords: function (query) {
//code here
},
stemmer: function (w) {
//code here
},
convertBoolean: function (w) {
//code here
}
}
}
var qp = QueryPreprocessing.init();
qp.removeStopWord('thequerystring');
//...