UNPKG

@react-bootstrap/react-popper

Version:
23 lines (19 loc) 650 B
/** * Takes an argument and if it's an array, returns the first item in the array, * otherwise returns the argument. Used for Preact compatibility. */ export var unwrapArray = function unwrapArray(arg) { return Array.isArray(arg) ? arg[0] : arg; }; /** * Takes a maybe-undefined function and arbitrary args and invokes the function * only if it is defined. */ export var safeInvoke = function safeInvoke(fn) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } if (typeof fn === "function") { return fn.apply(undefined, args); } };