diff options
| author | Bobby <[email protected]> | 2026-04-22 07:04:29 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2026-04-22 07:04:29 +0530 |
| commit | 9f0c3b0341d3ad29f3201d56fff5f19662a6f0b6 (patch) | |
| tree | e53e1adb1a87b8a0faa4ee9a808155c21c0ab83c /rng | |
| parent | 4dfbf7a13120b3b64521fce6de7d5d3f76cd2084 (diff) | |
| download | hollowdark-9f0c3b0341d3ad29f3201d56fff5f19662a6f0b6.tar.xz hollowdark-9f0c3b0341d3ad29f3201d56fff5f19662a6f0b6.zip | |
Use relative imports for same-directory siblings; split utils into folders
Two related cleanups landed together because they touch the same pattern:
1. Intra-module imports now use relative paths rather than the module's
own path alias. rng/seeded.ts imports from './derive', not 'rng/derive';
time/gameTime.ts from './calendar', not 'time/calendar'; the utils
barrel from './result' etc. This matches rules/01-code-style.md:
"Relative imports only for same-directory siblings." The alias form
is reserved for imports *between* modules — how external callers refer
to a module's public surface.
(The TS language server in the IDE had trouble resolving the self-
aliased form even though svelte-check accepted it; this change
removes the ambiguity.)
2. utils/ is now folder-per-concept. Each utility owns a directory with
its files broken up into small pieces:
utils/result/ types, constructors, predicates, map, unwrap
utils/assert/ assert, assert-never, assert-defined
utils/equal/ deep
utils/types/ brand, deep-readonly, element-of, json, non-empty-array
utils/log/ log
utils/index.ts re-exports from each subfolder via the barrel. External
callers import from 'utils' unchanged; internal references are relative.
One reason to prefer folders over flat files here is headroom — when a
concept grows, new files sit alongside their siblings inside the
concept's folder rather than crowding the utils/ root.
No API changes. All 128 tests still green.
Diffstat (limited to 'rng')
| -rw-r--r-- | rng/index.ts | 4 | ||||
| -rw-r--r-- | rng/seeded.ts | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/rng/index.ts b/rng/index.ts index fbc4251..b01e0dd 100644 --- a/rng/index.ts +++ b/rng/index.ts @@ -1,2 +1,2 @@ -export { createRNG, type SeededRNG } from 'rng/seeded' -export { hashString, deriveSeed } from 'rng/derive' +export { createRNG, type SeededRNG } from './seeded' +export { hashString, deriveSeed } from './derive' diff --git a/rng/seeded.ts b/rng/seeded.ts index 8aff2fb..52c4719 100644 --- a/rng/seeded.ts +++ b/rng/seeded.ts @@ -1,4 +1,4 @@ -import { deriveSeed, hashString } from 'rng/derive' +import { deriveSeed, hashString } from './derive' /** * Seeded PRNG. All gameplay randomness routes through this interface — |
