Fix small correctness bugs in getters#59
Merged
Conversation
- 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>
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.
Summary
Four small, non-breaking correctness fixes in
src/index.jssurfaced 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-opif (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 usesok(defaultVal)directly.getAll:arrMapperdeclared akeysparameter but closed over the outeritems. Now uses the parameter as intended.mapNums: switched fromparseInttoparseFloatso list casting matchesgetNumber(which moved to float in 994d343). The unusedparsehelper 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')withXunset still returns the default URL object.get('X', null)withXunset returnsundefined(previously returnednull).getList('NUMS', { cast: 'number' })whereNUMS='1.5,2.5'now returns[1.5, 2.5]instead of[1, 2].getAll(['A', 'B'])still returns values in order.