Skip to content

Commit

Permalink
refactor: swap out copy for assign in streams packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Jul 22, 2023
1 parent 2229dd5 commit 289f01d
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var hasOwnProp = require( '@stdlib/assert/has-own-property' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var ConstantStream = require( './main.js' );


Expand Down Expand Up @@ -79,13 +79,13 @@ function factory( value, options ) {
hasOwnProp( value, 'highWaterMark' )
)
) {
opts = copy( value, 1 );
opts = assign( {}, value );
FLG = true;
} else {
opts = {};
}
} else { // nargs > 1
opts = copy( options, 1 );
opts = assign( {}, options );
}
if ( FLG ) {
fcn = createStream1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var isUint8Array = require( '@stdlib/assert/is-uint8array' );
var arraybuffer2buffer = require( '@stdlib/buffer/from-arraybuffer' );
var string2buffer = require( '@stdlib/buffer/from-string' );
var Buffer = require( '@stdlib/buffer/ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg

Check warning on line 30 in lib/node_modules/@stdlib/streams/node/from-constant/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: replace Buffer.concat usage with...'
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
Expand Down Expand Up @@ -153,7 +153,7 @@ function ConstantStream( value, options ) {
}
return new ConstantStream( value );
}
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 ConstantStream = require( './main.js' );


Expand Down Expand Up @@ -62,7 +62,7 @@ function objectMode( value, 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 IteratorStream = require( './main.js' );


Expand Down Expand Up @@ -59,7 +59,7 @@ var IteratorStream = require( './main.js' );
function factory( options ) {
var opts;
if ( arguments.length ) {
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 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 IteratorStream = require( './main.js' );


Expand Down Expand Up @@ -63,7 +63,7 @@ function objectMode( iterator, 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 StridedArrayStream = require( './main.js' );


Expand Down Expand Up @@ -65,7 +65,7 @@ var StridedArrayStream = require( './main.js' );
function factory( options ) {
var opts;
if ( arguments.length ) {
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 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 StridedArrayStream = require( './main.js' );


Expand Down Expand Up @@ -72,7 +72,7 @@ function objectMode( N, buffer, stride, offset, 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 @@ -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 Stream = require( './main.js' );


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

var Writable = require( 'readable-stream' ).Writable;
var isFunction = require( '@stdlib/assert/is-function' );
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 @@ -146,7 +146,7 @@ function InspectSinkStream( options, clbk ) {
}
return new InspectSinkStream( options );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 1 ) {
inspect = clbk;
err = validate( opts, options );
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/streams/node/inspect/lib/factory.js
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 Stream = require( './main.js' );


Expand Down Expand Up @@ -65,7 +65,7 @@ function streamFactory( options ) {
if ( !isObject( options ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
opts = copy( options );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/streams/node/inspect/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var Transform = require( 'readable-stream' ).Transform;
var isFunction = require( '@stdlib/assert/is-function' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var format = require( '@stdlib/string/format' );
var inherit = require( '@stdlib/utils/inherit' );
var setNonEnumerable = require( '@stdlib/utils/define-nonenumerable-property' );
Expand Down Expand Up @@ -152,7 +152,7 @@ function InspectStream( options, clbk ) {
}
return new InspectStream( options );
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length > 1 ) {
inspect = clbk;
err = validate( opts, options );
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 Stream = require( './main.js' );


Expand Down Expand Up @@ -69,7 +69,7 @@ function objectMode( options, clbk ) {
if ( !isObject( options ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
opts = copy( options );
opts = assign( {}, options );
cb = clbk;
} else {
opts = {};
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/streams/node/split/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var Transform = require( 'readable-stream' ).Transform;
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 @@ -63,7 +63,7 @@ function transform( chunk, encoding, clbk ) {
}
else if ( encoding !== 'utf8' ) {
// Decode the chunk as a 'utf8' string...
chunk = new Buffer( chunk, encoding ); // eslint-disable-line no-buffer-constructor
chunk = new Buffer( chunk, encoding );
chunk = chunk.toString( 'utf8' );
}
// Split the chunk:
Expand Down Expand Up @@ -189,7 +189,7 @@ function SplitStream( options ) {
}
return new SplitStream();
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length ) {
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 Stream = require( './main.js' );


Expand Down Expand Up @@ -55,7 +55,7 @@ function objectMode( options ) {
if ( !isObject( options ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
opts = copy( options );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/streams/node/transform/lib/ctor.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var logger = require( 'debug' );
var Transform = require( 'readable-stream' ).Transform;
var inherit = require( '@stdlib/utils/inherit' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var DEFAULTS = require( './defaults.json' );
var validate = require( './validate.js' );
var destroy = require( './destroy.js' );
Expand Down Expand Up @@ -82,7 +82,7 @@ function ctor( options ) {
var copts;
var err;

copts = copy( DEFAULTS );
copts = assign( {}, DEFAULTS );
if ( arguments.length ) {
err = validate( copts, options );
if ( err ) {
Expand Down Expand Up @@ -133,7 +133,7 @@ function ctor( options ) {
}
return new TransformStream();
}
opts = copy( copts );
opts = assign( {}, copts );
if ( arguments.length ) {
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 Stream = require( './main.js' );


Expand Down Expand Up @@ -67,7 +67,7 @@ function streamFactory( options ) {
if ( !isObject( options ) ) {
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
}
opts = copy( options );
opts = assign( {}, options );
} else {
opts = {};
}
Expand Down
6 changes: 3 additions & 3 deletions lib/node_modules/@stdlib/streams/node/transform/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
var logger = require( 'debug' );
var Transform = require( 'readable-stream' ).Transform;
var inherit = require( '@stdlib/utils/inherit' );
var copy = require( '@stdlib/utils/copy' );
var assign = require( '@stdlib/object/assign' );
var DEFAULTS = require( './defaults.json' );
var validate = require( './validate.js' );
var destroy = require( './destroy.js' );
Expand Down Expand Up @@ -74,7 +74,7 @@ var debug = logger( 'transform-stream:main' );
*
* // prints: '1\n2\n3\n'
*/
function TransformStream( options ) {
function TransformStream( options ) { // eslint-disable-line stdlib/no-redeclare
var opts;
var err;
if ( !( this instanceof TransformStream ) ) {
Expand All @@ -83,7 +83,7 @@ function TransformStream( options ) {
}
return new TransformStream();
}
opts = copy( DEFAULTS );
opts = assign( {}, DEFAULTS );
if ( arguments.length ) {
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 Stream = require( './main.js' );


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

0 comments on commit 289f01d

Please sign in to comment.