MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / Map

Method Map

options/options.go:298–324  ·  view source on GitHub ↗

Map returns a copy of the Options as a map[string]any If the Options has a child, it combines the main and child maps, prepending each key with the options depth (e.g., "0.key" for main options, "1.key" for child options, "2.key" for grandchild options, etc.)

()

Source from the content-addressed store, hash-verified

296// prepending each key with the options depth
297// (e.g., "0.key" for main options, "1.key" for child options, "2.key" for grandchild options, etc.)
298func (o *Options) Map() map[string]any {
299 if o.child == nil {
300 return maps.Clone(o.m)
301 }
302
303 totalEntries := len(o.m)
304
305 for c := range o.Descendants() {
306 totalEntries += len(c.m)
307 }
308
309 result := make(map[string]any, totalEntries)
310
311 for k, v := range o.m {
312 result["0."+k] = v
313 }
314
315 depth := 1
316 for c := range o.Descendants() {
317 for k, v := range c.m {
318 result[strconv.Itoa(depth)+"."+k] = v
319 }
320 depth++
321 }
322
323 return result
324}
325
326// NestedMap returns Options as a nested map[string]any.
327// Each key is split by dots (.) and the resulting keys are used to create a nested structure.

Callers 4

StringMethod · 0.95
TestMapMethod · 0.80
BenchmarkMapFunction · 0.80
newRequestMethod · 0.80

Calls 2

DescendantsMethod · 0.95
CloneMethod · 0.45

Tested by 2

TestMapMethod · 0.64
BenchmarkMapFunction · 0.64