isLaziable.js 705 B

123456789101112131415161718192021222324252627
  1. var LazyWrapper = require('./LazyWrapper'),
  2. getData = require('./getData'),
  3. getFuncName = require('./getFuncName'),
  4. lodash = require('../chain/lodash');
  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, else `false`.
  11. */
  12. function isLaziable(func) {
  13. var funcName = getFuncName(func),
  14. other = lodash[funcName];
  15. if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
  16. return false;
  17. }
  18. if (func === other) {
  19. return true;
  20. }
  21. var data = getData(other);
  22. return !!data && func === data[0];
  23. }
  24. module.exports = isLaziable;