Creates indexed object by provided callback.
If array is returned, creates a separate index for each array element.
indexBy(['one', 'two', 'three'], v => v.length)// { '5': ['three'], '3': ['one', 'two'] }indexBy(['one', 'two', 'three'], v => [v.length, v.length + 1])// { '5': ['three'], '6': ['three'], '3': ['one', 'two'], '4': ['one', 'two'] } Copy
indexBy(['one', 'two', 'three'], v => v.length)// { '5': ['three'], '3': ['one', 'two'] }indexBy(['one', 'two', 'three'], v => [v.length, v.length + 1])// { '5': ['three'], '6': ['three'], '3': ['one', 'two'], '4': ['one', 'two'] }
Creates indexed object by provided callback.
If array is returned, creates a separate index for each array element.