Skip to content

Commit

Permalink
fix(random): handle seed initialization correctly
Browse files Browse the repository at this point in the history
The previous implementation used a direct property check (`config.seed`),
which could inadvertently treat falsy values like "0" as missing. This
caused incorrect random seed initialization in some cases.

Changed the condition to explicitly check for the presence of the `seed`
property using `Object.prototype.hasOwnProperty.call()`. Now, seed
initialization handles falsy but valid seed values correctly.
  • Loading branch information
rishav2404 committed Oct 13, 2024
1 parent c0a5dbe commit c4ca4a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/random/shuffle/lib/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function factory( config ) {
throw err;
}
}
if ( config && config.seed ) {
if ( config && Object.prototype.hasOwnProperty.call( config, 'seed' ) ) {
rand = randu({
'seed': config.seed
});
Expand Down

0 comments on commit c4ca4a7

Please sign in to comment.