src/parser/option.js
function processAliases(aliases) {
	const result = {
		long: {},
		short: {}
	};

	if (!aliases) {
		return result;
	}

	if (!Array.isArray(aliases)) {
		if (typeof aliases === 'object') {
			if (aliases.long && typeof aliases.long === 'object') {
				Object.assign(result.long, aliases.long);
			}
			if (aliases.short && typeof aliases.short === 'object') {
				Object.assign(result.short, aliases.short);
			}
			return result;
		}

		aliases = [ aliases ];
	}

	for (const alias of aliases) {
		if (!alias || typeof alias !== 'string') {
			throw E.INVALID_ALIAS('Expected aliases to be a string or an array of strings',
				{ name: 'aliases', scope: 'Option.constructor', value: alias });
		}

		for (const a of alias.split(/[ ,|]+/)) {
			const m = a.match(aliasRegExp);
			if (!m) {
				throw E.INVALID_ALIAS(`Invalid alias format "${alias}"`, { name: 'aliases', scope: 'Option.constructor', value: alias });
			}

			if (m[2]) {
				result.short[m[2]] = !m[1];
			} else if (m[3]) {
				result.long[m[3]] = !m[1];
			}
		}
	}

	return result;
}
function processAliases(aliases) {
	const result = {
		long: {},
		short: {}
	};

	if (!aliases) {
		return result;
	}

	if (!Array.isArray(aliases)) {
		if (typeof aliases === 'object') {
			if (aliases.long && typeof aliases.long === 'object') {
				Object.assign(result.long, aliases.long);
			}
			if (aliases.short && typeof aliases.short === 'object') {
				Object.assign(result.short, aliases.short);
			}
			return result;
		}

		aliases = [ aliases ];
	}

	for (const alias of aliases) {
		if (!alias || typeof alias !== 'string') {
			throw E.INVALID_ALIAS('Expected aliases to be a string or an array of strings',
				{ name: 'aliases', scope: 'Option.constructor', value: alias });
		}

		for (const a of alias.split(/[ ,|]+/)) {
			const m = a.match(aliasRegExp);
			if (!m) {
				throw E.INVALID_ALIAS(`Invalid alias format "${alias}"`, { name: 'aliases', scope: 'Option.constructor', value: alias });
			}

			if (m[2]) {
				result.short[m[2]] = !m[1];
			} else if (m[3]) {
				result.long[m[3]] = !m[1];
			}
		}
	}

	return result;
}
function processAliases ( aliases ) { const result = { long : { } , short : { } } ; if ( ! aliases ) { return result ; } if ( ! Array . isArray ( aliases ) ) { if ( typeof aliases === 'object' ) { if ( aliases . long && typeof aliases . long === 'object' ) { Object . assign ( result . long , aliases . long ) ; } if ( aliases . short && typeof aliases . short === 'object' ) { Object . assign ( result . short , aliases . short ) ; } return result ; } aliases = [ aliases ] ; } for ( const alias of aliases ) { if ( ! alias || typeof alias !== 'string' ) { throw E . INVALID_ALIAS ( 'Expected aliases to be a string or an array of strings' , { name : 'aliases' , scope : 'Option.constructor' , value : alias } ) ; } for ( const a of alias . split ( / [ ,|]+ / ) ) { const m = a . match ( aliasRegExp ) ; if ( ! m ) { throw E . INVALID_ALIAS ( ` ${ alias } ` , { name : 'aliases' , scope : 'Option.constructor' , value : alias } ) ; } if ( m [ 2 ] ) { result . short [ m [ 2 ] ] = ! m [ 1 ] ; } else if ( m [ 3 ] ) { result . long [ m [ 3 ] ] = ! m [ 1 ] ; } } } return result ; }
Processes aliases into sorted buckets for faster lookup.

@param {Array.<String>|String} aliases - An array, object, or string containing aliases.
@returns {Object}
Processes aliases into sorted buckets for faster lookup .