-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build blueprint from validation (#612)
* Validation to blueprint * Fix build
- Loading branch information
Showing
55 changed files
with
5,796 additions
and
6,864 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
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 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,46 @@ | ||
package graphql.nadel.util | ||
|
||
/** | ||
* Very similar to [String.split] but the [splitFunction] determines when to split the input. | ||
*/ | ||
internal fun <E> Sequence<E>.splitBy( | ||
splitFunction: (E) -> Boolean, | ||
): Sequence<List<E>> { | ||
return sequence { | ||
var currentSplit = mutableListOf<E>() | ||
|
||
for (e in this@splitBy) { | ||
if (splitFunction(e)) { | ||
yield(currentSplit) | ||
currentSplit = mutableListOf() | ||
} else { | ||
currentSplit.add(e) | ||
} | ||
} | ||
|
||
yield(currentSplit) | ||
} | ||
} | ||
|
||
/** | ||
* Very similar to [String.split] but the [splitFunction] determines when to split the input. | ||
*/ | ||
internal fun <E> Iterable<E>.splitBy( | ||
splitFunction: (E) -> Boolean, | ||
): List<List<E>> { | ||
val splits = mutableListOf<List<E>>() | ||
var currentSplit = mutableListOf<E>() | ||
|
||
for (e in this) { | ||
if (splitFunction(e)) { | ||
splits.add(currentSplit) | ||
currentSplit = mutableListOf() | ||
} else { | ||
currentSplit.add(e) | ||
} | ||
} | ||
|
||
splits.add(currentSplit) | ||
|
||
return splits | ||
} |
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
Oops, something went wrong.