mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
lodash: added _.mapKeys() method
This commit is contained in:
@@ -1794,6 +1794,54 @@ result = <string[]>_({ 'one': 1, 'two': 2, 'three': 3 }).keys().value();
|
||||
result = <string[]>_.keysIn({ 'one': 1, 'two': 2, 'three': 3 });
|
||||
result = <string[]>_({ 'one': 1, 'two': 2, 'three': 3 }).keysIn().value();
|
||||
|
||||
// _.mapKeys
|
||||
module TestMapKeys {
|
||||
let array: TResult[];
|
||||
let list: _.List<TResult>;
|
||||
let dictionary: _.Dictionary<TResult>;
|
||||
|
||||
let listIterator: (value: TResult, index: number, collection: _.List<TResult>) => string;
|
||||
let dictionaryIterator: (value: TResult, key: string, collection: _.Dictionary<TResult>) => string;
|
||||
|
||||
let result: _.Dictionary<TResult>;
|
||||
|
||||
result = _.mapKeys<TResult, string>(array);
|
||||
result = _.mapKeys<TResult, string>(array, listIterator);
|
||||
result = _.mapKeys<TResult, string>(array, listIterator, any);
|
||||
result = _.mapKeys<TResult>(array, '');
|
||||
result = _.mapKeys<TResult, {}>(array, {});
|
||||
|
||||
result = _.mapKeys<TResult, string>(list);
|
||||
result = _.mapKeys<TResult, string>(list, listIterator);
|
||||
result = _.mapKeys<TResult, string>(list, listIterator, any);
|
||||
result = _.mapKeys<TResult>(list, '');
|
||||
result = _.mapKeys<TResult, {}>(list, {});
|
||||
|
||||
result = _.mapKeys<TResult, string>(dictionary);
|
||||
result = _.mapKeys<TResult, string>(dictionary, dictionaryIterator);
|
||||
result = _.mapKeys<TResult, string>(dictionary, dictionaryIterator, any);
|
||||
result = _.mapKeys<TResult>(dictionary, '');
|
||||
result = _.mapKeys<TResult, {}>(dictionary, {});
|
||||
|
||||
result = _(array).mapKeys<string>().value();
|
||||
result = _(array).mapKeys<string>(listIterator).value();
|
||||
result = _(array).mapKeys<string>(listIterator, any).value();
|
||||
result = _(array).mapKeys('').value();
|
||||
result = _(array).mapKeys<{}>({}).value();
|
||||
|
||||
result = _(list).mapKeys<TResult, string>().value();
|
||||
result = _(list).mapKeys<TResult, string>(listIterator).value();
|
||||
result = _(list).mapKeys<TResult, string>(listIterator, any).value();
|
||||
result = _(list).mapKeys<TResult>('').value();
|
||||
result = _(list).mapKeys<TResult, {}>({}).value();
|
||||
|
||||
result = _(dictionary).mapKeys<TResult, string>().value();
|
||||
result = _(dictionary).mapKeys<TResult, string>(dictionaryIterator).value();
|
||||
result = _(dictionary).mapKeys<TResult, string>(dictionaryIterator, any).value();
|
||||
result = _(dictionary).mapKeys<TResult>('').value();
|
||||
result = _(dictionary).mapKeys<TResult, {}>({}).value();
|
||||
}
|
||||
|
||||
var mergeNames = {
|
||||
'stooges': [
|
||||
{ 'name': 'moe' },
|
||||
|
||||
Vendored
+91
@@ -7403,6 +7403,97 @@ declare module _ {
|
||||
keysIn(): LoDashArrayWrapper<string>
|
||||
}
|
||||
|
||||
//_.mapKeys
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* The opposite of _.mapValues; this method creates an object with the same values as object and keys generated
|
||||
* by running each own enumerable property of object through iteratee.
|
||||
*
|
||||
* @param object The object to iterate over.
|
||||
* @param iteratee The function invoked per iteration.
|
||||
* @param thisArg The this binding of iteratee.
|
||||
* @return Returns the new mapped object.
|
||||
*/
|
||||
mapKeys<T, TKey>(
|
||||
object: List<T>,
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): Dictionary<T>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<T, TKey>(
|
||||
object: Dictionary<T>,
|
||||
iteratee?: DictionaryIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): Dictionary<T>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<T, TObject extends {}>(
|
||||
object: List<T>|Dictionary<T>,
|
||||
iteratee?: TObject
|
||||
): Dictionary<T>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<T>(
|
||||
object: List<T>|Dictionary<T>,
|
||||
iteratee?: string
|
||||
): Dictionary<T>;
|
||||
}
|
||||
|
||||
interface LoDashArrayWrapper<T> {
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<TKey>(
|
||||
iteratee?: ListIterator<T, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashObjectWrapper<Dictionary<T>>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<TObject extends {}>(
|
||||
iteratee?: TObject
|
||||
): LoDashObjectWrapper<Dictionary<T>>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys(
|
||||
iteratee?: string
|
||||
): LoDashObjectWrapper<Dictionary<T>>;
|
||||
}
|
||||
|
||||
interface LoDashObjectWrapper<T> {
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<TResult, TKey>(
|
||||
iteratee?: ListIterator<TResult, TKey>|DictionaryIterator<TResult, TKey>,
|
||||
thisArg?: any
|
||||
): LoDashObjectWrapper<Dictionary<TResult>>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<TResult, TObject extends {}>(
|
||||
iteratee?: TObject
|
||||
): LoDashObjectWrapper<Dictionary<TResult>>;
|
||||
|
||||
/**
|
||||
* @see _.mapKeys
|
||||
*/
|
||||
mapKeys<TResult>(
|
||||
iteratee?: string
|
||||
): LoDashObjectWrapper<Dictionary<TResult>>;
|
||||
}
|
||||
|
||||
//_.mapValues
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user