From f08b6e269001599e7203a9bfdd0a35f7a078afa5 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 2 Jan 2016 00:52:45 -0600 Subject: [PATCH] Add `_.cond` doc example. [ci skip] --- lodash.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lodash.js b/lodash.js index 61c5dcf24..8d3791523 100644 --- a/lodash.js +++ b/lodash.js @@ -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,