Splitby
See original GitHub issueThis would be a function that would split one iterable in two, depending on a condition.
const [first, second] = splitBy((item) => item === ' ', 'hello world')
Array.from(first) // ['h', 'e', 'l', 'l', 'o']
Array.from(second) // [' ', 'w', 'o', 'r', 'l', 'd']
^^^ I am undecided about the separator
It should be an optimised version of:
const [clone1, clone2] = fork('hello world')
const first = takeWhile((item) => item !== ' ', clone1)
const second = dropWhile((item) => item !== ' ', clone2)
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
splitBy | MuleSoft Documentation
Splits a string into a string array based on a value that matches part of that string. It filters out the matching part...
Read more >SplitBy - Wolfram Language Documentation
SplitBy [list, f] splits list into sublists consisting of runs of successive elements that give the same value when f is applied. SplitBy[list,...
Read more >docs-dataweave/dw-core-functions-splitby.adoc at v2.4 - GitHub
Splits a string into a string array based on a value that matches part of that string. It filters out the matching part...
Read more >splitBy and joinBy function dataweave2 - CloudServicesTutorial
splitBy. Splits a string into a string array based on a value of input or matches part of that input string. It filters...
Read more >DataWeave splitBy function | #Codetober 2021 Day 18
Learn how to use the splitBy function!Official documentation: https://docs.mulesoft.com/dataweave/2.4/dw-core-functions-splitbyDataWeave ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So… ? I’m not saying we copy the API exactly, I’m just saying we use the basics of how it works.
What if we just called it
split
and it removed the sentinel item and emitted a fully variable number of iterables? Then it would be the iterable equivalent ofString.prototype.split
.