Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduction of random access reading #1183

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

Borewit
Copy link
Owner

@Borewit Borewit commented Nov 26, 2024

Introduce Random Access Support via supportsRandomAccess and IRandomAccessTokenizer

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

@Borewit Borewit self-assigned this Nov 26, 2024
@coveralls
Copy link

coveralls commented Nov 26, 2024

Coverage Status

coverage: 94.726% (-0.2%) from 94.894%
when pulling ccfec12 on feature-random-access-tokenizer
into 8b4f02b on master.

@Borewit Borewit force-pushed the feature-random-access-tokenizer branch from 3e14502 to ccfec12 Compare November 26, 2024 20:13
@Borewit Borewit changed the title Add extension for tokenizer for random access to media Introduction of random access reading Nov 26, 2024
@Borewit Borewit merged commit 15267d8 into master Nov 26, 2024
16 checks passed
@Borewit Borewit deleted the feature-random-access-tokenizer branch November 26, 2024 20:21
@Borewit
Copy link
Owner Author

Borewit commented Nov 26, 2024

Part of strtok3 version 9.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants