Skip to content

Commit

Permalink
keep for split
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiancook committed Jan 16, 2024
1 parent 32f39b7 commit 6a09d8f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/split/split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,28 @@ export function split<T>(
function* inner() {
yield mainTarget?.push(snapshot);

for (const [index, target] of targets.entries()) {
if (index >= snapshot.length) {
continue;
if (options?.keep) {
for (let index = 0; index < snapshot.length; index += 1) {
const target = atTarget(index);
const value = snapshot.at(index);
assert(value);
target.push(value);
}
if (index < 0 && Math.abs(index) > snapshot.length) {
continue;
} else {
for (const [index, target] of targets.entries()) {
if (index >= snapshot.length) {
continue;
}
if (index < 0 && Math.abs(index) > snapshot.length) {
continue;
}
const value = snapshot.at(index); // Using at here allows using -1 as an index
assert(value);
target.push(value);
}
const value = snapshot.at(index); // Using at here allows using -1 as an index
assert(value);
target.push(value);
}


}
}

Expand Down

0 comments on commit 6a09d8f

Please sign in to comment.