-
Notifications
You must be signed in to change notification settings - Fork 0
/
begin.go
51 lines (40 loc) · 1.52 KB
/
begin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package rangechain
import (
"github.com/halprin/rangechain/internal/generator"
"iter"
)
// FromSlice starts the chain with the supplied slice.
// Chaining and terminating methods can now be called on the result.
func FromSlice(slice interface{}) *Link {
sliceGenerator := generator.FromSlice(slice)
link := newLink(sliceGenerator)
return link
}
// FromArray starts the chain with the supplied array.
// Chaining and terminating methods can now be called on the result.
func FromArray(array interface{}) *Link {
arrayGenerator := generator.FromArray(array)
link := newLink(arrayGenerator)
return link
}
// FromChannel starts the chain with the supplied channel.
// Chaining and terminating methods can now be called on the result.
func FromChannel(channel interface{}) *Link {
channelGenerator := generator.FromChannel(channel)
link := newLink(channelGenerator)
return link
}
// FromMap starts the chain with the supplied map.
// Chaining and terminating methods can now be called on the result. The singular value used to represent the key and value pairs is `keyvalue.KeyValuer` of `github.com/halprin/rangechain/keyvalue`.
func FromMap(aMap interface{}) *Link {
mapGenerator := generator.FromMap(aMap)
link := newLink(mapGenerator)
return link
}
// FromIterator starts the chain with the supplied iterator.
// Chaining and terminating methods can now be called on the result.
func FromIterator[T any](anIterator iter.Seq[T]) *Link {
iterGenerator := generator.FromIterator(anIterator)
link := newLink(iterGenerator)
return link
}