MCPcopy
hub / github.com/riverqueue/river / Map

Function Map

rivershared/util/sliceutil/slice_util.go:48–56  ·  view source on GitHub ↗

Map manipulates a slice and transforms it to a slice of another type.

(collection []T, mapFunc func(T) R)

Source from the content-addressed store, hash-verified

46
47// Map manipulates a slice and transforms it to a slice of another type.
48func Map[T any, R any](collection []T, mapFunc func(T) R) []R {
49 result := make([]R, len(collection))
50
51 for i, item := range collection {
52 result[i] = mapFunc(item)
53 }
54
55 return result
56}
57
58// MapError manipulates a slice and transforms it to a slice of another type,
59// returning the first error that occurred invoking the map function, if there

Callers 15

AddManyMethod · 0.92
AddManySafelyMethod · 0.92
Test_Client_JobListFunction · 0.92
Test_Client_RetryPolicyFunction · 0.92
StartMethod · 0.92
insertManyMethod · 0.92
insertManySharedMethod · 0.92
TestSchemaFunction · 0.92
LogValueMethod · 0.92
JobRescueManyMethod · 0.92

Calls

no outgoing calls

Tested by 10

Test_Client_JobListFunction · 0.74
Test_Client_RetryPolicyFunction · 0.74
TestSchemaFunction · 0.74
TestPeriodicJobEnqueuerFunction · 0.74
TestJobListWithJobsFunction · 0.74
TestMigratorFunction · 0.74
TestMigrationsFromFSFunction · 0.74
TestMapFunction · 0.68