@@ -665,66 +665,67 @@ export default class Piscina<T = any, R = any> extends EventEmitterAsyncResource
665665 #pool : ThreadPool ;
666666
667667 constructor ( options : Options = { } ) {
668- super ( { ...options , name : 'Piscina' } ) ;
668+ const opts = { ...options , '__proto__' : null } ;
669+ super ( { ...opts , name : 'Piscina' } ) ;
669670
670- if ( typeof options . filename !== 'string' && options . filename != null ) {
671+ if ( typeof opts . filename !== 'string' && opts . filename != null ) {
671672 throw new TypeError ( 'options.filename must be a string or null' ) ;
672673 }
673- if ( typeof options . name !== 'string' && options . name != null ) {
674+ if ( typeof opts . name !== 'string' && opts . name != null ) {
674675 throw new TypeError ( 'options.name must be a string or null' ) ;
675676 }
676- if ( options . minThreads !== undefined &&
677- ( typeof options . minThreads !== 'number' || options . minThreads < 0 ) ) {
677+ if ( opts . minThreads !== undefined &&
678+ ( typeof opts . minThreads !== 'number' || opts . minThreads < 0 ) ) {
678679 throw new TypeError ( 'options.minThreads must be a non-negative integer' ) ;
679680 }
680- if ( options . maxThreads !== undefined &&
681- ( typeof options . maxThreads !== 'number' || options . maxThreads < 1 ) ) {
681+ if ( opts . maxThreads !== undefined &&
682+ ( typeof opts . maxThreads !== 'number' || opts . maxThreads < 1 ) ) {
682683 throw new TypeError ( 'options.maxThreads must be a positive integer' ) ;
683684 }
684- if ( options . minThreads !== undefined && options . maxThreads !== undefined &&
685- options . minThreads > options . maxThreads ) {
685+ if ( opts . minThreads !== undefined && opts . maxThreads !== undefined &&
686+ opts . minThreads > opts . maxThreads ) {
686687 throw new RangeError ( 'options.minThreads and options.maxThreads must not conflict' ) ;
687688 }
688- if ( options . idleTimeout !== undefined &&
689- ( typeof options . idleTimeout !== 'number' || options . idleTimeout < 0 ) ) {
689+ if ( opts . idleTimeout !== undefined &&
690+ ( typeof opts . idleTimeout !== 'number' || opts . idleTimeout < 0 ) ) {
690691 throw new TypeError ( 'options.idleTimeout must be a non-negative integer' ) ;
691692 }
692- if ( options . maxQueue !== undefined &&
693- options . maxQueue !== 'auto' &&
694- ( typeof options . maxQueue !== 'number' || options . maxQueue < 0 ) ) {
693+ if ( opts . maxQueue !== undefined &&
694+ opts . maxQueue !== 'auto' &&
695+ ( typeof opts . maxQueue !== 'number' || opts . maxQueue < 0 ) ) {
695696 throw new TypeError ( 'options.maxQueue must be a non-negative integer' ) ;
696697 }
697- if ( options . concurrentTasksPerWorker !== undefined &&
698- ( typeof options . concurrentTasksPerWorker !== 'number' ||
699- options . concurrentTasksPerWorker < 1 ) ) {
698+ if ( opts . concurrentTasksPerWorker !== undefined &&
699+ ( typeof opts . concurrentTasksPerWorker !== 'number' ||
700+ opts . concurrentTasksPerWorker < 1 ) ) {
700701 throw new TypeError (
701702 'options.concurrentTasksPerWorker must be a positive integer' ) ;
702703 }
703- if ( options . useAtomics !== undefined &&
704- typeof options . useAtomics !== 'boolean' ) {
704+ if ( opts . useAtomics !== undefined &&
705+ typeof opts . useAtomics !== 'boolean' ) {
705706 throw new TypeError ( 'options.useAtomics must be a boolean value' ) ;
706707 }
707- if ( options . resourceLimits !== undefined &&
708- ( typeof options . resourceLimits !== 'object' ||
709- options . resourceLimits === null ) ) {
708+ if ( opts . resourceLimits !== undefined &&
709+ ( typeof opts . resourceLimits !== 'object' ||
710+ opts . resourceLimits === null ) ) {
710711 throw new TypeError ( 'options.resourceLimits must be an object' ) ;
711712 }
712- if ( options . taskQueue !== undefined && ! isTaskQueue ( options . taskQueue ) ) {
713+ if ( opts . taskQueue !== undefined && ! isTaskQueue ( opts . taskQueue ) ) {
713714 throw new TypeError ( 'options.taskQueue must be a TaskQueue object' ) ;
714715 }
715- if ( options . niceIncrement !== undefined &&
716- ( typeof options . niceIncrement !== 'number' || ( options . niceIncrement < 0 && process . platform !== 'win32' ) ) ) {
716+ if ( opts . niceIncrement !== undefined &&
717+ ( typeof opts . niceIncrement !== 'number' || ( opts . niceIncrement < 0 && process . platform !== 'win32' ) ) ) {
717718 throw new TypeError ( 'options.niceIncrement must be a non-negative integer on Unix systems' ) ;
718719 }
719- if ( options . trackUnmanagedFds !== undefined &&
720- typeof options . trackUnmanagedFds !== 'boolean' ) {
720+ if ( opts . trackUnmanagedFds !== undefined &&
721+ typeof opts . trackUnmanagedFds !== 'boolean' ) {
721722 throw new TypeError ( 'options.trackUnmanagedFds must be a boolean value' ) ;
722723 }
723- if ( options . closeTimeout !== undefined && ( typeof options . closeTimeout !== 'number' || options . closeTimeout < 0 ) ) {
724+ if ( opts . closeTimeout !== undefined && ( typeof opts . closeTimeout !== 'number' || opts . closeTimeout < 0 ) ) {
724725 throw new TypeError ( 'options.closeTimeout must be a non-negative integer' ) ;
725726 }
726727
727- this . #pool = new ThreadPool ( this , options ) ;
728+ this . #pool = new ThreadPool ( this , opts ) ;
728729 }
729730
730731 /** @deprecated Use run(task, options) instead **/
0 commit comments