Add formatFileSize utility function - human readable byte sizes #54694
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.
Adds a new utility function to format byte sizes into human-readable strings (e.g., '1.5 KB', '2.3 MB').
This utility can be useful for displaying file sizes, download sizes, and other byte-based measurements in React Native applications.
Summary:
Adds a new utility function to format byte sizes into human-readable strings (e.g., "1.5 KB", "2.3 MB"). This utility can be useful for displaying file sizes, download sizes, and other byte-based measurements in React Native applications.
Changelog:
[GENERAL][ADDED] - Added formatFileSize utility function to format bytes into human-readable strings (KB, MB, GB, etc.)
Test Plan:
1. Unit Testing
Type Checking
Command:
yarn flowResults: No Flow errors - all type annotations correct
Linting
Command:
yarn lint(on formatFileSize files)Results: No linting errors - code follows React Native style guidelines
Integration Testing
Command:
yarn test --testPathPattern="Utilities.*test"Results: All 21 Utilities test suites pass (119 tests total)
Code Examples / Usage Verification
Command:
yarn test formatFileSizeResults:
Test Output:
2. Flow Type Checking
Command:
yarn flowResults:
3. Linting
Command:
yarn lint(on specific files)Results:
4. Integration Tests
Command:
yarn test --testPathPattern="Utilities.*test"Results:
5. Code Examples / Usage Verification
Since this is a utility function (not a UI component), here are code examples demonstrating usage:
Basic Usage:
Real-world Usage Example:
Screenshots / Visual Evidence
Since this is a utility function (not a UI component), there are no visual UI changes to screenshot. Instead, here's the evidence of functionality:
Test Output Screenshot
The test suite output demonstrates all functionality works correctly (see Test Execution section above).
Code Coverage
Manual Verification Steps