Permalink
Cannot retrieve contributors at this time
48 lines (45 sloc)
1016 Bytes
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/lodash/plant.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var baseLodash = require('./_baseLodash'), | |
wrapperClone = require('./_wrapperClone'); | |
/** | |
* Creates a clone of the chain sequence planting `value` as the wrapped value. | |
* | |
* @name plant | |
* @memberOf _ | |
* @since 3.2.0 | |
* @category Seq | |
* @param {*} value The value to plant. | |
* @returns {Object} Returns the new `lodash` wrapper instance. | |
* @example | |
* | |
* function square(n) { | |
* return n * n; | |
* } | |
* | |
* var wrapped = _([1, 2]).map(square); | |
* var other = wrapped.plant([3, 4]); | |
* | |
* other.value(); | |
* // => [9, 16] | |
* | |
* wrapped.value(); | |
* // => [1, 4] | |
*/ | |
function wrapperPlant(value) { | |
var result, | |
parent = this; | |
while (parent instanceof baseLodash) { | |
var clone = wrapperClone(parent); | |
clone.__index__ = 0; | |
clone.__values__ = undefined; | |
if (result) { | |
previous.__wrapped__ = clone; | |
} else { | |
result = clone; | |
} | |
var previous = clone; | |
parent = parent.__wrapped__; | |
} | |
previous.__wrapped__ = value; | |
return result; | |
} | |
module.exports = wrapperPlant; |