8000 Tweak `lodash`, `shimIsPlainObject`, `shimKeys`, and `reduce` functio… · lodash/lodash@d1498bb · GitHub
[go: up one dir, main page]

Skip to content

Commit d1498bb

Browse files
committed
Tweak lodash, shimIsPlainObject, shimKeys, and reduce function docs. [ci skip]
Former-commit-id: f24dd4de2a5a6c8103f26d000f1f16b5be3d8165
1 parent 54eeef1 commit d1498bb

File tree

5 files changed

+241
-139
lines changed

5 files changed

+241
-139
lines changed

dist/lodash.compat.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@
209209
/*--------------------------------------------------------------------------*/
210210

211211
/**
212-
* Creates a `lodash` object, that wraps the given `value`, to enable method
212+
* Creates a `lodash` object, which wraps the given `value`, to enable method
213213
* chaining.
214214
*
215215
* In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
@@ -247,6 +247,26 @@
247247
* @category Chaining
248248
* @param {Mixed} value The value to wrap in a `lodash` instance.
249249
* @returns {Object} Returns a `lodash` instance.
250+
* @example
251+
*
252+
* var wrapped = _([1, 2, 3]);
253+
*
254+
* // returns an unwrapped value
255+
* wrapped.reduce(function(sum, num) {
256+
* return sum + num;
257+
* });
258+
* // => 6
259+
*
260+
* // returns a wrapped value
261+
* var squares = wrapped.map(function(num) {
262+
* return num * num;
263+
* });
264+
*
265+
* _.isArray(squares);
266+
* // => false
267+
*
268+
* _.isArray(squares.value());
269+
* // => true
250270
*/
251271
function lodash(value) {
252272
// don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
@@ -807,7 +827,7 @@
807827
}
808828

809829
/**
810-
* A fallback implementation of `isPlainObject` that checks if a given `value`
830+
* A fallback implementation of `isPlainObject` which checks if a given `value`
811831
* is an object created by the `Object` constructor, assuming objects created
812832
* by the `Object` constructor have no inherited enumerable properties and that
813833
* there are no `Object.prototype` extensions.
@@ -937,7 +957,7 @@
937957
};
938958

939959
/**
940-
* A fallback implementation of `Object.keys` that produces an array of the
960+
* A fallback implementation of `Object.keys` which produces an array of the
941961
* given object's own enumerable property names.
942962
*
943963
* @private
@@ -2875,7 +2895,7 @@
28752895
var pluck = map;
28762896

28772897
/**
2878-
* Reduces a `collection` to a value that is the accumulated result of running
2898+
* Reduces a `collection` to a value which is the accumulated result of running
28792899
* each element in the `collection` through the `callback`, where each successive
28802900
* `callback` execution consumes the return value of the previous execution.
28812901
* If `accumulator` is not passed, the first element of the `collection` will be

dist/lodash.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
/*--------------------------------------------------------------------------*/
204204

205205
/**
206-
* Creates a `lodash` object, that wraps the given `value`, to enable method
206+
* Creates a `lodash` object, which wraps the given `value`, to enable method
207207
* chaining.
208208
*
209209
* In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
@@ -241,6 +241,26 @@
241241
* @category Chaining
242242
* @param {Mixed} value The value to wrap in a `lodash` instance.
243243
* @returns {Object} Returns a `lodash` instance.
244+
* @example
245+
*
246+
* var wrapped = _([1, 2, 3]);
247+
*
248+
* // returns an unwrapped value
249+
* wrapped.reduce(function(sum, num) {
250+
* return sum + num;
251+
* });
252+
* // => 6
253+
*
254+
* // returns a wrapped value
255+
* var squares = wrapped.map(function(num) {
256+
* return num * num;
257+
* });
258+
*
259+
* _.isArray(squares);
260+
* // => false
261+
*
262+
* _.isArray(squares.value());
263+
* // => true
244264
*/
245265
function lodash(value) {
246266
// don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
@@ -641,7 +661,7 @@
641661
}
642662

643663
/**
644-
* A fallback implementation of `isPlainObject` that checks if a given `value`
664+
* A fallback implementation of `isPlainObject` which checks if a given `value`
645665
* is an object created by the `Object` constructor, assuming objects created
646666
* by the `Object` constructor have no inherited enumerable properties and that
647667
* there are no `Object.prototype` extensions.
@@ -755,7 +775,7 @@
755775
};
756776

757777
/**
758-
* A fallback implementation of `Object.keys` that produces an array of the
778+
* A fallback implementation of `Object.keys` which produces an array of the
759779
* given object's own enumerable property names.
760780
*
761781
* @private
@@ -2676,7 +2696,7 @@
26762696
}
26772697

26782698
/**
2679-
* Reduces a `collection` to a value that is the accumulated result of running
2699+
* Reduces a `collection` to a value which is the accumulated result of running
26802700
* each element in the `collection` through the `callback`, where each successive
26812701
* `callback` execution consumes the return value of the previous execution.
26822702
* If `accumulator` is not passed, the first element of the `collection` will be

dist/lodash.underscore.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
/*--------------------------------------------------------------------------*/
145145

146146
/**
147-
* Creates a `lodash` object, that wraps the given `value`, to enable method
147+
* Creates a `lodash` object, which wraps the given `value`, to enable method
148148
* chaining.
149149
*
150150
* In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
@@ -182,6 +182,26 @@
182182
* @category Chaining
183183
* @param {Mixed} value The value to wrap in a `lodash` instance.
184184
* @returns {Object} Returns a `lodash` instance.
185+
* @example
186+
*
187+
* var wrapped = _([1, 2, 3]);
188+
*
189+
* // returns an unwrapped value
190+
* wrapped.reduce(function(sum, num) {
191+
* return sum + num;
192+
* });
193+
* // => 6
194+
*
195+
* // returns a wrapped value
196+
* var squares = wrapped.map(function(num) {
197+
* return num * num;
198+
* });
199+
*
200+
* _.isArray(squares);
201+
* // => false
202+
*
203+
* _.isArray(squares.value());
204+
* // => true
185205
*/
186206
function lodash(value) {
187207
return (value instanceof lodash)
@@ -486,7 +506,7 @@
486506
};
487507

488508
/**
489-
* A fallback implementation of `Object.keys` that produces an array of the
509+
* A fallback implementation of `Object.keys` which produces an array of the
490510
* given object's own enumerable property names.
491511
*
492512
* @private
@@ -2030,7 +2050,7 @@
20302050
}
20312051

20322052
/**
2033-
* Reduces a `collection` to a value that is the accumulated result of running
2053+
* Reduces a `collection` to a value which is the accumulated result of running
20342054
* each element in the `collection` through the `callback`, where each successive
20352055
* `callback` execution consumes the return value of the previous execution.
20362056
* If `accumulator` is not passed, the first element of the `collection` will be

0 commit comments

Comments
 (0)
0