Skip to content

Commit

Permalink
fix: ensure correct seed validation
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, such as `0`, as missing, leading
to incorrect seed validation.

PR-URL: #3007
Closes: #2952
Reviewed-by: Athan Reines <kgryte@gmail.com>
  • Loading branch information
rishav2404 authored Oct 19, 2024
1 parent 04b72af commit 93560b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/node_modules/@stdlib/random/shuffle/lib/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var deepCopy = require( '@stdlib/utils/copy' );
var floor = require( '@stdlib/math/base/special/floor' );
var randu = require( '@stdlib/random/base/mt19937' ).factory;
var format = require( '@stdlib/string/format' );
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
var defaults = require( './defaults.json' );
var validate = require( './validate.js' );

Expand Down Expand Up @@ -63,7 +64,7 @@ function factory( config ) {
throw err;
}
}
if ( config && config.seed ) {
if ( config && hasOwnProp( config, 'seed' ) ) {
rand = randu({
'seed': config.seed
});
Expand Down

1 comment on commit 93560b9

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
random/shuffle $\color{green}354/354$
$\color{green}+100.00\%$
$\color{green}40/40$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}354/354$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.