- if (opts != null && !isPlainObject(opts)) {
- throw new TypeError('opts worker options parameter is not a plain object')
- }
- if (
- opts?.killBehavior != null &&
- !Object.values(KillBehaviors).includes(opts.killBehavior)
- ) {
- throw new TypeError(
- `killBehavior option '${opts.killBehavior}' is not valid`
- )
- }
- if (
- opts?.maxInactiveTime != null &&
- !Number.isSafeInteger(opts.maxInactiveTime)
- ) {
- throw new TypeError('maxInactiveTime option is not an integer')
- }
- if (opts?.maxInactiveTime != null && opts.maxInactiveTime < 5) {
- throw new TypeError(
- 'maxInactiveTime option is not a positive integer greater or equal than 5'
- )
- }
- if (opts?.killHandler != null && typeof opts.killHandler !== 'function') {
- throw new TypeError('killHandler option is not a function')
- }
- if (opts?.async != null) {
- throw new Error('async option is deprecated')
- }