Introduction of random access reading #1183
Merged
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.
Introduce Random Access Support via
supportsRandomAccess
andIRandomAccessTokenizer
This pull request enhances the strtok3 library by adding support for random access reading, a significant improvement for scenarios requiring non-sequential data access. The core of this update is the introduction of:
supportsRandomAccess
Method:This method provides a way to determine whether a given tokenizer supports random access, offering developers clarity and control over tokenization strategies.
IRandomAccessTokenizer
Interface:A new interface type specifically designed for tokenizers that allow random access to data, enabling developers to implement or extend tokenizers with advanced reading capabilities.
Key Benefits
Random Access Reading: Facilitates efficient handling of files where data needs to be read or processed in non-linear sequences.
Enhanced API Design: Introduces a clear distinction between sequential and random-access tokenizers, improving type safety and extensibility.
Flexibility: Enables broader use cases, such as working with large files, network streams, or complex data formats that benefit from selective data access.
Motivation
The addition of random access support aligns with the need for more versatile file-processing capabilities, as seen in related discussions around file-type detection and malformed file handling. This feature is particularly useful for integrating with applications requiring adaptive or performance-optimized reading strategies.
Allow random access to the underlying media, if the underlying media supports it.
Related to sindresorhus/file-type#688