Conversation
Extract #freezeResult(), #fromCache(), and #toCache() private helpers to eliminate repeated Object.freeze return patterns across 10+ methods. Consolidate #getIndexKeys and #getIndexKeysForWhere into a single parametrized #getIndexKeysFrom method (2 methods → 1, removing 62 lines of duplicate code).
Add 'should recreate index after clear on same store' test to achieve 100% line coverage across haro.js.
- Remove clone(), freeze(), merge() from public API (all are private) - Add Internal Helper Methods section documenting #freezeResult, #fromCache, #toCache, #getIndexKeysFrom - Update Immutability Model to reference centralized #freezeResult() - Update cache mutation protection to reference #fromCache/#toCache - Clarify internal vs public utility methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#freezeResult(),#fromCache(),#toCache()helpers; consolidate#getIndexKeys+#getIndexKeysForWhere→#getIndexKeysFrom()(212 lines removed, -50% duplicate code)clear()→set()state transition achieving 100% line coverageChanges
src/haro.js (-293, +188)
#freezeResult(result)- Centralizes allObject.freeze()returns (10+ methods)#fromCache(cached)- Unified cache-read clone/freeze pattern forsearch()/where()#toCache(cacheKey, records)- Unified cache-write forsearch()/where()#getIndexKeysFrom(arg, source, getValueFn)- Consolidates index key generation with getter callback#getIndexKeysand#getIndexKeysForWhere(duplicated logic)tests/unit/crud.test.js (+1 test)
clear()→set()on same store triggers lazy index recreation branchsrc/constants.js (no change, 100% coverage maintained)
docs/
clone()/freeze()/merge()from public API; added Internal Helper Methods sectioncoverage.txt
Testing
Commits (4)
4dba4f5— DRY refactoring helpers and consolidate getIndexKeysdfd268f— Coverage fix: test clear() → set() index recreatione6eadd2— AGENTS.md expansion with helpers, patterns, strategy2bdf030— API and technical docs update