feat: Add sync module, refactor core module, update build#12
Merged
feat: Add sync module, refactor core module, update build#12
Conversation
- Fixed the `LsTypesValues` type definition to iterate through `LsTypesInterface` interface to get the values instead of `keyof typeof LsTypesInterface` - Improved the `ResolvedLsOptions` and keeping the `exclude` property to have `undefined` type exclusively - Removed redundant and unnecessary type casting in core (`lsfnd`) module - Improved all types (including functions' parameters) within core module In addition, this change also make all `ls*` functions (`ls`, `lsDirs`, and `lsFiles`) to support to use `lsTypes` keys (string) or values (numbers) with stable and will throws an error if specified any unknown values (not including nullable values).
- Fixed unresolved type for `match` and `exclude` options - Updated the `resolveOptions` util function to accept RegExp also for more convenience when being used - Added special case with value 0 for case `LS_A`, it will behaves similar to `LS_A` and list both files and directories - Several code improvements
- Migrated all utility functions to new `utils` module - Moved all constants from core module to new `constants` module
The code inside are mirroring to the core module (`lsfnd.ts`) with some adjustments for synchronous operations.
- Added test modules `lsfnd-sync.spec.cjs` and `lsfnd-sync.spec.mjs` - Readjusted the expected values within the existing test modules - Updated the `test:cjs` and `test:mjs` scripts within `package.json` to include and run the new test modules
- Updated the `tsconfig.production.json` to preserve comments for
transpiled files
- Added `scripts/postbuild` module
- Added `removeMultilineCommentsAfterUseStrict` function to remove the
module's header comment
- Removed the APIs type implementation from `types/index` module
- Added `postbuild` script to `package.json` executing the
`scripts/postbuild` module
With this change, we can guarantee the APIs are now will appears along
with the documentation when used with Intellisense.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This branch reshapes several parts of the project: the core module is reorganized, type definitions are corrected, a synchronous variant of the library is introduced, and the build process gains a postbuild cleanup phase. Documentation and tests have been adjusted to match the new structure. The goal is to tighten the internal design while making the API surface more predictable for users and Intellisense.
Introduce New Sync Module
Synchronous version of LSFND has been implemented. Users can imports them from
/syncsubmodule oflsfnd. For example:Changes Made
scripts/postbuildmodule, including theremoveMultilineCommentsAfterUseStrictutility.types/index.postbuildscript topackage.json.lsfnd-syncmodule, including CJS and ESM variants.lsfnd-syncmodule, a synchronous counterpart to the core module with code adapted appropriately.utilsmodule and constants into a newconstantsmodule.matchandexclude, enhancingresolveOptionsto acceptRegExp, and adding a special case forLS_Awhen passed0.LsTypesValuestype, strengtheningResolvedLsOptions, and removing redundant casts.ls*functions to guaranteed accept both string keys and numeric values fromlsTypes, throwing errors on unknown values.Impact
The internal structure becomes clearer and easier to maintain. Type safety improves across the board, reducing silent inconsistencies and making the API more predictable. The synchronous module fills a long-standing gap for environments where async behavior is less desirable. Tooling improvements ensure the output retains necessary comments while removing module-generated clutter. Developers will get cleaner IntelliSense results with better documentation visibility.
Summary
This update pulls several threads together: reorganized internals, corrected types, a new synchronous API, an improved build pipeline, and refined tests. The project becomes more coherent without changing its fundamental behavior.