Types exiliary files
This commit is contained in:
parent
63f78b0808
commit
5c9398a6b1
5 changed files with 449 additions and 423 deletions
|
@ -45,7 +45,7 @@ interface IOptions<T extends {}> {
|
|||
* @param {function[]} options.funcs List of functions that when called with the
|
||||
* object as an arg will return a string to use as an index
|
||||
*/
|
||||
export default class QueryMatcher<T> {
|
||||
export default class QueryMatcher<T extends Object> {
|
||||
private _options: IOptions<T>;
|
||||
private _keys: IOptions<T>["keys"];
|
||||
private _funcs: Required<IOptions<T>["funcs"]>;
|
||||
|
@ -75,7 +75,10 @@ export default class QueryMatcher<T> {
|
|||
this._items = new Map();
|
||||
|
||||
for (const object of objects) {
|
||||
const keyValues = _at(object, this._keys);
|
||||
// Need to use unsafe coerce here because the objects can have any
|
||||
// type for their values. We assume that those values who's keys have
|
||||
// been specified will be string.
|
||||
const keyValues: (string)[] = _at<T>(object as any, this._keys) as any;
|
||||
|
||||
for (const f of this._funcs) {
|
||||
keyValues.push(f(object));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue