source: trip-planner-front/node_modules/lodash/plant.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1016 bytes
Line 
1var baseLodash = require('./_baseLodash'),
2 wrapperClone = require('./_wrapperClone');
3
4/**
5 * Creates a clone of the chain sequence planting `value` as the wrapped value.
6 *
7 * @name plant
8 * @memberOf _
9 * @since 3.2.0
10 * @category Seq
11 * @param {*} value The value to plant.
12 * @returns {Object} Returns the new `lodash` wrapper instance.
13 * @example
14 *
15 * function square(n) {
16 * return n * n;
17 * }
18 *
19 * var wrapped = _([1, 2]).map(square);
20 * var other = wrapped.plant([3, 4]);
21 *
22 * other.value();
23 * // => [9, 16]
24 *
25 * wrapped.value();
26 * // => [1, 4]
27 */
28function wrapperPlant(value) {
29 var result,
30 parent = this;
31
32 while (parent instanceof baseLodash) {
33 var clone = wrapperClone(parent);
34 clone.__index__ = 0;
35 clone.__values__ = undefined;
36 if (result) {
37 previous.__wrapped__ = clone;
38 } else {
39 result = clone;
40 }
41 var previous = clone;
42 parent = parent.__wrapped__;
43 }
44 previous.__wrapped__ = value;
45 return result;
46}
47
48module.exports = wrapperPlant;
Note: See TracBrowser for help on using the repository browser.