UNPKG

vue-app-sdk

Version:
71 lines (70 loc) 2.87 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const _baseSetData = require("./_baseSetData.cjs"); const _createBind = require("./_createBind.cjs"); const _createCurry = require("./_createCurry.cjs"); const _createHybrid = require("./_createHybrid.cjs"); const _createPartial = require("./_createPartial.cjs"); const _getData = require("./_getData.cjs"); const _mergeData = require("./_mergeData.cjs"); const _setData = require("./_setData.cjs"); const _setWrapToString = require("./_setWrapToString.cjs"); const toInteger = require("./toInteger.cjs"); var FUNC_ERROR_TEXT = "Expected a function"; var WRAP_BIND_FLAG = 1, WRAP_BIND_KEY_FLAG = 2, WRAP_CURRY_FLAG = 8, WRAP_CURRY_RIGHT_FLAG = 16, WRAP_PARTIAL_FLAG = 32, WRAP_PARTIAL_RIGHT_FLAG = 64; var nativeMax = Math.max; function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary, arity) { var isBindKey = bitmask & WRAP_BIND_KEY_FLAG; if (!isBindKey && typeof func != "function") { throw new TypeError(FUNC_ERROR_TEXT); } var length = partials ? partials.length : 0; if (!length) { bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG); partials = holders = void 0; } ary = ary === void 0 ? ary : nativeMax(toInteger.default(ary), 0); arity = arity === void 0 ? arity : toInteger.default(arity); length -= holders ? holders.length : 0; if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) { var partialsRight = partials, holdersRight = holders; partials = holders = void 0; } var data = isBindKey ? void 0 : _getData.default(func); var newData = [ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity ]; if (data) { _mergeData.default(newData, data); } func = newData[0]; bitmask = newData[1]; thisArg = newData[2]; partials = newData[3]; holders = newData[4]; arity = newData[9] = newData[9] === void 0 ? isBindKey ? 0 : func.length : nativeMax(newData[9] - length, 0); if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) { bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG); } if (!bitmask || bitmask == WRAP_BIND_FLAG) { var result = _createBind.default(func, bitmask, thisArg); } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) { result = _createCurry.default(func, bitmask, arity); } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) { result = _createPartial.default(func, bitmask, thisArg, partials); } else { result = _createHybrid.default.apply(void 0, newData); } var setter = data ? _baseSetData.default : _setData.default; return _setWrapToString.default(setter(result, newData), func, bitmask); } exports.default = createWrap;