mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Add _#toString and _#valueOf.
Former-commit-id: adb194b6270fc72f794c69343891a2e891b90051
This commit is contained in:
18
lodash.js
18
lodash.js
@@ -4043,6 +4043,22 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produces the `toString` result of the wrapped value.
|
||||
*
|
||||
* @name toString
|
||||
* @memberOf _
|
||||
* @category Chaining
|
||||
* @returns {String} Returns the string result.
|
||||
* @example
|
||||
*
|
||||
* _([1, 2, 3]).toString();
|
||||
* // => '1,2,3'
|
||||
*/
|
||||
function wrapperToString() {
|
||||
return String(this.__wrapped__);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the wrapped value.
|
||||
*
|
||||
@@ -4196,7 +4212,9 @@
|
||||
// add `lodash.prototype.chain` after calling `mixin()` to avoid overwriting
|
||||
// it with the wrapped `lodash.chain`
|
||||
lodash.prototype.chain = wrapperChain;
|
||||
lodash.prototype.toString = wrapperToString;
|
||||
lodash.prototype.value = wrapperValue;
|
||||
lodash.prototype.valueOf = wrapperValue;
|
||||
|
||||
// add all mutator Array functions to the wrapper.
|
||||
forEach(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
|
||||
|
||||
Reference in New Issue
Block a user