Merge pull request #7104 from chrootsu/lodash-omit

lodash: signatures of _.omit have been changed
This commit is contained in:
Masahiro Wakame
2015-12-09 10:32:56 +09:00
2 changed files with 80 additions and 48 deletions
+36 -12
View File
@@ -7073,19 +7073,43 @@ module TestFunctions {
}
}
interface HasName {
name: string;
// _.omit
module TestOmit {
let predicate: (element: any, key: string, collection: any) => boolean;
{
let result: TResult;
result = _.omit<TResult, Object>({}, 'a');
result = _.omit<TResult, Object>({}, 0, 'a');
result = _.omit<TResult, Object>({}, true, 0, 'a');
result = _.omit<TResult, Object>({}, ['b', 1, false], true, 0, 'a');
result = _.omit<TResult, Object>({}, predicate);
result = _.omit<TResult, Object>({}, predicate, any);
}
{
let result: _.LoDashImplicitObjectWrapper<TResult>;
result = _({}).omit<TResult>('a');
result = _({}).omit<TResult>(0, 'a');
result = _({}).omit<TResult>(true, 0, 'a');
result = _({}).omit<TResult>(['b', 1, false], true, 0, 'a');
result = _({}).omit<TResult>(predicate);
result = _({}).omit<TResult>(predicate, any);
}
{
let result: _.LoDashExplicitObjectWrapper<TResult>;
result = _({}).chain().omit<TResult>('a');
result = _({}).chain().omit<TResult>(0, 'a');
result = _({}).chain().omit<TResult>(true, 0, 'a');
result = _({}).chain().omit<TResult>(['b', 1, false], true, 0, 'a');
result = _({}).chain().omit<TResult>(predicate);
result = _({}).chain().omit<TResult>(predicate, any);
}
}
result = <HasName>_.omit({ 'name': 'moe', 'age': 40 }, 'age');
result = <HasName>_.omit({ 'name': 'moe', 'age': 40 }, ['age']);
result = <HasName>_.omit({ 'name': 'moe', 'age': 40 }, function (value) {
return typeof value == 'number';
});
result = <HasName>_({ 'name': 'moe', 'age': 40 }).omit('age').value();
result = <HasName>_({ 'name': 'moe', 'age': 40 }).omit(['age']).value();
result = <HasName>_({ 'name': 'moe', 'age': 40 }).omit(function (value) {
return typeof value == 'number';
}).value();
// _.pairs
module TestPairs {
+44 -36
View File
@@ -11842,54 +11842,62 @@ declare module _ {
//_.omit
interface LoDashStatic {
/**
* Creates a shallow clone of object excluding the specified properties. Property names may be
* specified as individual arguments or as arrays of property names. If a callback is provided
* it will be executed for each property of object omitting the properties the callback returns
* truey for. The callback is bound to thisArg and invoked with three arguments; (value, key,
* object).
* @param object The source object.
* @param keys The properties to omit.
* @return An object without the omitted properties.
**/
omit<Omitted, T>(
* The opposite of _.pick; this method creates an object composed of the own and inherited enumerable
* properties of object that are not omitted.
*
* @param object The source object.
* @param predicate The function invoked per iteration or property names to omit, specified as individual
* property names or arrays of property names.
* @param thisArg The this binding of predicate.
* @return Returns the new object.
*/
omit<TResult extends {}, T extends {}>(
object: T,
...keys: string[]): Omitted;
predicate: ObjectIterator<any, boolean>,
thisArg?: any
): TResult;
/**
* @see _.omit
**/
omit<Omitted, T>(
* @see _.omit
*/
omit<TResult extends {}, T extends {}>(
object: T,
keys: string[]): Omitted;
/**
* @see _.omit
**/
omit<Omitted, T>(
object: T,
callback: ObjectIterator<any, boolean>,
thisArg?: any): Omitted;
...predicate: (StringRepresentable|StringRepresentable[])[]
): TResult;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.omit
**/
omit<Omitted>(
...keys: string[]): LoDashImplicitObjectWrapper<Omitted>;
* @see _.omit
*/
omit<TResult extends {}>(
predicate: ObjectIterator<any, boolean>,
thisArg?: any
): LoDashImplicitObjectWrapper<TResult>;
/**
* @see _.omit
**/
omit<Omitted>(
keys: string[]): LoDashImplicitObjectWrapper<Omitted>;
* @see _.omit
*/
omit<TResult extends {}>(
...predicate: (StringRepresentable|StringRepresentable[])[]
): LoDashImplicitObjectWrapper<TResult>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.omit
*/
omit<TResult extends {}>(
predicate: ObjectIterator<any, boolean>,
thisArg?: any
): LoDashExplicitObjectWrapper<TResult>;
/**
* @see _.omit
**/
omit<Omitted>(
callback: ObjectIterator<any, boolean>,
thisArg?: any): LoDashImplicitObjectWrapper<Omitted>;
* @see _.omit
*/
omit<TResult extends {}>(
...predicate: (StringRepresentable|StringRepresentable[])[]
): LoDashExplicitObjectWrapper<TResult>;
}
//_.pairs