Skip to content

Commit

Permalink
feat(synset): add .size
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Oct 5, 2022
1 parent 1a6642f commit f683788
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/Synset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ describe('Synset', () => {
});
});

describe('.size', () => {
it('should return lemma count', () => {
const synset = anEmptySynset();
expect(synset.size).toBe(0);
synset.add(new LemmaGroup());
synset.add(new LemmaGroup());
expect(synset.size).toBe(0);
synset.add(['some1', 'some2']);
expect(synset.size).toBe(2);
});
});

describe('.union()', () => {
it('should create a new synset with all the values', () => {
const synset1 = anEmptySynset().add(['a', 'b']);
Expand Down
4 changes: 4 additions & 0 deletions src/core/Synset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export class Synset {
return !!this.lemmas().next().done;
}

public get size(): number {
return [...this.lemmas()].length;
}

public union(
other: Synset,
equals: EqualityPredicate<Lemma> = valueEquals,
Expand Down

0 comments on commit f683788

Please sign in to comment.