modern-valhalla
Version:
Private npm repository server
26 lines (23 loc) • 542 B
JavaScript
/**
* Handle the packages search.
*/
class Search {
/**
* Performs a query to the db.
* If the keyword is a * it returns all local elements
* otherwise performs a search
* @param {String} q the keyword
* @return {Array} list of results.
*/
query(q) {
return q === '*' ? this.storage.get_local() : this.storage.search_local(q);
}
/**
* Set up the {Storage}
* @param {*} storage An instance of storage.
*/
configureStorage(storage) {
this.storage = storage;
}
}
module.exports = new Search();