MCPcopy Create free account
hub / github.com/WICG/webpackage / possibleKeyAt

Method possibleKeyAt

go/bundle/encoder.go:346–357  ·  view source on GitHub ↗

possibleKeyAt returns a variant key at given index within the all possible key combinations for v, or nil if index is out of range.

(index int)

Source from the content-addressed store, hash-verified

344// possibleKeyAt returns a variant key at given index within the all possible
345// key combinations for v, or nil if index is out of range.
346func (v Variants) possibleKeyAt(index int) []string {
347 keys := make([]string, len(v))
348 for i := len(v) - 1; i >= 0; i-- {
349 vals := v[i][1:] // Drop header-name
350 keys[i] = vals[index%len(vals)]
351 index /= len(vals)
352 }
353 if index != 0 {
354 return nil // index out of range
355 }
356 return keys
357}
358
359func (is *indexSection) Name() string {
360 return "index"

Callers 2

TestVariantsFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestVariantsFunction · 0.64