You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cb.js 792B

1234567891011121314151617181920212223242526272829
  1. const identity = require('./identity');
  2. const isFunction = require('./is-function');
  3. const optimizeCb = require('./optimize-cb');
  4. const isObject = require('./is-object');
  5. const matcher = require('./matcher');
  6. const property = require('./property');
  7. const baseIteratee = (value, context, argCount) => {
  8. if (value == null) return identity;
  9. if (isFunction(value)) return optimizeCb(value, context, argCount);
  10. if (isObject(value) && !Array.isArray(value)) return matcher(value);
  11. return property(value);
  12. };
  13. let iteratee;
  14. const exportIteratee = iteratee = (value, context) => baseIteratee(value, context, Infinity);
  15. module.exports = (value, context, argCount) => {
  16. if (iteratee !== exportIteratee) return iteratee(value, context);
  17. return baseIteratee(value, context, argCount);
  18. };