-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededonlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source week
Description
Feature: Enhanced Lazy Evaluation
Extend lazy evaluation capabilities beyond the current use method to support more complex scenarios.
Current State
The library already has a use() method that enables lazy evaluation for circular references and complex relationships. This feature would enhance and extend these capabilities.
Proposed Features
-
Enhanced
lazymethod with field dependencies- Allow specifying which fields trigger re-evaluation
- Support for conditional dependencies
-
Async lazy evaluation support
- Handle promises in lazy evaluation
- Maintain type safety with async operations
-
Conditional lazy evaluation
- Evaluate only when certain conditions are met
- Support for predicate functions
-
Proper type inference
- Preserve TypeScript type inference throughout
- No degradation of type safety
Implementation Requirements
- Build upon existing
use()method infrastructure - Maintain backward compatibility
- Ensure TypeScript type inference is preserved
- Consider integration with circular reference handling
- Add comprehensive tests for all new lazy evaluation patterns
Example API
// Field dependencies
const factory = new Factory<User>((faker) => ({
id: faker.string.uuid(),
name: faker.person.fullName(),
email: factory.lazy((user) => `${user.name.toLowerCase().replace(' ', '.')}@example.com`, ['name'])
}));
// Async lazy evaluation
const factory = new Factory<User>((faker) => ({
id: faker.string.uuid(),
apiKey: factory.lazyAsync(async (user) => await generateApiKey(user.id))
}));
// Conditional lazy evaluation
const factory = new Factory<Order>((faker) => ({
status: faker.helpers.arrayElement(['pending', 'completed', 'cancelled']),
completedAt: factory.lazyIf(
(order) => order.status === 'completed',
() => faker.date.recent()
)
}));Testing Requirements
- Unit tests for each lazy evaluation pattern
- Type-level tests to ensure inference works correctly
- Performance tests for complex lazy evaluation chains
- Integration tests with existing
use()method
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is neededonlydust-waveContribute to awesome OSS repos during OnlyDust's open source weekContribute to awesome OSS repos during OnlyDust's open source week