feat(collections): add new collection APIs, iterator support, and tree serialization utilities

This commit is contained in:
2026-03-22 08:44:49 +00:00
parent 20182a00f8
commit f4db131ede
23 changed files with 2251 additions and 2657 deletions

View File

@@ -15,11 +15,51 @@ tap.test('should create an interest', async () => {
});
tap.test('should return an already existing interest', async () => {
await testInterestmap.addInterest(3);
const interest3a = await testInterestmap.addInterest(3);
const interest3b = await testInterestmap.addInterest(3);
expect(interest3a === interest3b).toBeTrue();
});
tap.test('should be able to inform about a lost interest', async () => {
testInterestmap.informLostInterest(3);
});
tap.test('checkInterest returns true for existing', async () => {
expect(testInterestmap.checkInterest(4)).toBeTrue();
});
tap.test('checkInterest returns false for non-existing', async () => {
expect(testInterestmap.checkInterest(999)).toBeFalse();
});
tap.test('findInterest returns the interest', async () => {
const interest = testInterestmap.findInterest(4);
expect(interest).not.toBeNull();
expect(interest.originalInterest).toEqual(4);
});
tap.test('findInterest returns null for non-existing', async () => {
const interest = testInterestmap.findInterest(888);
expect(interest).toBeNull();
});
tap.test('fullfillInterest resolves the promise', async () => {
const im = new lik.InterestMap<string, string>((s) => s);
const interest = await im.addInterest('hello');
interest.fullfillInterest('world');
const result = await interest.interestFullfilled;
expect(result).toEqual('world');
expect(interest.isFullfilled).toBeTrue();
im.destroy();
});
tap.test('destroy cleans up interestmap', async () => {
const im = new lik.InterestMap<string, string>((s) => s);
await im.addInterest('a');
await im.addInterest('b');
im.destroy();
expect(im.checkInterest('a')).toBeFalse();
expect(im.checkInterest('b')).toBeFalse();
});
export default tap.start();