Skip to content

Conversation

@konard
Copy link
Member

@konard konard commented Jan 13, 2026

Summary

Implement the in-memory storage backend for JavaScript/TypeScript that implements the LinkStore interface from issue #7.

Features

  • O(1) lookups by ID using JavaScript Map
  • Link deduplication - identical source/target pairs share the same ID
  • Pattern matching with wildcard queries via Any symbol
  • Async API for consistency with other backends
  • Universal links support with additional values
  • AsyncIterable iteration over matching links
  • Clear method to reset the store

Implementation Details

File Description
src/backends/memory.js Main MemoryLinkStore class implementation
src/backends/memory.d.ts TypeScript type definitions
src/index.js, src/index.d.ts Export from main package entry point
tests/memory.test.js 105 comprehensive unit tests
tests/memory.benchmark.js Performance validation benchmarks

API Example

import { MemoryLinkStore, Any } from 'links-queue-js';

const store = new MemoryLinkStore();

// Create a link
const link = await store.create('hello', 'world');
console.log(link); // { id: 1, source: 'hello', target: 'world' }

// Find links
const results = await store.find({ source: 'hello', target: Any });

// Deduplication - returns existing link
const duplicate = await store.create('hello', 'world');
console.log(duplicate.id === link.id); // true

Performance Benchmarks

Operation Throughput
get by ID > 8M ops/sec
exists check > 10M ops/sec
count (all links) > 7M ops/sec
create (new) > 1M ops/sec
create (deduplicated) > 1.6M ops/sec
update > 898K ops/sec
find (pattern) > 27K ops/sec
iterate (first 100) > 97K ops/sec

Test Coverage

105 tests covering:

  • Constructor and initialization
  • Create operations (basic, with values, deduplication)
  • Get operations
  • Exists checks
  • Find with pattern matching (source, target, id, Any wildcard)
  • Count operations
  • Update operations (including error handling)
  • Delete operations (single and matching)
  • Iterate operations
  • Clear operations
  • Edge cases (empty strings, zero, negative numbers, bigints, nested links, concurrent operations)

Dependencies

Closes

Fixes #8


🤖 Generated with Claude Code

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #8
@konard konard self-assigned this Jan 13, 2026
Implement the in-memory storage backend for JavaScript/TypeScript
that implements the LinkStore interface from issue #7.

Features:
- O(1) lookups by ID using JavaScript Map
- Link deduplication (identical source/target pairs share same ID)
- Pattern matching with wildcard queries via Any symbol
- Async API for consistency with other backends
- Support for universal links with additional values
- AsyncIterable iteration over matching links
- Clear method to reset the store

Implementation details:
- src/backends/memory.js: Main MemoryLinkStore class implementation
- src/backends/memory.d.ts: TypeScript type definitions
- Export from main package entry point (index.js and index.d.ts)

Tests:
- tests/memory.test.js: 105 comprehensive unit tests covering all
  CRUD operations, deduplication, pattern matching, edge cases
- tests/memory.benchmark.js: Performance validation tests showing:
  - O(1) operations (get, exists, count) > 7M ops/sec
  - Pattern matching operations > 14K ops/sec

Closes #8

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard konard changed the title [WIP] [Phase 1] Implement in-memory LinkStore backend (JavaScript) [Phase 1] Implement in-memory LinkStore backend (JavaScript) Jan 13, 2026
@konard konard marked this pull request as ready for review January 13, 2026 21:25
konard and others added 2 commits January 13, 2026 22:31
Remove beforeEach pattern and use helper functions that create fresh
store instances per test. This fixes test isolation issues in Deno
where beforeEach hooks were not properly scoping, causing shared state
between tests.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@konard
Copy link
Member Author

konard commented Jan 13, 2026

⚠️ Solution Draft Finished with Errors

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Public pricing estimate: $7.355044 USD
  • Calculated by Anthropic: $0.000000 USD
  • Difference: $-7.355044 (-100.00%)

Note: The session encountered errors during execution, but some work may have been completed. Please review the changes carefully.

📎 Log file uploaded as Gist (960KB)
🔗 View complete solution draft log

Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Phase 1] Implement in-memory LinkStore backend (JavaScript)

2 participants