lodash: signatures of the method _.forIn have been changed

This commit is contained in:
Ilya Mochalov
2015-11-15 11:10:15 +05:00
parent aed176536a
commit 717007ce83
2 changed files with 75 additions and 26 deletions
+41 -6
View File
@@ -5259,13 +5259,48 @@ module TestFindLastKey {
}
}
result = <Dog>_.forIn(new Dog('Dagny'), function (value, key) {
console.log(key);
});
// _.forIn
module TestForIn {
type SampleObject = {a: number; b: string; c: boolean;};
result = <_.LoDashImplicitObjectWrapper<Dog>>_(new Dog('Dagny')).forIn(function (value, key) {
console.log(key);
});
let dictionary: _.Dictionary<number>;
let dictionaryIterator: (value: number, key: string, collection: _.Dictionary<number>) => any;
let object: SampleObject;
let objectIterator: (element: any, key?: string, collection?: any) => any;
{
let result: _.Dictionary<number>;
result = _.forIn<number>(dictionary);
result = _.forIn<number>(dictionary, dictionaryIterator);
result = _.forIn<number>(dictionary, dictionaryIterator, any);
}
{
let result: SampleObject;
result = _.forIn<SampleObject>(object);
result = _.forIn<SampleObject>(object, objectIterator);
result = _.forIn<SampleObject>(object, objectIterator, any);
}
{
let result: _.LoDashImplicitObjectWrapper<_.Dictionary<number>>;
result = _(dictionary).forIn<number>();
result = _(dictionary).forIn<number>(dictionaryIterator);
result = _(dictionary).forIn<number>(dictionaryIterator, any);
}
{
let result: _.LoDashExplicitObjectWrapper<_.Dictionary<number>>;
result = _(dictionary).chain().forIn<number>();
result = _(dictionary).chain().forIn<number>(dictionaryIterator);
result = _(dictionary).chain().forIn<number>(dictionaryIterator, any);
}
}
result = <Dog>_.forInRight(new Dog('Dagny'), function (value, key) {
console.log(key);
+34 -20
View File
@@ -9936,35 +9936,49 @@ declare module _ {
//_.forIn
interface LoDashStatic {
/**
* Iterates over own and inherited enumerable properties of an object, executing the callback for
* each property. The callback is bound to thisArg and invoked with three arguments; (value, key,
* object). Callbacks may exit iteration early by explicitly returning false.
* @param object The object to iterate over.
* @param callback The function called per iteration.
* @param thisArg The this binding of callback.
* @return object
**/
* Iterates over own and inherited enumerable properties of an object invoking iteratee for each property. The
* iteratee is bound to thisArg and invoked with three arguments: (value, key, object). Iteratee functions may
* exit iteration early by explicitly returning false.
*
* @param object The object to iterate over.
* @param iteratee The function invoked per iteration.
* @param thisArg The this binding of iteratee.
* @return Returns object.
*/
forIn<T>(
object: Dictionary<T>,
callback?: DictionaryIterator<T, void>,
thisArg?: any): Dictionary<T>;
iteratee?: DictionaryIterator<T, any>,
thisArg?: any
): Dictionary<T>;
/**
* @see _.forIn
**/
forIn<T>(
* @see _.forIn
*/
forIn<T extends {}>(
object: T,
callback?: ObjectIterator<any, void>,
thisArg?: any): T;
iteratee?: ObjectIterator<any, any>,
thisArg?: any
): T;
}
interface LoDashImplicitObjectWrapper<T> {
/**
* @see _.forIn
**/
forIn<T extends {}>(
callback: ObjectIterator<T, void>,
thisArg?: any): _.LoDashImplicitObjectWrapper<T>;
* @see _.forIn
*/
forIn<TValue>(
iteratee?: DictionaryIterator<TValue, any>,
thisArg?: any
): _.LoDashImplicitObjectWrapper<T>;
}
interface LoDashExplicitObjectWrapper<T> {
/**
* @see _.forIn
*/
forIn<TValue>(
iteratee?: DictionaryIterator<TValue, any>,
thisArg?: any
): _.LoDashExplicitObjectWrapper<T>;
}
//_.forInRight