Skip to content

Fix small correctness bugs in getters#59

Merged
recursivefunk merged 1 commit into
mainfrom
jra/getter-bug-fixes
Apr 22, 2026
Merged

Fix small correctness bugs in getters#59
recursivefunk merged 1 commit into
mainfrom
jra/getter-bug-fixes

Conversation

@recursivefunk

Copy link
Copy Markdown
Owner

Summary

Four small, non-breaking correctness fixes in src/index.js surfaced while reading the code. Each is an existing bug that happens to be inert in current test paths. Bumps patch to 7.6.3.

Changed Files

  • src/index.js — four getter fixes:
    • getUrl: removed a no-op if (urlStr === defaultVal) { urlStr = defaultVal } block.
    • get: typeof ok(defaultVal) always produced the truthy string 'boolean', so falsy defaults (null, 0, '') were being substituted for missing values. Now uses ok(defaultVal) directly.
    • getAll: arrMapper declared a keys parameter but closed over the outer items. Now uses the parameter as intended.
    • mapNums: switched from parseInt to parseFloat so list casting matches getNumber (which moved to float in 994d343). The unused parse helper was removed.
  • package.json — version 7.6.2 → 7.6.3.

Steps to Verify

  • npm test — all 98 tests pass, 100% line coverage holds.
  • getUrl('X', 'https://example.com') with X unset still returns the default URL object.
  • get('X', null) with X unset returns undefined (previously returned null).
  • getList('NUMS', { cast: 'number' }) where NUMS='1.5,2.5' now returns [1.5, 2.5] instead of [1, 2].
  • getAll(['A', 'B']) still returns values in order.

- getUrl: remove no-op reassignment to defaultVal
- get: fix typo (`typeof ok(defaultVal)` always truthy) so falsy defaults
  are no longer incorrectly substituted for missing values
- getAll: arrMapper now uses its `keys` parameter instead of the outer
  `items` it was closing over
- mapNums: switch from parseInt to parseFloat so list casting matches
  getNumber (aligned after 994d343)

Bumps patch to 7.6.3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@recursivefunk recursivefunk self-assigned this Apr 22, 2026
@recursivefunk recursivefunk merged commit 073ef40 into main Apr 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant