Skip to content

Commit f519e44

Browse files
author
Tyler Rockwood
committed
Run prettier on the code
1 parent 4090619 commit f519e44

File tree

4 files changed

+21
-24
lines changed

4 files changed

+21
-24
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Trie<T> {
5050
*
5151
* @param target the key and distinct to remove.
5252
*/
53-
remove(target: Pick<Item<never>, 'key'|'distinct'>) {
53+
remove(target: Pick<Item<never>, 'key' | 'distinct'>) {
5454
this.root.remove(target, 0);
5555
}
5656

src/node.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ class Node<T> {
138138
this.sorted = false;
139139
}
140140

141-
remove(target: Pick<Item<never>, 'key'|'distinct'>, index: number) {
141+
remove(target: Pick<Item<never>, 'key' | 'distinct'>, index: number) {
142142
if (this.leaf) {
143143
let max = 0;
144144
filterInPlace(this.values as Item<T>[], item => {
145-
const keep = item.key !== target.key || item.distinct !== target.distinct;
145+
const keep =
146+
item.key !== target.key || item.distinct !== target.distinct;
146147
if (keep) {
147148
max = Math.max(item.score, max);
148149
}
@@ -192,11 +193,7 @@ class Node<T> {
192193
* We use the passed in pqueue which has a limit and unique flag to
193194
* configure the search.
194195
*/
195-
getSortedResults(
196-
prefix: string,
197-
results: Array<T>,
198-
opts: SearchOptions,
199-
) {
196+
getSortedResults(prefix: string, results: Array<T>, opts: SearchOptions) {
200197
const seenKeys = new Set<string>();
201198

202199
if (this.leaf) {

test/randomized.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe('Trie Choas Monkey', () => {
157157
}
158158
case 'remove': {
159159
s.remove(op.key);
160-
t.remove({key: op.key});
160+
t.remove({ key: op.key });
161161
t.validateInvariants();
162162
break;
163163
}

test/trie.test.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ describe('Trie', () => {
257257
});
258258

259259
expect(t.prefixSearch('')).toEqual(['a', 'b']);
260-
t.remove({key: 'a'});
260+
t.remove({ key: 'a' });
261261
expect(t.prefixSearch('')).toEqual(['b']);
262262
expect(t.prefixSearch('b')).toEqual(['b']);
263263
expect(t.prefixSearch('a')).toEqual([]);
264-
t.remove({key: 'b'});
264+
t.remove({ key: 'b' });
265265
expect(t.prefixSearch('')).toEqual([]);
266266
expect(t.prefixSearch('b')).toEqual([]);
267267
expect(t.prefixSearch('a')).toEqual([]);
@@ -283,19 +283,19 @@ describe('Trie', () => {
283283
});
284284

285285
expect(t.prefixSearch('')).toEqual(['b', 'a']);
286-
t.remove({key: 'a'});
286+
t.remove({ key: 'a' });
287287
expect(t.prefixSearch('')).toEqual(['b']);
288288
t.add({
289289
key: 'a',
290290
score: 3,
291291
value: 'a',
292292
});
293293
expect(t.prefixSearch('')).toEqual(['a', 'b']);
294-
t.remove({key: 'a'});
294+
t.remove({ key: 'a' });
295295
});
296296

297297
it('distinct limit bug', () => {
298-
const t = new StrictTrie({maxWidth: 1});
298+
const t = new StrictTrie({ maxWidth: 1 });
299299
t.add({
300300
key: 'a',
301301
score: 1,
@@ -314,24 +314,24 @@ describe('Trie', () => {
314314
value: 'c',
315315
distinct: '2',
316316
});
317-
expect(t.prefixSearch("", {limit: 2, unique: true})).toEqual(['a', 'c']);
317+
expect(t.prefixSearch('', { limit: 2, unique: true })).toEqual(['a', 'c']);
318318
});
319319

320320
it('removes exact distinct matches', () => {
321-
const t = new StrictTrie({maxWidth: 1});
321+
const t = new StrictTrie({ maxWidth: 1 });
322322
t.add({
323323
key: 'a',
324324
score: 1,
325325
value: 'a',
326326
distinct: '1',
327327
});
328-
t.remove({key: 'a'})
329-
expect(t.prefixSearch("")).toEqual(['a']);
330-
t.remove({key: 'a', distinct: '2'})
331-
expect(t.prefixSearch("")).toEqual(['a']);
332-
t.remove({key: 'b', distinct: '1'})
333-
expect(t.prefixSearch("")).toEqual(['a']);
334-
t.remove({key: 'a', distinct: '1'})
335-
expect(t.prefixSearch("")).toEqual([]);
328+
t.remove({ key: 'a' });
329+
expect(t.prefixSearch('')).toEqual(['a']);
330+
t.remove({ key: 'a', distinct: '2' });
331+
expect(t.prefixSearch('')).toEqual(['a']);
332+
t.remove({ key: 'b', distinct: '1' });
333+
expect(t.prefixSearch('')).toEqual(['a']);
334+
t.remove({ key: 'a', distinct: '1' });
335+
expect(t.prefixSearch('')).toEqual([]);
336336
});
337337
});

0 commit comments

Comments
 (0)