Back | Home
الـ Path الحالي: /home/picotech/domains/instantly.picotech.app/public_html/public/uploads/../uploads/../../../../instantly.picotech.app/homes/../../wa.picotech.app/public_html/node_modules/path-exists/../duplexify/./../@protobufjs/../cheerio/../parse5/../ee-first/../y18n/../libphonenumber-js/source
الملفات الموجودة في هذا الـ Path:
.
..
AsYouType.js
AsYouType.test.js
AsYouTypeFormatter.PatternMatcher.d.ts
AsYouTypeFormatter.PatternMatcher.js
AsYouTypeFormatter.PatternMatcher.test.js
AsYouTypeFormatter.PatternParser.d.ts
AsYouTypeFormatter.PatternParser.js
AsYouTypeFormatter.PatternParser.test.js
AsYouTypeFormatter.complete.js
AsYouTypeFormatter.js
AsYouTypeFormatter.util.js
AsYouTypeFormatter.util.test.js
AsYouTypeParser.js
AsYouTypeState.js
ParseError.js
PhoneNumber.js
PhoneNumber.test.js
PhoneNumberMatcher.js
PhoneNumberMatcher.test.js
constants.js
findNumbers
findPhoneNumbersInText.js
findPhoneNumbersInText.test.js
format.js
format.test.js
formatIncompletePhoneNumber.js
formatIncompletePhoneNumber.test.js
formatPhoneNumberForMobileDialing.js
formatPhoneNumberForMobileDialing.test.js
getCountries.js
getCountries.test.js
getCountryCallingCode.js
getCountryCallingCode.test.js
getExampleNumber.js
getExampleNumber.test.js
helpers
isPossible.js
isPossible.test.js
isPossiblePhoneNumber.js
isPossiblePhoneNumber.test.js
isValid.js
isValid.test.js
isValidPhoneNumber.js
isValidPhoneNumber.test.js
legacy
metadata.js
metadata.test.js
normalizeArguments.js
parse.js
parse.test.js
parseIncompletePhoneNumber.js
parseIncompletePhoneNumber.test.js
parsePhoneNumber.js
parsePhoneNumber.test.js
parsePhoneNumberWithError.js
parsePhoneNumberWithError.test.js
parsePhoneNumberWithError_.js
parsePhoneNumber_.js
searchPhoneNumbersInText.js
searchPhoneNumbersInText.test.js
tools
validatePhoneNumberLength.js
validatePhoneNumberLength.test.js

مشاهدة ملف: normalizeArguments.js

import isObject from './helpers/isObject.js'

// Extracts the following properties from function arguments:
// * input `text`
// * `options` object
// * `metadata` JSON
export default function normalizeArguments(args) {
	const [arg_1, arg_2, arg_3, arg_4] = Array.prototype.slice.call(args)

	let text
	let options
	let metadata

	// If the phone number is passed as a string.
	// `parsePhoneNumber('88005553535', ...)`.
	if (typeof arg_1 === 'string') {
		text = arg_1
	}
	else throw new TypeError('A text for parsing must be a string.')

	// If "default country" argument is being passed then move it to `options`.
	// `parsePhoneNumber('88005553535', 'RU', [options], metadata)`.
	if (!arg_2 || typeof arg_2 === 'string')
	{
		if (arg_4) {
			options = arg_3
			metadata = arg_4
		} else {
			options = undefined
			metadata = arg_3
		}

		if (arg_2) {
			options = { defaultCountry: arg_2, ...options }
		}
	}
	// `defaultCountry` is not passed.
	// Example: `parsePhoneNumber('+78005553535', [options], metadata)`.
	else if (isObject(arg_2))
	{
		if (arg_3) {
			options  = arg_2
			metadata = arg_3
		} else {
			metadata = arg_2
		}
	}
	else throw new Error(`Invalid second argument: ${arg_2}`)

	return {
		text,
		options,
		metadata
	}
}