Add _.cond doc example. [ci skip]

This commit is contained in:
John-David Dalton
2016-01-02 00:52:45 -06:00
parent fa13cb5544
commit f08b6e2690

View File

@@ -12832,6 +12832,21 @@
* @param {Array} pairs The predicate-function pairs.
* @returns {Function} Returns the new function.
* @example
*
* var func = _.cond([
* [_.matches({ 'a': 1 }), _.constant('matches A')],
* [_.conforms({ 'b': _.isNumber }), _.constant('matches B')],
* [_.constant(true), _.constant('no match')]
* ])
*
* func({ 'a': 1, 'b': 2 });
* // => 'matches A'
*
* func({ 'a': 0, 'b': 1 });
* // => 'matches B'
*
* func({ 'a': '1', 'b': '2' });
* // => 'no match'
*/
function cond(pairs) {
var length = pairs ? pairs.length : 0,