Merge pull request #5613 from chrootsu/lodash-identity

lodash: changed _.identity() method
This commit is contained in:
Masahiro Wakame
2015-09-03 02:07:27 +09:00
2 changed files with 41 additions and 6 deletions
+16 -2
View File
@@ -1650,8 +1650,6 @@ var testAttempFn: TestAttemptFn;
result = <TResult|Error>_.attempt<TResult>(testAttempFn);
result = <TResult|Error>_(testAttempFn).attempt<TResult>();
result = <{ name: string }>_.identity({ 'name': 'moe' });
_.mixin({
'capitalize': function (string) {
return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
@@ -1907,6 +1905,22 @@ result = <() => boolean>_(true).constant<boolean>();
result = <() => any[]>_(['a']).constant<any[]>();
result = <() => {}>_({}).constant<{}>();
// _.identity
{
let testIdentityValue: TResult;
let result: TResult;
result = _.identity<TResult>(testIdentityValue);
result = _(testIdentityValue).identity();
}
{
let result: number;
result = _(42).identity();
}
{
let result: boolean[];
result = _<boolean>([]).identity();
}
// _.method
class TestMethod {
a = {
+25 -4
View File
@@ -8055,13 +8055,34 @@ declare module _ {
//_.identity
interface LoDashStatic {
/**
* This method returns the first argument provided to it.
* @param value Any value.
* @return value.
**/
* This method returns the first argument provided to it.
* @param value Any value.
* @return Returns value.
*/
identity<T>(value?: T): T;
}
interface LoDashWrapper<T> {
/**
* @see _.identity
*/
identity(): T;
}
interface LoDashArrayWrapper<T> {
/**
* @see _.identity
*/
identity(): T[];
}
interface LoDashObjectWrapper<T> {
/**
* @see _.identity
*/
identity(): T;
}
//_.method
interface LoDashStatic {
/**