mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
lodash: added _.invertBy
This commit is contained in:
@@ -8823,6 +8823,101 @@ module TestInvert {
|
||||
}
|
||||
}
|
||||
|
||||
// _.invertBy
|
||||
namespace TestInvertBy {
|
||||
let array: ({a: number;})[];
|
||||
let list: _.List<{a: number;}>;
|
||||
let dictionary: _.Dictionary<{a: number;}>;
|
||||
let numericDictionary: _.NumericDictionary<{a: number;}>;
|
||||
|
||||
let stringIterator: (value: string) => any;
|
||||
let arrayIterator: (value: {a: number;}) => any;
|
||||
let listIterator: (value: {a: number;}) => any;
|
||||
let dictionaryIterator: (value: {a: number;}) => any;
|
||||
let numericDictionaryIterator: (value: {a: number;}) => any;
|
||||
|
||||
{
|
||||
let result: _.Dictionary<string[]>;
|
||||
|
||||
result = _.invertBy('foo');
|
||||
result = _.invertBy('foo', stringIterator);
|
||||
|
||||
result = _.invertBy(array);
|
||||
result = _.invertBy<{a: number;}>(array, 'a');
|
||||
result = _.invertBy<{a: number;}>(array, arrayIterator);
|
||||
result = _.invertBy<{a: number;}>(array, {a: 1});
|
||||
|
||||
result = _.invertBy(list);
|
||||
result = _.invertBy<{a: number;}>(list, 'a');
|
||||
result = _.invertBy<{a: number;}>(list, listIterator);
|
||||
result = _.invertBy<{a: number;}>(list, {a: 1});
|
||||
|
||||
result = _.invertBy(dictionary);
|
||||
result = _.invertBy<{a: number;}>(dictionary, 'a');
|
||||
result = _.invertBy<{a: number;}>(dictionary, dictionaryIterator);
|
||||
result = _.invertBy<{a: number;}>(dictionary, {a: 1});
|
||||
|
||||
result = _.invertBy(numericDictionary);
|
||||
result = _.invertBy<{a: number;}>(numericDictionary, 'a');
|
||||
result = _.invertBy<{a: number;}>(numericDictionary, numericDictionaryIterator);
|
||||
result = _.invertBy<{a: number;}>(numericDictionary, {a: 1});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashImplicitObjectWrapper<_.Dictionary<string[]>>;
|
||||
|
||||
result = _('foo').invertBy();
|
||||
result = _('foo').invertBy(stringIterator);
|
||||
|
||||
result = _(array).invertBy();
|
||||
result = _(array).invertBy('a');
|
||||
result = _(array).invertBy(arrayIterator);
|
||||
result = _(array).invertBy({a: 1});
|
||||
|
||||
result = _(list).invertBy();
|
||||
result = _(list).invertBy('a');
|
||||
result = _(list).invertBy(listIterator);
|
||||
result = _(list).invertBy<{a: number;}>({a: 1});
|
||||
|
||||
result = _(dictionary).invertBy();
|
||||
result = _(dictionary).invertBy('a');
|
||||
result = _(dictionary).invertBy(dictionaryIterator);
|
||||
result = _(dictionary).invertBy<{a: number;}>({a: 1});
|
||||
|
||||
result = _(numericDictionary).invertBy();
|
||||
result = _(numericDictionary).invertBy('a');
|
||||
result = _(numericDictionary).invertBy(numericDictionaryIterator);
|
||||
result = _(numericDictionary).invertBy<{a: number;}>({a: 1});
|
||||
}
|
||||
|
||||
{
|
||||
let result: _.LoDashExplicitObjectWrapper<_.Dictionary<string[]>>;
|
||||
|
||||
result = _('foo').chain().invertBy();
|
||||
result = _('foo').chain().invertBy(stringIterator);
|
||||
|
||||
result = _(array).chain().invertBy();
|
||||
result = _(array).chain().invertBy('a');
|
||||
result = _(array).chain().invertBy(arrayIterator);
|
||||
result = _(array).chain().invertBy({a: 1});
|
||||
|
||||
result = _(list).chain().invertBy();
|
||||
result = _(list).chain().invertBy('a');
|
||||
result = _(list).chain().invertBy(listIterator);
|
||||
result = _(list).chain().invertBy<{a: number;}>({a: 1});
|
||||
|
||||
result = _(dictionary).chain().invertBy();
|
||||
result = _(dictionary).chain().invertBy('a');
|
||||
result = _(dictionary).chain().invertBy(dictionaryIterator);
|
||||
result = _(dictionary).chain().invertBy<{a: number;}>({a: 1});
|
||||
|
||||
result = _(numericDictionary).chain().invertBy();
|
||||
result = _(numericDictionary).chain().invertBy('a');
|
||||
result = _(numericDictionary).chain().invertBy(numericDictionaryIterator);
|
||||
result = _(numericDictionary).chain().invertBy<{a: number;}>({a: 1});
|
||||
}
|
||||
}
|
||||
|
||||
// _.keys
|
||||
module TestKeys {
|
||||
let object: _.Dictionary<any>;
|
||||
|
||||
Vendored
+127
@@ -14951,6 +14951,133 @@ declare module _ {
|
||||
invert<TResult extends {}>(multiValue?: boolean): LoDashExplicitObjectWrapper<TResult>;
|
||||
}
|
||||
|
||||
//_.inverBy
|
||||
interface InvertByIterator<T> {
|
||||
(value: T): any;
|
||||
}
|
||||
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* This method is like _.invert except that the inverted object is generated from the results of running each
|
||||
* element of object through iteratee. The corresponding inverted value of each inverted key is an array of
|
||||
* keys responsible for generating the inverted value. The iteratee is invoked with one argument: (value).
|
||||
*
|
||||
* @param object The object to invert.
|
||||
* @param interatee The iteratee invoked per element.
|
||||
* @return Returns the new inverted object.
|
||||
*/
|
||||
invertBy(
|
||||
object: Object,
|
||||
interatee?: InvertByIterator<any>|string
|
||||
): Dictionary<string[]>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<T>(
|
||||
object: _.Dictionary<T>|_.NumericDictionary<T>,
|
||||
interatee?: InvertByIterator<T>|string
|
||||
): Dictionary<string[]>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<W>(
|
||||
object: Object,
|
||||
interatee?: W
|
||||
): Dictionary<string[]>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<T, W>(
|
||||
object: _.Dictionary<T>,
|
||||
interatee?: W
|
||||
): Dictionary<string[]>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy(
|
||||
interatee?: InvertByIterator<any>
|
||||
): LoDashImplicitObjectWrapper<Dictionary<string[]>>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy(
|
||||
interatee?: InvertByIterator<T>|string
|
||||
): LoDashImplicitObjectWrapper<Dictionary<string[]>>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<W>(
|
||||
interatee?: W
|
||||
): LoDashImplicitObjectWrapper<Dictionary<string[]>>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy(
|
||||
interatee?: InvertByIterator<any>|string
|
||||
): LoDashImplicitObjectWrapper<Dictionary<string[]>>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<W>(
|
||||
interatee?: W
|
||||
): LoDashImplicitObjectWrapper<Dictionary<string[]>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitWrapper<T> {
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy(
|
||||
interatee?: InvertByIterator<any>
|
||||
): LoDashExplicitObjectWrapper<Dictionary<string[]>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy(
|
||||
interatee?: InvertByIterator<T>|string
|
||||
): LoDashExplicitObjectWrapper<Dictionary<string[]>>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<W>(
|
||||
interatee?: W
|
||||
): LoDashExplicitObjectWrapper<Dictionary<string[]>>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy(
|
||||
interatee?: InvertByIterator<any>|string
|
||||
): LoDashExplicitObjectWrapper<Dictionary<string[]>>;
|
||||
|
||||
/**
|
||||
* @see _.invertBy
|
||||
*/
|
||||
invertBy<W>(
|
||||
interatee?: W
|
||||
): LoDashExplicitObjectWrapper<Dictionary<string[]>>;
|
||||
}
|
||||
|
||||
//_.keys
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user