question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

This 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:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
conartist6commented, Feb 13, 2019

So… ? I’m not saying we copy the API exactly, I’m just saying we use the basics of how it works.

1reaction
conartist6commented, Feb 12, 2019

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 of String.prototype.split.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found