-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from halprin/external-api-changes
External API Changes
- Loading branch information
Showing
25 changed files
with
241 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,41 @@ | ||
package rangechain | ||
|
||
import ( | ||
"github.com/halprin/rangechain/generator" | ||
"github.com/halprin/rangechain/intermediate" | ||
"github.com/halprin/rangechain/internal/generator" | ||
) | ||
|
||
// FromSlice starts the chain with the supplied slice. | ||
// Chaining and terminating methods can now be called on the result. | ||
func FromSlice(slice interface{}) *intermediate.Link { | ||
func FromSlice(slice interface{}) *Link { | ||
sliceGenerator := generator.FromSlice(slice) | ||
|
||
link := intermediate.NewLink(sliceGenerator) | ||
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{}) *intermediate.Link { | ||
func FromArray(array interface{}) *Link { | ||
arrayGenerator := generator.FromArray(array) | ||
|
||
link := intermediate.NewLink(arrayGenerator) | ||
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{}) *intermediate.Link { | ||
func FromChannel(channel interface{}) *Link { | ||
channelGenerator := generator.FromChannel(channel) | ||
|
||
link := intermediate.NewLink(channelGenerator) | ||
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 `generator.MapTuple` of `github.com/halprin/rangechain/generator`. | ||
func FromMap(aMap interface{}) *intermediate.Link { | ||
// 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 := intermediate.NewLink(mapGenerator) | ||
link := newLink(mapGenerator) | ||
return link | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package generator | ||
|
||
// mapTuple implements the `keyvalue.KeyValuer` interface and is used to represent map's keys and values | ||
type mapTuple struct { | ||
TheKey interface{} | ||
TheValue interface{} | ||
} | ||
|
||
func (m *mapTuple) Key() interface{} { | ||
return m.TheKey | ||
} | ||
|
||
func (m *mapTuple) Value() interface{} { | ||
return m.TheValue | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// Package keyvalue exists to specify the interface of `KeyValuer`. | ||
package keyvalue | ||
|
||
// KeyValuer is used to represent key and value pairs. | ||
type KeyValuer interface { | ||
Key() interface{} | ||
Value() interface{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package rangechain | ||
|
||
// Link is not meant to be initialized directly by external users. Use the `From*` functions. | ||
type Link struct { | ||
generator func() (interface{}, error) | ||
} | ||
|
||
func newLink(generator func() (interface{}, error)) *Link { | ||
return &Link{ | ||
generator: generator, | ||
} | ||
} |
Oops, something went wrong.