mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Add toJSON alias of valueOf. [closes #521]
This commit is contained in:
@@ -3561,7 +3561,7 @@
|
|||||||
*
|
*
|
||||||
* @name valueOf
|
* @name valueOf
|
||||||
* @memberOf _
|
* @memberOf _
|
||||||
* @alias value
|
* @alias value, toJSON
|
||||||
* @category Chaining
|
* @category Chaining
|
||||||
* @returns {*} Returns the wrapped value.
|
* @returns {*} Returns the wrapped value.
|
||||||
* @example
|
* @example
|
||||||
@@ -8427,6 +8427,7 @@
|
|||||||
|
|
||||||
// add "Chaining" functions to the wrapper
|
// add "Chaining" functions to the wrapper
|
||||||
lodash.prototype.chain = wrapperChain;
|
lodash.prototype.chain = wrapperChain;
|
||||||
|
lodash.prototype.toJSON = wrapperValueOf;
|
||||||
lodash.prototype.toString = wrapperToString;
|
lodash.prototype.toString = wrapperToString;
|
||||||
lodash.prototype.value = wrapperValueOf;
|
lodash.prototype.value = wrapperValueOf;
|
||||||
lodash.prototype.valueOf = wrapperValueOf;
|
lodash.prototype.valueOf = wrapperValueOf;
|
||||||
|
|||||||
11
test/test.js
11
test/test.js
@@ -9659,6 +9659,17 @@
|
|||||||
skipTest();
|
skipTest();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should be aliased', 2, function() {
|
||||||
|
if (!isNpm) {
|
||||||
|
var expected = _.prototype.valueOf;
|
||||||
|
strictEqual(_.prototype.toJSON, expected);
|
||||||
|
strictEqual(_.prototype.value, expected);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(2);
|
||||||
|
}
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user