UNPKG

als-store

Version:

Library for streamlined file management and advanced data caching, featuring intelligent file searching, dynamic cache control, and flexible file operations

28 lines (20 loc) 1.89 kB
### File Name Conversion in the `File` Class of `als-store` #### Schema Dependency - **Conditional Conversion**: The sophisticated file name conversion process is triggered only when a schema is provided. In the absence of a schema, files are saved with their original names without undergoing this conversion. #### Handling Complex Data - **Conversion Logic**: Complex data types (like numbers, strings, objects) are encoded into a string format that complies with file naming standards. - **Special Cases Handling**: Specific values such as `undefined`, `null`, and `NaN` are converted to recognizable string representations. #### Operating System Constraints - **Windows Restrictions**: Windows has specific rules for file names, disallowing certain characters and reserved names. - **Conversion on Windows**: - Illegal characters are replaced with `_x` followed by their ASCII hex code. - Reserved names are transformed using `_r` and a hex-encoded representation of each character. #### Cross-platform Compatibility - **Uniform Handling**: Ensures consistent handling across different platforms, including Linux and macOS. - **Dot Handling**: Dots (`.`), often used in file extensions, are replaced with `[.]` to maintain clarity. #### Reversibility of the Process - **Decoding**: The conversion process is reversible, allowing the original data to be reconstructed from the file name by reversing the encoding steps. #### Practical Applications - **Schema-Based File Naming**: Facilitates storing structured data in file names, enabling a seamless mapping between data and valid file names. - **Data Integrity and Accessibility**: Maintains data integrity and accessibility across platforms by ensuring valid and meaningful file names. - **Automated Process**: The entire conversion is handled automatically, abstracting complexities from the user.