From 4b7f882c80b434c929ad62e7fb12d25e5c6f10aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 26 Jul 2023 21:53:01 +0000 Subject: [PATCH] Auto-generated commit --- streams/binomial/lib/factory.js | 9 +++++++++ streams/cauchy/lib/factory.js | 9 +++++++++ streams/chi/lib/factory.js | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/streams/binomial/lib/factory.js b/streams/binomial/lib/factory.js index bca2a159..35e7b110 100644 --- a/streams/binomial/lib/factory.js +++ b/streams/binomial/lib/factory.js @@ -20,7 +20,9 @@ // MODULES // +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); var assign = require( '@stdlib/object/assign' ); +var format = require( '@stdlib/string/format' ); var RandomStream = require( './main.js' ); @@ -42,6 +44,7 @@ var RandomStream = require( './main.js' ); * @param {PRNGStateMT19937} [options.state] - pseudorandom number generator state * @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state * @param {PositiveInteger} [options.siter] - number of iterations after which to emit the PRNG state +* @throws {TypeError} options argument must be an object * @returns {Function} stream factory * * @example @@ -68,8 +71,14 @@ function factory( n, p, options ) { nargs = arguments.length; if ( nargs === 1 ) { + if ( !isPlainObject( n ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', n ) ); + } opts = assign( {}, n ); } else if ( nargs > 2 ) { + if ( !isPlainObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } opts = assign( {}, options ); } else { opts = {}; diff --git a/streams/cauchy/lib/factory.js b/streams/cauchy/lib/factory.js index c45dfdd8..f5ff58c9 100644 --- a/streams/cauchy/lib/factory.js +++ b/streams/cauchy/lib/factory.js @@ -20,7 +20,9 @@ // MODULES // +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); var assign = require( '@stdlib/object/assign' ); +var format = require( '@stdlib/string/format' ); var RandomStream = require( './main.js' ); @@ -42,6 +44,7 @@ var RandomStream = require( './main.js' ); * @param {PRNGStateMT19937} [options.state] - pseudorandom number generator state * @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state * @param {PositiveInteger} [options.siter] - number of iterations after which to emit the PRNG state +* @throws {TypeError} options argument must be an object * @returns {Function} stream factory * * @example @@ -68,8 +71,14 @@ function factory( x0, gamma, options ) { nargs = arguments.length; if ( nargs === 1 ) { + if ( !isPlainObject( x0 ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', x0 ) ); + } opts = assign( {}, x0 ); } else if ( nargs > 2 ) { + if ( !isPlainObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } opts = assign( {}, options ); } else { opts = {}; diff --git a/streams/chi/lib/factory.js b/streams/chi/lib/factory.js index ea37d609..90f03c59 100644 --- a/streams/chi/lib/factory.js +++ b/streams/chi/lib/factory.js @@ -20,8 +20,10 @@ // MODULES // +var isPlainObject = require( '@stdlib/assert/is-plain-object' ); var isPositive = require( '@stdlib/assert/is-positive-number' ).isPrimitive; var assign = require( '@stdlib/object/assign' ); +var format = require( '@stdlib/string/format' ); var RandomStream = require( './main.js' ); @@ -42,6 +44,7 @@ var RandomStream = require( './main.js' ); * @param {PRNGStateMT19937} [options.state] - pseudorandom number generator state * @param {boolean} [options.copy=true] - boolean indicating whether to copy a provided pseudorandom number generator state * @param {PositiveInteger} [options.siter] - number of iterations after which to emit the PRNG state +* @throws {TypeError} options argument must be an object * @returns {Function} stream factory * * @example @@ -68,6 +71,9 @@ function factory( k, options ) { nargs = arguments.length; if ( nargs > 1 ) { + if ( !isPlainObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } fcn = createStream2; opts = assign( {}, options ); } else if ( nargs === 1 ) { @@ -75,6 +81,9 @@ function factory( k, options ) { fcn = createStream2; opts = {}; } else { + if ( !isPlainObject( k ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', k ) ); + } opts = assign( {}, k ); fcn = createStream1; }