Skip to content

Commit 9e97a03

Browse files
committed
add support on search wildcard
1 parent 0eec6d4 commit 9e97a03

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/repository.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,23 @@ repository.prototype.getByName = function(type, name, limit) {
170170
return this.db.resolve(result);
171171
};
172172

173+
174+
/**
175+
* Lookup at each file and retrieves named elements
176+
* @param {String} type
177+
* @param {Number} limit
178+
* @return {node[]} {@link NODE.md|:link:}
179+
*/
180+
repository.prototype.searchByName = function(type, name, limit) {
181+
var criteria = {};
182+
criteria[type] = name + '%';
183+
var result = this.db.search(criteria);
184+
if (result.length > limit) {
185+
result = result.slice(0, limit);
186+
}
187+
return this.db.resolve(result);
188+
};
189+
173190
/**
174191
* Lookup at each file and retrieves named elements
175192
* @param {String} type

0 commit comments

Comments
 (0)