diff --git a/src/core/Synset.test.ts b/src/core/Synset.test.ts index 71239d0..3bbb07d 100644 --- a/src/core/Synset.test.ts +++ b/src/core/Synset.test.ts @@ -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']); diff --git a/src/core/Synset.ts b/src/core/Synset.ts index 726c9fa..08e9cdf 100644 --- a/src/core/Synset.ts +++ b/src/core/Synset.ts @@ -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 = valueEquals,