Skip to content

Commit

Permalink
refactor: swap out copy for assign in random streams packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Jul 22, 2023
1 parent e7f78f9 commit 2377b27
Show file tree
Hide file tree
Showing 30 changed files with 69 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -68,9 +68,9 @@ function factory( a, b, options ) {

nargs = arguments.length;
if ( nargs === 1 ) {
opts = copy( a, 1 );
opts = assign( {}, a );
} else if ( nargs > 2 ) {
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/random/streams/arcsine/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var Readable = require( 'readable-stream' ).Readable;
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -244,7 +244,7 @@ function RandomStream( a, b, options ) {
if ( a >= b ) {
throw new RangeError( format( 'invalid argument. Minimum support must be less than maximum support. Value: `[%f, %f]`.', a, b ) );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 2 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var isObject = require( '@stdlib/assert/is-plain-object' );
var format = require( '@stdlib/string/format' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -72,7 +72,7 @@ function objectMode( a, b, options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var isProbability = require( '@stdlib/assert/is-probability' ).isPrimitive;
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -69,13 +69,13 @@ function factory( p, options ) {
nargs = arguments.length;
if ( nargs > 1 ) {
fcn = createStream2;
opts = copy( options, 1 );
opts = assign( {}, options );
} else if ( nargs === 1 ) {
if ( isProbability( p ) ) {
fcn = createStream2;
opts = {};
} else {
opts = copy( p, 1 );
opts = assign( {}, p );
fcn = createStream1;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/random/streams/bernoulli/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var Readable = require( 'readable-stream' ).Readable;
var isProbability = require( '@stdlib/assert/is-probability' ).isPrimitive;
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -234,7 +234,7 @@ function RandomStream( p, options ) {
if ( !isProbability( p ) ) {
throw new TypeError( format( 'invalid argument. First argument must be a probability. Value: `%s`.', p ) );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 1 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var isObject = require( '@stdlib/assert/is-plain-object' );
var format = require( '@stdlib/string/format' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -69,7 +69,7 @@ function objectMode( p, options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -69,9 +69,9 @@ function factory( N, K, n, options ) {

nargs = arguments.length;
if ( nargs === 1 ) {
opts = copy( N, 1 );
opts = assign( {}, N );
} else if ( nargs > 3 ) {
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var Readable = require( 'readable-stream' ).Readable;
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' );
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -252,7 +252,7 @@ function RandomStream( N, K, n, options ) {
if ( K > N ) {
throw new RangeError( 'invalid argument. Second argument must be less than or equal to the first argument.' );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 3 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var isObject = require( '@stdlib/assert/is-plain-object' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var RandomStream = require( './main.js' );

Expand Down Expand Up @@ -75,7 +75,7 @@ function objectMode( N, K, n, options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -62,7 +62,7 @@ var RandomStream = require( './main.js' );
function factory( options ) {
var opts;
if ( arguments.length > 0 ) {
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var Readable = require( 'readable-stream' ).Readable;
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -227,7 +227,7 @@ function RandomStream( options ) {
}
return new RandomStream();
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 0 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var isObject = require( '@stdlib/assert/is-plain-object' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var RandomStream = require( './main.js' );

Expand Down Expand Up @@ -67,7 +67,7 @@ function objectMode( options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -68,9 +68,9 @@ function factory( alpha, beta, options ) {

nargs = arguments.length;
if ( nargs === 1 ) {
opts = copy( alpha, 1 );
opts = assign( {}, alpha );
} else if ( nargs > 2 ) {
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/random/streams/invgamma/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var Readable = require( 'readable-stream' ).Readable;
var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive;
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -239,7 +239,7 @@ function RandomStream( alpha, beta, options ) {
if ( !isPositiveNumber( beta ) ) {
throw new TypeError( format( 'invalid argument. Second argument must be a positive number. Value: `%s`.', beta ) );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 2 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var isObject = require( '@stdlib/assert/is-plain-object' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var RandomStream = require( './main.js' );

Expand Down Expand Up @@ -71,7 +71,7 @@ function objectMode( alpha, beta, options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -68,9 +68,9 @@ function factory( a, b, options ) {

nargs = arguments.length;
if ( nargs === 1 ) {
opts = copy( a, 1 );
opts = assign( {}, a );
} else if ( nargs > 2 ) {
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var Readable = require( 'readable-stream' ).Readable;
var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive;
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -239,7 +239,7 @@ function RandomStream( a, b, options ) {
if ( !isPositiveNumber( b ) ) {
throw new TypeError( format( 'invalid argument. Second argument must be a positive number. Value: `%s`.', b ) );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 2 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var isObject = require( '@stdlib/assert/is-plain-object' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var RandomStream = require( './main.js' );

Expand Down Expand Up @@ -71,7 +71,7 @@ function objectMode( a, b, options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

// MODULES //

var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var RandomStream = require( './main.js' );


Expand Down Expand Up @@ -68,9 +68,9 @@ function factory( mu, b, options ) {

nargs = arguments.length;
if ( nargs === 1 ) {
opts = copy( mu, 1 );
opts = assign( {}, mu );
} else if ( nargs > 2 ) {
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/random/streams/laplace/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitiv
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var isError = require( '@stdlib/assert/is-error' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
var setNonEnumerableReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
Expand Down Expand Up @@ -241,7 +241,7 @@ function RandomStream( mu, b, options ) {
if ( !isPositiveNumber( b ) ) {
throw new TypeError( format( 'invalid argument. Second argument must be a positive number. Value: `%s`.', b ) );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 2 ) {
err = validate( opts, options );
if ( err ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var isObject = require( '@stdlib/assert/is-plain-object' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var RandomStream = require( './main.js' );

Expand Down Expand Up @@ -71,7 +71,7 @@ function objectMode( mu, b, options ) {
if ( !isObject( opts ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
}
opts = copy( options, 1 );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
Loading

0 comments on commit 2377b27

Please sign in to comment.