(options, key, required)
| 30 | }; |
| 31 | |
| 32 | const getFunctionOption = (options, key, required) => { |
| 33 | const value = key in options ? options[key] : null; |
| 34 | if (typeof value === 'function') return value; |
| 35 | if (value != null) throw new TypeError(`Expected the "${key}" option to be a function`); |
| 36 | if (required) throw new TypeError(`Missing required option "${key}"`); |
| 37 | return null; |
| 38 | }; |
| 39 | |
| 40 | const getLength = ({ length }) => { |
| 41 | if (Number.isInteger(length) && length >= 0) return length; |