v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/util/slice/object.go (about)

     1  package slice
     2  
     3  func Object[K comparable, V any](keys []K, values []V) map[K]V {
     4  	l := len(keys)
     5  	if len(values) <= l {
     6  		l = len(values)
     7  	}
     8  	m := make(map[K]V, l)
     9  	for i := 0; i < l; i++ {
    10  		m[keys[i]] = values[i]
    11  	}
    12  	return m
    13  }