Skip to content

Commit c11f291

Browse files
committed
Serialize distribution parameters
1 parent b0cf7a1 commit c11f291

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

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

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

245245
```javascript
246246
var o = t.toJSON();
247-
// returns { 'type': 'PRNG', 'name': '...', 'state': {...} }
247+
// returns { 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
248248
```
249249

250250
</section>

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

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

168168
See Also
169169
--------

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ function factory() {
249249
out.type = 'PRNG';
250250
out.name = prng.NAME;
251251
out.state = typedarray2json( rand.state );
252+
if ( v === void 0 ) {
253+
out.params = [];
254+
} else {
255+
out.params = [ v ];
256+
}
252257
return out;
253258
}
254259

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,12 @@ tape( 'attached to the returned function is a method to serialize the generator
594594
t.equal( o.type, 'PRNG', 'has property' );
595595
t.equal( o.name, rt.NAME, 'has property' );
596596
t.deepEqual( o.state, typedarray2json( rt.state ), 'has property' );
597+
t.deepEqual( o.params, [], 'has property' );
598+
599+
rt = factory( 9.0 );
600+
o = rt.toJSON();
601+
602+
t.deepEqual( o.params, [ 9.0 ], 'has property' );
597603

598604
t.end();
599605
});

0 commit comments

Comments
 (0)