[d565449] | 1 | import arrayEach from './_arrayEach.js';
|
---|
| 2 | import arrayIncludes from './_arrayIncludes.js';
|
---|
| 3 |
|
---|
| 4 | /** Used to compose bitmasks for function metadata. */
|
---|
| 5 | var WRAP_BIND_FLAG = 1,
|
---|
| 6 | WRAP_BIND_KEY_FLAG = 2,
|
---|
| 7 | WRAP_CURRY_FLAG = 8,
|
---|
| 8 | WRAP_CURRY_RIGHT_FLAG = 16,
|
---|
| 9 | WRAP_PARTIAL_FLAG = 32,
|
---|
| 10 | WRAP_PARTIAL_RIGHT_FLAG = 64,
|
---|
| 11 | WRAP_ARY_FLAG = 128,
|
---|
| 12 | WRAP_REARG_FLAG = 256,
|
---|
| 13 | WRAP_FLIP_FLAG = 512;
|
---|
| 14 |
|
---|
| 15 | /** Used to associate wrap methods with their bit flags. */
|
---|
| 16 | var wrapFlags = [
|
---|
| 17 | ['ary', WRAP_ARY_FLAG],
|
---|
| 18 | ['bind', WRAP_BIND_FLAG],
|
---|
| 19 | ['bindKey', WRAP_BIND_KEY_FLAG],
|
---|
| 20 | ['curry', WRAP_CURRY_FLAG],
|
---|
| 21 | ['curryRight', WRAP_CURRY_RIGHT_FLAG],
|
---|
| 22 | ['flip', WRAP_FLIP_FLAG],
|
---|
| 23 | ['partial', WRAP_PARTIAL_FLAG],
|
---|
| 24 | ['partialRight', WRAP_PARTIAL_RIGHT_FLAG],
|
---|
| 25 | ['rearg', WRAP_REARG_FLAG]
|
---|
| 26 | ];
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * Updates wrapper `details` based on `bitmask` flags.
|
---|
| 30 | *
|
---|
| 31 | * @private
|
---|
| 32 | * @returns {Array} details The details to modify.
|
---|
| 33 | * @param {number} bitmask The bitmask flags. See `createWrap` for more details.
|
---|
| 34 | * @returns {Array} Returns `details`.
|
---|
| 35 | */
|
---|
| 36 | function updateWrapDetails(details, bitmask) {
|
---|
| 37 | arrayEach(wrapFlags, function(pair) {
|
---|
| 38 | var value = '_.' + pair[0];
|
---|
| 39 | if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
|
---|
| 40 | details.push(value);
|
---|
| 41 | }
|
---|
| 42 | });
|
---|
| 43 | return details.sort();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | export default updateWrapDetails;
|
---|