Skip to content

Commit 7f7263e

Browse files
committed
Fix option handling bug
1 parent 429f4cb commit 7f7263e

File tree

1 file changed

+10
-4
lines changed
  • lib/node_modules/@stdlib/random/base/improved-ziggurat/lib

1 file changed

+10
-4
lines changed

lib/node_modules/@stdlib/random/base/improved-ziggurat/lib/factory.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function factory( options ) {
7272
var randn;
7373
var state;
7474
var seed;
75+
var copy;
7576
if ( arguments.length ) {
7677
if ( !isObject( options ) ) {
7778
throw new TypeError( 'invalid argument. Must provide an object. Value: `' + options + '`.' );
@@ -102,26 +103,31 @@ function factory( options ) {
102103
}
103104
}
104105
}
106+
copy = ( options && options.copy === false ) ? options.copy : true;
105107
if ( state === void 0 ) {
106108
if ( randu === void 0 ) {
107109
if ( seed === void 0 ) {
108-
randi = mt19937();
110+
randi = mt19937({
111+
'copy': copy
112+
});
109113
} else {
110114
randi = mt19937({
111-
'seed': seed
115+
'seed': seed,
116+
'copy': copy
112117
});
113118
}
114119
randu = randi.normalized;
115120
} else {
116121
randi = mt19937({
117-
'seed': floor( 1.0 + ( UINT32_MAX*randu() ) ) // allows seeding via an externally seeded PRNG
122+
'seed': floor( 1.0 + ( UINT32_MAX*randu() ) ), // allows seeding via an externally seeded PRNG
123+
'copy': copy
118124
});
119125
seed = null;
120126
}
121127
} else {
122128
randi = mt19937({
123129
'state': state,
124-
'copy': ( options.copy === void 0 ) ? true : options.copy
130+
'copy': copy
125131
});
126132
randu = randi.normalized;
127133
}

0 commit comments

Comments
 (0)