Skip to content

Conversation

@r-el
Copy link
Owner

@r-el r-el commented Sep 11, 2025

Summary

This PR adds full Promise-based API support alongside the existing callback-based methods.

Changes

New Features

  • Promise API: All CRUD methods now have async counterparts (createAsync, readAllAsync, etc.)
  • Async/Await Support: Modern async/await syntax support
  • TypeScript Integration: Updated type definitions for Promise methods

Implementation

  • Added async-wrapper.js utility for converting callback methods to Promises
  • Updated main class to include async methods in constructor
  • Created comprehensive test suite for async operations
  • Added async usage example (async-demo.js)

Documentation

  • Updated README with Promise API documentation
  • Added async/await usage examples
  • Updated feature list to include Promise support

Testing

  • All existing tests pass
  • New async test suite with 10 comprehensive tests
  • All examples work correctly

Breaking Changes

None - this is fully backward compatible.

Examples

// New async API
const user = await db.createAsync({ name: 'John', age: 30 });
const users = await db.readAllAsync();
await db.updateAsync(user.id, { age: 31 });
await db.deleteAsync(user.id);

// Original callback API still works
db.create({ name: 'Jane' }, (err, user) => {
  // callback implementation
});

Commits

  • Add async wrapper utilities for JsonFileCRUD with Promise-based API
  • Add async method variants to JsonFileCRUD for improved usability
  • Add callback-based methods to JsonFileCRUD interface for improved functionality
  • Add async demo example to showcase Promise-based API usage
  • Add async tests for JsonFileCRUD methods to validate functionality
  • Add async/await usage examples to README for enhanced clarity
  • Update CHANGELOG.md for version 1.3.0: Add async/await API support and enhanced examples
  • Update package.json for version 1.3.0: Add async tests and examples to improve coverage and clarity
  • Add Promise-based API section to README with async method examples

@r-el r-el merged commit 1bc9080 into master Sep 11, 2025
6 checks passed
@r-el r-el deleted the feature/async-api branch September 11, 2025 09:21
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.

2 participants