Skip to content

Commit

Permalink
fix: split
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Dec 1, 2023
1 parent d64728e commit 95566bc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/strings/split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ export const split = <T>(
writableStrategy?: QueuingStrategy,
readableStrategy?: QueuingStrategy,
) => {
return new TransformStream<string, string[]>(
return new TransformStream<string, string>(
{
transform(chunk, controller) {
controller.enqueue(chunk.split(separator));
for (const item of chunk.split(separator)) {
controller.enqueue(item);
}
},
},
writableStrategy,
Expand Down
4 changes: 2 additions & 2 deletions test/strings/split.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("split", () => {

await pipeline(fromIterable(["1,2,3"]), split(), toArray(destinationArray));

expect(destinationArray).toEqual([["1", "2", "3"]]);
expect(destinationArray).toEqual(["1", "2", "3"]);
});

test("should split strings with custom separator", async () => {
Expand All @@ -23,6 +23,6 @@ describe("split", () => {
toArray(destinationArray),
);

expect(destinationArray).toEqual([["1", "2", "3"]]);
expect(destinationArray).toEqual(["1", "2", "3"]);
});
});
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { globSync } from 'glob';
import { defineConfig } from 'tsup';

const tsFiles = globSync('./src/**/*.ts')
const tsFiles = globSync('./src/**/*.ts', { posix: true });

export default defineConfig({
entry: tsFiles,
Expand Down

0 comments on commit 95566bc

Please sign in to comment.