Skip to content

docs(helpers): document weightedArrayElement throws - #4016

Merged
ST-DDT merged 1 commit into
faker-js:nextfrom
nityanand123gupta:docs-weightedarrayelement-throws
Aug 30, 2026
Merged

ST-DDT merged 1 commit into
faker-js:nextfrom
nityanand123gupta:docs-weightedarrayelement-throws

Conversation

@nityanand123gupta

Copy link
Copy Markdown
Contributor

Description

faker.helpers.weightedArrayElement can throw FakerError in two cases but had no @throws JSDoc, per the contributing guidelines requirement that throwing functions document it:

https://github.com/faker-js/faker/blob/next/CONTRIBUTING.md?plain=1#L362

Change

Added @throws tags for both real throw conditions in the implementation:

  • empty array
  • any element with a non-positive weight

Fixes #4015

@nityanand123gupta
nityanand123gupta requested a review from a team as a code owner August 29, 2026 20:28
@netlify

netlify Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for fakerjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bcf1d58
🔍 Latest deploy log https://app.netlify.com/projects/fakerjs/deploys/6a9341012ce144000850f01d
😎 Deploy Preview https://deploy-preview-4016.fakerjs.dev
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@xDivisionByZerox xDivisionByZerox added the c: docs Improvements or additions to documentation label Aug 29, 2026
@ST-DDT ST-DDT added p: 1-normal Nothing urgent m: helpers Something is referring to the helpers module labels Aug 30, 2026
@ST-DDT ST-DDT modified the milestones: v11.x, v11.0 Aug 30, 2026
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.98%. Comparing base (bbd1693) to head (bcf1d58).

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #4016   +/-   ##
=======================================
  Coverage   98.98%   98.98%           
=======================================
  Files         926      926           
  Lines        3246     3246           
  Branches      582      569   -13     
=======================================
  Hits         3213     3213           
  Misses         29       29           
  Partials        4        4           
Files with missing lines Coverage Δ
src/modules/helpers/module.ts 94.84% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ST-DDT
ST-DDT added this pull request to the merge queue Aug 30, 2026
Merged via the queue into faker-js:next with commit 25ac6ef Aug 30, 2026
26 checks passed
@nityanand123gupta

Copy link
Copy Markdown
Contributor Author

Thanks for reviewing and merging this! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: docs Improvements or additions to documentation m: helpers Something is referring to the helpers module p: 1-normal Nothing urgent

Projects

None yet

Development

Successfully merging this pull request may close these issues.

weightedArrayElement does not mention the possibility to throw in it's docs

4 participants