Sha256: c33560a1f869c02f4ce41a07502f2c7523c934d93b35f82d8151e4a4cc14d3fe

Contents?: true

Size: 981 Bytes

Versions: 153

Compression:

Stored size: 981 Bytes

Contents

var baseLodash = require('../internal/baseLodash'),
    wrapperClone = require('../internal/wrapperClone');

/**
 * Creates a clone of the chained sequence planting `value` as the wrapped value.
 *
 * @name plant
 * @memberOf _
 * @category Chain
 * @returns {Object} Returns the new `lodash` wrapper instance.
 * @example
 *
 * var array = [1, 2];
 * var wrapped = _(array).map(function(value) {
 *   return Math.pow(value, 2);
 * });
 *
 * var other = [3, 4];
 * var otherWrapped = wrapped.plant(other);
 *
 * otherWrapped.value();
 * // => [9, 16]
 *
 * wrapped.value();
 * // => [1, 4]
 */
function wrapperPlant(value) {
  var result,
      parent = this;

  while (parent instanceof baseLodash) {
    var clone = wrapperClone(parent);
    if (result) {
      previous.__wrapped__ = clone;
    } else {
      result = clone;
    }
    var previous = clone;
    parent = parent.__wrapped__;
  }
  previous.__wrapped__ = value;
  return result;
}

module.exports = wrapperPlant;

Version data entries

153 entries across 80 versions & 8 rubygems

Version Path
ilog-0.4.1 node_modules/contents/node_modules/lodash/chain/wrapperPlant.js
ilog-0.4.1 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/chain/wrapperPlant.js
ilog-0.4.1 node_modules/babel/node_modules/lodash/chain/wrapperPlant.js
ilog-0.4.0 node_modules/babel/node_modules/lodash/chain/wrapperPlant.js
ilog-0.4.0 node_modules/contents/node_modules/lodash/chain/wrapperPlant.js
ilog-0.4.0 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/chain/wrapperPlant.js
ilog-0.3.3 node_modules/babel/node_modules/lodash/chain/wrapperPlant.js
ilog-0.3.3 node_modules/contents/node_modules/lodash/chain/wrapperPlant.js
ilog-0.3.3 node_modules/babel-plugin-proto-to-assign/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperPlant.js
xcodebuild-helper-1.2.5 externals/ios-sim-master/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/chain/wrapperPlant.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/inquirer/node_modules/lodash/chain/wrapperPlant.js