Skip to content

Commit 57ac3dd

Browse files
committed
Serialize distribution parameters
1 parent 992793a commit 57ac3dd

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

lib/node_modules/@stdlib/random/base/bernoulli/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Serializes the pseudorandom number generator as a JSON object.
251251

252252
```javascript
253253
var o = bernoulli.toJSON();
254-
// returns { 'type': 'PRNG', 'name': '...', 'state': {...} }
254+
// returns { 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
255255
```
256256

257257
</section>

lib/node_modules/@stdlib/random/base/bernoulli/docs/repl.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
Examples
163163
--------
164164
> var o = {{alias}}.toJSON()
165-
{ 'type': 'PRNG', 'name': '...', 'state': {...} }
165+
{ 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
166166

167167
See Also
168168
--------

lib/node_modules/@stdlib/random/base/bernoulli/lib/factory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,11 @@ function factory() {
186186
out.type = 'PRNG';
187187
out.name = prng.NAME;
188188
out.state = typedarray2json( rand.state );
189+
if ( p === void 0 ) {
190+
out.params = [];
191+
} else {
192+
out.params = [ p ];
193+
}
189194
return out;
190195
}
191196

lib/node_modules/@stdlib/random/base/bernoulli/test/test.factory.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ tape( 'attached to the returned function is a method to serialize the generator
450450
t.equal( o.name, bernoulli.NAME, 'has property' );
451451
t.deepEqual( o.state, typedarray2json( bernoulli.state ), 'has property' );
452452

453+
bernoulli = factory( 0.5 );
454+
o = bernoulli.toJSON();
455+
456+
t.deepEqual( o.params, [ 0.5 ], 'has property' );
457+
453458
t.end();
454459
});
455460

0 commit comments

Comments
 (0)