_isLaziable.js 712 B

1234567891011121314151617181920212223242526272829
  1. var LazyWrapper = require('./_LazyWrapper'),
  2. getData = require('./_getData'),
  3. getFuncName = require('./_getFuncName'),
  4. lodash = require('./wrapperLodash');
  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. module.exports = isLaziable;