diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index f2c59d8416..765ab33ee2 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -4384,8 +4384,8 @@ module TestIncludes { } } -// _.indexBy -module TestIndexBy { +// _.keyBy +module TestKeyBy { type SampleObject = {a: number; b: string; c: boolean;}; let array: SampleObject[]; @@ -4401,131 +4401,131 @@ module TestIndexBy { { let result: _.Dictionary; - result = _.indexBy('abcd'); - result = _.indexBy('abcd', stringIterator); - result = _.indexBy('abcd', stringIterator, any); + result = _.keyBy('abcd'); + result = _.keyBy('abcd', stringIterator); + result = _.keyBy('abcd', stringIterator, any); } { let result: _.Dictionary; - result = _.indexBy(array); - result = _.indexBy(array, listIterator); - result = _.indexBy(array, listIterator, any); - result = _.indexBy(array, 'a'); - result = _.indexBy(array, 'a', any); - result = _.indexBy<{a: number}, SampleObject>(array, {a: 42}); - result = _.indexBy(array, {a: 42}); + result = _.keyBy(array); + result = _.keyBy(array, listIterator); + result = _.keyBy(array, listIterator, any); + result = _.keyBy(array, 'a'); + result = _.keyBy(array, 'a', any); + result = _.keyBy<{a: number}, SampleObject>(array, {a: 42}); + result = _.keyBy(array, {a: 42}); - result = _.indexBy(list); - result = _.indexBy(list, listIterator); - result = _.indexBy(list, listIterator, any); - result = _.indexBy(list, 'a'); - result = _.indexBy(list, 'a', any); - result = _.indexBy<{a: number}, SampleObject>(list, {a: 42}); - result = _.indexBy(list, {a: 42}); + result = _.keyBy(list); + result = _.keyBy(list, listIterator); + result = _.keyBy(list, listIterator, any); + result = _.keyBy(list, 'a'); + result = _.keyBy(list, 'a', any); + result = _.keyBy<{a: number}, SampleObject>(list, {a: 42}); + result = _.keyBy(list, {a: 42}); - result = _.indexBy(numericDictionary); - result = _.indexBy(numericDictionary, numericDictionaryIterator); - result = _.indexBy(numericDictionary, numericDictionaryIterator, any); - result = _.indexBy(numericDictionary, 'a'); - result = _.indexBy(numericDictionary, 'a', any); - result = _.indexBy<{a: number}, SampleObject>(numericDictionary, {a: 42}); - result = _.indexBy(numericDictionary, {a: 42}); + result = _.keyBy(numericDictionary); + result = _.keyBy(numericDictionary, numericDictionaryIterator); + result = _.keyBy(numericDictionary, numericDictionaryIterator, any); + result = _.keyBy(numericDictionary, 'a'); + result = _.keyBy(numericDictionary, 'a', any); + result = _.keyBy<{a: number}, SampleObject>(numericDictionary, {a: 42}); + result = _.keyBy(numericDictionary, {a: 42}); - result = _.indexBy(dictionary); - result = _.indexBy(dictionary, dictionaryIterator); - result = _.indexBy(dictionary, dictionaryIterator, any); - result = _.indexBy(dictionary, 'a'); - result = _.indexBy(dictionary, 'a', any); - result = _.indexBy<{a: number}, SampleObject>(dictionary, {a: 42}); - result = _.indexBy(dictionary, {a: 42}); + result = _.keyBy(dictionary); + result = _.keyBy(dictionary, dictionaryIterator); + result = _.keyBy(dictionary, dictionaryIterator, any); + result = _.keyBy(dictionary, 'a'); + result = _.keyBy(dictionary, 'a', any); + result = _.keyBy<{a: number}, SampleObject>(dictionary, {a: 42}); + result = _.keyBy(dictionary, {a: 42}); } { let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; - result = _('abcd').indexBy(); - result = _('abcd').indexBy(stringIterator); - result = _('abcd').indexBy(stringIterator, any); + result = _('abcd').keyBy(); + result = _('abcd').keyBy(stringIterator); + result = _('abcd').keyBy(stringIterator, any); } { let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; - result = _(array).indexBy(); - result = _(array).indexBy(listIterator); - result = _(array).indexBy(listIterator, any); - result = _(array).indexBy('a'); - result = _(array).indexBy('a', any); - result = _(array).indexBy<{a: number}>({a: 42}); + result = _(array).keyBy(); + result = _(array).keyBy(listIterator); + result = _(array).keyBy(listIterator, any); + result = _(array).keyBy('a'); + result = _(array).keyBy('a', any); + result = _(array).keyBy<{a: number}>({a: 42}); - result = _(list).indexBy(); - result = _(list).indexBy(listIterator); - result = _(list).indexBy(listIterator, any); - result = _(list).indexBy('a'); - result = _(list).indexBy('a', any); - result = _(list).indexBy<{a: number}, SampleObject>({a: 42}); - result = _(list).indexBy({a: 42}); + result = _(list).keyBy(); + result = _(list).keyBy(listIterator); + result = _(list).keyBy(listIterator, any); + result = _(list).keyBy('a'); + result = _(list).keyBy('a', any); + result = _(list).keyBy<{a: number}, SampleObject>({a: 42}); + result = _(list).keyBy({a: 42}); - result = _(numericDictionary).indexBy(); - result = _(numericDictionary).indexBy(numericDictionaryIterator); - result = _(numericDictionary).indexBy(numericDictionaryIterator, any); - result = _(numericDictionary).indexBy('a'); - result = _(numericDictionary).indexBy('a', any); - result = _(numericDictionary).indexBy<{a: number}, SampleObject>({a: 42}); - result = _(numericDictionary).indexBy({a: 42}); + result = _(numericDictionary).keyBy(); + result = _(numericDictionary).keyBy(numericDictionaryIterator); + result = _(numericDictionary).keyBy(numericDictionaryIterator, any); + result = _(numericDictionary).keyBy('a'); + result = _(numericDictionary).keyBy('a', any); + result = _(numericDictionary).keyBy<{a: number}, SampleObject>({a: 42}); + result = _(numericDictionary).keyBy({a: 42}); - result = _(dictionary).indexBy(); - result = _(dictionary).indexBy(dictionaryIterator); - result = _(dictionary).indexBy(dictionaryIterator, any); - result = _(dictionary).indexBy('a'); - result = _(dictionary).indexBy('a', any); - result = _(dictionary).indexBy<{a: number}, SampleObject>({a: 42}); - result = _(dictionary).indexBy({a: 42}); + result = _(dictionary).keyBy(); + result = _(dictionary).keyBy(dictionaryIterator); + result = _(dictionary).keyBy(dictionaryIterator, any); + result = _(dictionary).keyBy('a'); + result = _(dictionary).keyBy('a', any); + result = _(dictionary).keyBy<{a: number}, SampleObject>({a: 42}); + result = _(dictionary).keyBy({a: 42}); } { let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; - result = _('abcd').chain().indexBy(); - result = _('abcd').chain().indexBy(stringIterator); - result = _('abcd').chain().indexBy(stringIterator, any); + result = _('abcd').chain().keyBy(); + result = _('abcd').chain().keyBy(stringIterator); + result = _('abcd').chain().keyBy(stringIterator, any); } { let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; - result = _(array).chain().indexBy(); - result = _(array).chain().indexBy(listIterator); - result = _(array).chain().indexBy(listIterator, any); - result = _(array).chain().indexBy('a'); - result = _(array).chain().indexBy('a', any); - result = _(array).chain().indexBy<{a: number}>({a: 42}); + result = _(array).chain().keyBy(); + result = _(array).chain().keyBy(listIterator); + result = _(array).chain().keyBy(listIterator, any); + result = _(array).chain().keyBy('a'); + result = _(array).chain().keyBy('a', any); + result = _(array).chain().keyBy<{a: number}>({a: 42}); - result = _(list).chain().indexBy(); - result = _(list).chain().indexBy(listIterator); - result = _(list).chain().indexBy(listIterator, any); - result = _(list).chain().indexBy('a'); - result = _(list).chain().indexBy('a', any); - result = _(list).chain().indexBy<{a: number}, SampleObject>({a: 42}); - result = _(list).chain().indexBy({a: 42}); + result = _(list).chain().keyBy(); + result = _(list).chain().keyBy(listIterator); + result = _(list).chain().keyBy(listIterator, any); + result = _(list).chain().keyBy('a'); + result = _(list).chain().keyBy('a', any); + result = _(list).chain().keyBy<{a: number}, SampleObject>({a: 42}); + result = _(list).chain().keyBy({a: 42}); - result = _(numericDictionary).chain().indexBy(); - result = _(numericDictionary).chain().indexBy(numericDictionaryIterator); - result = _(numericDictionary).chain().indexBy(numericDictionaryIterator, any); - result = _(numericDictionary).chain().indexBy('a'); - result = _(numericDictionary).chain().indexBy('a', any); - result = _(numericDictionary).chain().indexBy<{a: number}, SampleObject>({a: 42}); - result = _(numericDictionary).chain().indexBy({a: 42}); + result = _(numericDictionary).chain().keyBy(); + result = _(numericDictionary).chain().keyBy(numericDictionaryIterator); + result = _(numericDictionary).chain().keyBy(numericDictionaryIterator, any); + result = _(numericDictionary).chain().keyBy('a'); + result = _(numericDictionary).chain().keyBy('a', any); + result = _(numericDictionary).chain().keyBy<{a: number}, SampleObject>({a: 42}); + result = _(numericDictionary).chain().keyBy({a: 42}); - result = _(dictionary).chain().indexBy(); - result = _(dictionary).chain().indexBy(dictionaryIterator); - result = _(dictionary).chain().indexBy(dictionaryIterator, any); - result = _(dictionary).chain().indexBy('a'); - result = _(dictionary).chain().indexBy('a', any); - result = _(dictionary).chain().indexBy<{a: number}, SampleObject>({a: 42}); - result = _(dictionary).chain().indexBy({a: 42}); + result = _(dictionary).chain().keyBy(); + result = _(dictionary).chain().keyBy(dictionaryIterator); + result = _(dictionary).chain().keyBy(dictionaryIterator, any); + result = _(dictionary).chain().keyBy('a'); + result = _(dictionary).chain().keyBy('a', any); + result = _(dictionary).chain().keyBy<{a: number}, SampleObject>({a: 42}); + result = _(dictionary).chain().keyBy({a: 42}); } } diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 9952113daa..93d974cfd9 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -19,7 +19,7 @@ TODO: - [x] Removed _.pluck in favor of _.map with iteratee shorthand - [x] Renamed _.first to _.head -- [ ] Renamed _.indexBy to _.keyBy +- [x] Renamed _.indexBy to _.keyBy - [ ] Renamed _.invoke to _.invokeMap - [ ] Renamed _.modArgs to _.overArgs - [ ] Renamed _.padLeft & _.padRight to _.padStart & _.padEnd @@ -208,7 +208,7 @@ declare module _ { * after, assign, bind, bindAll, bindKey, chain, chunk, compact, compose, concat, countBy, * createCallback, curry, debounce, defaults, defer, delay, difference, filter, flatten, * forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, functions, groupBy, - * indexBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, + * keyBy, initial, intersection, invert, invoke, keys, map, max, memoize, merge, min, * object, omit, once, pairs, partial, partialRight, pick, pluck, pull, push, range, reject, * remove, rest, reverse, sample, shuffle, slice, sort, sortBy, splice, tap, throttle, times, * toArray, transform, union, uniq, unshift, unzip, values, where, without, wrap, and zip @@ -6732,7 +6732,7 @@ declare module _ { ): LoDashExplicitWrapper; } - //_.indexBy + //_.keyBy interface LoDashStatic { /** * Creates an object composed of keys generated from the results of running each element of collection through @@ -6754,51 +6754,51 @@ declare module _ { * @param thisArg The this binding of iteratee. * @return Returns the composed aggregate object. */ - indexBy( + keyBy( collection: List, iteratee?: ListIterator, thisArg?: any ): Dictionary; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( collection: NumericDictionary, iteratee?: NumericDictionaryIterator, thisArg?: any ): Dictionary; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( collection: Dictionary, iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( collection: List|NumericDictionary|Dictionary, iteratee?: string, thisArg?: any ): Dictionary; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( collection: List|NumericDictionary|Dictionary, iteratee?: W ): Dictionary; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( collection: List|NumericDictionary|Dictionary, iteratee?: Object ): Dictionary; @@ -6806,9 +6806,9 @@ declare module _ { interface LoDashImplicitWrapper { /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: ListIterator, thisArg?: any ): LoDashImplicitObjectWrapper>; @@ -6816,66 +6816,66 @@ declare module _ { interface LoDashImplicitArrayWrapper { /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: ListIterator, thisArg?: any ): LoDashImplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: string, thisArg?: any ): LoDashImplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: W ): LoDashImplicitObjectWrapper>; } interface LoDashImplicitObjectWrapper { /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: ListIterator|NumericDictionaryIterator|DictionaryIterator, thisArg?: any ): LoDashImplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: string, thisArg?: any ): LoDashImplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: W ): LoDashImplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: Object ): LoDashImplicitObjectWrapper>; } interface LoDashExplicitWrapper { /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: ListIterator, thisArg?: any ): LoDashExplicitObjectWrapper>; @@ -6883,57 +6883,57 @@ declare module _ { interface LoDashExplicitArrayWrapper { /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: ListIterator, thisArg?: any ): LoDashExplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: string, thisArg?: any ): LoDashExplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: W ): LoDashExplicitObjectWrapper>; } interface LoDashExplicitObjectWrapper { /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: ListIterator|NumericDictionaryIterator|DictionaryIterator, thisArg?: any ): LoDashExplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: string, thisArg?: any ): LoDashExplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: W ): LoDashExplicitObjectWrapper>; /** - * @see _.indexBy + * @see _.keyBy */ - indexBy( + keyBy( iteratee?: Object ): LoDashExplicitObjectWrapper>; }