_isLaziable.js 710 B

12345678910111213141516171819202122232425262728
  1. import LazyWrapper from './_LazyWrapper.js';
  2. import getData from './_getData.js';
  3. import getFuncName from './_getFuncName.js';
  4. import lodash from './wrapperLodash.js';
  5. /**
  6. * Checks if `func` has a lazy counterpart.
  7. *
  8. * @private
  9. * @param {Function} func The function to check.
  10. * @returns {boolean} Returns `true` if `func` has a lazy counterpart,
  11. * else `false`.
  12. */
  13. function isLaziable(func) {
  14. var funcName = getFuncName(func),
  15. other = lodash[funcName];
  16. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  17. return false;
  18. }
  19. if (func === other) {
  20. return true;
  21. }
  22. var data = getData(other);
  23. return !!data && func === data[0];
  24. }
  25. export default isLaziable;