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.
14 lines
483 B
14 lines
483 B
'use strict'; |
|
|
|
/** |
|
* Create a method that will retrieve the given field from an object where that field has a function value |
|
* @param {string} field The field to consider |
|
* @returns {function(object):function} A method that gets functions from the given field |
|
*/ |
|
function getFieldAsFn(field) { |
|
return function getFromValue(value) { |
|
return !!value && (typeof value === 'object') && (typeof value[field] === 'function') && value[field]; |
|
}; |
|
} |
|
|
|
module.exports = getFieldAsFn; |