zipToObject
Combine multiple arrays in sets
214 bytes
Usage
Creates an object mapping the keys in the first array to their corresponding values in the second array.
import * as import _
_ from 'radashi'
const const names: string[]
names = ['ra', 'zeus', 'loki']const const cultures: string[]
cultures = ['egypt', 'greek', 'norse']
import _
_.zipToObject<string, string>(keys: readonly string[], values: string | readonly string[] | ((key: string, idx: number) => string)): Record<string, string>export zipToObject
Creates an object mapping the specified keys to their corresponding
values.
zipToObject(const names: string[]
names, const cultures: string[]
cultures)// => { ra: egypt, zeus: greek, loki: norse }
import _
_.zipToObject<string, string>(keys: readonly string[], values: string | readonly string[] | ((key: string, idx: number) => string)): Record<string, string>export zipToObject
Creates an object mapping the specified keys to their corresponding
values.
zipToObject(const names: string[]
names, (k: string
k, i: number
i) => k: string
k + i: number
i)// => { ra: ra0, zeus: zeus1, loki: loki2 }
import _
_.zipToObject<string, null>(keys: readonly string[], values: ((key: string, idx: number) => null) | readonly null[] | null): Record<string, null>export zipToObject
Creates an object mapping the specified keys to their corresponding
values.
zipToObject(const names: string[]
names, null)// => { ra: null, zeus: null, loki: null }