Repository navigation
docs: update examples - #15677
docs: update examples#15677
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
Changed the example output label from `'Mean: %d'` to `'mean: %d'` in both the README `## Examples` block and `examples/index.js`, which the siblings keep byte-identical. 12 of the 13 `stats/iter/m*` packages label the iterated value with a lowercase quantity name, as do all 15 `stats/iter/cu*` packages (27 of 28 iterator-returning packages overall); `cumean`, which computes the same quantity, already uses `'mean: %d'`. The capitalized form matches the older reducer `stats/iter/mean` (`'Mean: %d.'`), from which it appears to have been copied; `mmax` and `mmin` did not inherit it from `max` and `min`. The reducers are left untouched, as they are split on capitalization and have no majority. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LRrCGN5Hzrrj2iRvLy42N9
bfe5669 to
f837335
Compare
stats/iter/cuhmean and example label in stats/iter/mmeanstats/iter/mmean
Dropped
|
| Package | Label |
|---|---|
stats/iter/cugmean |
'gmean: %d' |
stats/iter/cuhmean |
'hmean: %d' |
etc/eslint/rules/spellcheck.js has allowCompoundWords: true, which is why sibling labels such as 'meanabs: %d' and 'sumabs: %d' pass — they decompose into known words. A single-letter prefix does not compound, so gmean and hmean fail. Neither word is in the rule's words list, and the ignoreRegExpList entry for single-quoted strings (/'[-\w]+?'/g) does not apply because these strings contain :, a space, and %.
Proposed patch
Adding both to the words list in etc/eslint/rules/spellcheck.js would fix it, alongside the domain vocabulary already there (BLAS, clbk, dilogarithm, …). These are stdlib's own package names (stats/iter/cugmean, stats/incr/hmean, …):
'words': [
'BLAS',
'bonferroni',
'boop',
'clbk',
'congruential',
'convergents',
'coversed',
'dilogarithm',
+ 'gmean',
+ 'hmean',I have deliberately not pushed that here. It changes shared lint configuration for the whole repository rather than the package this PR is about, and node_modules is not installed in my environment, so I cannot run make lint-markdown-package-readme-files to verify it before pushing. It is a maintainer's call whether to accept these two words globally.
Once the wordlist carries them, the dropped cuhmean change is a one-liner worth restoring — its ## Notes bullet ends "handles such values accordingly" where the bullet enumerates only one value category (non-numeric, including NaN). 13 of the 14 cu* packages whose note covers only that category say "non-numeric values" (92.9%), and repo-wide the phrasing is 186 to 2. Applying it makes the bullet byte-identical to stats/iter/cumean's:
-- ... you are advised to provide an [`iterator`][mdn-iterator-protocol] which type checks and handles such values accordingly.
+- ... you are advised to provide an [`iterator`][mdn-iterator-protocol] which type checks and handles non-numeric values accordingly.stats/iter/cugmean should keep "such values" — its bullet covers non-numeric and negative values, so the generic referent is correct there.
Generated by Claude Code
stats/iter/mmean
Description
This pull request lowercases the example output label in
stats/iter/mmeanto match the convention used by every other iterator-returning package in the namespace.stats/iter/mmeanChanges the example output label from
console.log( 'Mean: %d', v.value );toconsole.log( 'mean: %d', v.value );in both the## Examplesblock ofREADME.mdandexamples/index.js, which siblings keep byte-identical. Lowercase quantity labels hold in 27 of the 28 iterator-returningstats/iterpackages (96.4%) — 12 of 13m*and all 15cu*— andstats/iter/cumean, which computes the same quantity, already prints'mean: %d'. The capitalized form matches the older reducerstats/iter/mean('Mean: %d.') and was copied from it;mmaxandmmindid not inherit capitalization frommaxandmin.The reducers (
stats/iter/mean,max,min, etc.) are left untouched: they split 6/7 on capitalization and have no majority. Two lines, cosmetic; no behavior change and no test expectations affected.examples/index.jswas run directly and exits 0.A second correction in
stats/iter/cuhmeanwas dropped from this pull request; see the comment below for the reason and a proposed patch.Related Issues
No.
Questions
No.
Other
See the comment below regarding a pre-existing spellchecker gap affecting
stats/iter/cugmeanandstats/iter/cuhmean.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This pull request was authored by Claude Code running as an automated cross-package consistency check over the
stats/iternamespace. The analysis, the edit, and this description were produced by Claude Code; the finding was reviewed by three independent agents before being applied, and the modified example was executed. No human had reviewed the change at the time of opening, which is why it was opened as a draft.🤖 Generated with Claude Code
https://claude.ai/code/session_01LRrCGN5Hzrrj2iRvLy42N9