INNER CODE UNIT · JavaScript

isObject

sindresorhus/meow · source/options.js:8

const isObject = value => Object.prototype.toString.call(value) === '[object Object]';

const validateOptions = options => {
	if (!isObject(options.flags)) {
		throw new TypeError('The `flags` option must be an object.');
	}

	if (options.input !== undefined && typeof options.input !== 'string' && !isObject(options.input)) {
		throw new TypeError('The `input` option must be a string or an object.');
	}

	if (isObject(options.input) && Object.hasOwn(options.input, 'isRequired') && typeof options.input.isRequired !== 'boolean' && typeof options.input.isRequired !== 'function') {
		throw new TypeError('The `input.isRequired` option must be a boolean or a function.');
	}

	if (options.commands !== undefined) {
		if (!Array.isArray(options.commands)) {
			throw new TypeError('The `commands` option must be an array of strings.');

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…