mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Add and adjust deep path examples to _.method, _.methodOf, _.property and _.propertyOf docs. [ci skip]
This commit is contained in:
@@ -11330,14 +11330,14 @@
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var objects = [
|
* var objects = [
|
||||||
* { 'a': { 'b': _.constant(2) } },
|
* { 'a': { 'b': { 'c': _.constant(2) } } },
|
||||||
* { 'a': { 'b': _.constant(1) } }
|
* { 'a': { 'b': { 'c': _.constant(1) } } }
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* _.map(objects, _.method('a.b'));
|
* _.map(objects, _.method('a.b.c'));
|
||||||
* // => [2, 1]
|
* // => [2, 1]
|
||||||
*
|
*
|
||||||
* _.invoke(_.sortBy(objects, _.method(['a', 'b'])), 'a.b');
|
* _.invoke(_.sortBy(objects, _.method(['a', 'b', 'c'])), 'a.b.c');
|
||||||
* // => [1, 2]
|
* // => [1, 2]
|
||||||
*/
|
*/
|
||||||
var method = restParam(function(path, args) {
|
var method = restParam(function(path, args) {
|
||||||
@@ -11357,17 +11357,14 @@
|
|||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var object = {
|
* var array = _.times(3, _.constant),
|
||||||
* 'a': { 'aa': _.constant(3) },
|
* object = { 'a': array, 'b': array, 'c': array };
|
||||||
* 'b': { 'bb': _.constant(1) },
|
|
||||||
* 'c': { 'cc': _.constant(2) }
|
|
||||||
* };
|
|
||||||
*
|
*
|
||||||
* _.map(['a.aa', 'c.cc'], _.methodOf(object));
|
* _.map(['a[2]', 'c[0]'], _.methodOf(object));
|
||||||
* // => [3, 2]
|
* // => [2, 0]
|
||||||
*
|
*
|
||||||
* _.map([['a', 'aa'], ['c', 'cc']], _.methodOf(object));
|
* _.map([['a', '2'], ['c', '0']], _.methodOf(object));
|
||||||
* // => [3, 2]
|
* // => [2, 0]
|
||||||
*/
|
*/
|
||||||
var methodOf = restParam(function(object, args) {
|
var methodOf = restParam(function(object, args) {
|
||||||
return function(path) {
|
return function(path) {
|
||||||
@@ -11514,14 +11511,14 @@
|
|||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var objects = [
|
* var objects = [
|
||||||
* { 'a': 2 },
|
* { 'a': { 'b': { 'c': 2 } } },
|
||||||
* { 'a': 1 }
|
* { 'a': { 'b': { 'c': 1 } } }
|
||||||
* ];
|
* ];
|
||||||
*
|
*
|
||||||
* _.map(objects, _.property('a'));
|
* _.map(objects, _.property('a.b.c'));
|
||||||
* // => [2, 1]
|
* // => [2, 1]
|
||||||
*
|
*
|
||||||
* _.pluck(_.sortBy(objects, _.property('a')), 'a');
|
* _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
|
||||||
* // => [1, 2]
|
* // => [1, 2]
|
||||||
*/
|
*/
|
||||||
function property(path) {
|
function property(path) {
|
||||||
@@ -11535,17 +11532,18 @@
|
|||||||
* @static
|
* @static
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @category Utility
|
* @category Utility
|
||||||
* @param {Object} object The object to inspect.
|
* @param {Object} object The object to query.
|
||||||
* @returns {Function} Returns the new function.
|
* @returns {Function} Returns the new function.
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
* var object = { 'a': 3, 'b': 1, 'c': 2 };
|
* var array = [0, 1, 2],
|
||||||
|
* object = { 'a': array, 'b': array, 'c': array };
|
||||||
*
|
*
|
||||||
* _.map(['a', 'c'], _.propertyOf(object));
|
* _.map(['a[2]', 'c[0]'], _.propertyOf(object));
|
||||||
* // => [3, 2]
|
* // => [2, 0]
|
||||||
*
|
*
|
||||||
* _.sortBy(['a', 'b', 'c'], _.propertyOf(object));
|
* _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
|
||||||
* // => ['b', 'c', 'a']
|
* // => [2, 0]
|
||||||
*/
|
*/
|
||||||
function propertyOf(object) {
|
function propertyOf(object) {
|
||||||
return function(path) {
|
return function(path) {
|
||||||
|
|||||||
Reference in New Issue
Block a user