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.

13 lines
483 B

4 years ago
  1. 'use strict';
  2. /**
  3. * Create a method that will retrieve the given field from an object where that field has a function value
  4. * @param {string} field The field to consider
  5. * @returns {function(object):function} A method that gets functions from the given field
  6. */
  7. function getFieldAsFn(field) {
  8. return function getFromValue(value) {
  9. return !!value && (typeof value === 'object') && (typeof value[field] === 'function') && value[field];
  10. };
  11. }
  12. module.exports = getFieldAsFn;