react-native-udp
Version:
React Native UDP socket API for Android & iOS
19 lines (14 loc) • 480 B
JavaScript
/**
* @param {any[]} args
*/
export default function normalizeBindOptions(...args) {
const [arg1, arg2] = args
const lastArg = args[args.length - 1]
let options = {}
if (typeof arg1 === 'object') options = arg1
else if (typeof arg1 === 'number') options.port = arg1
else if (typeof arg1 === 'string') options.address = arg1
if (typeof arg2 === 'string') options.address = arg2
if (typeof lastArg === 'function') options.callback = lastArg
return options
}