Skip to content

Commit

Permalink
šŸ”„Remove stream combinators
Browse files Browse the repository at this point in the history
Stream transformations are not our core competency. If Effection is
measured by that yard stick, it'll come up short because what we have
is 5% implementation of a not-strongly-opinionated stream helpers
library. One could very reasonably ask "well where is flatMap(),
merge(), reduce(), reduceRight()" and on and on. The answer is that we
aren't in that business, and it's better to not play that game at all,
than to enter the race and get lapped 20 times.

Our mantra is "Structured Concurrency and Effects for
JavaScript". It's a minimalist approach that seeks to excel via
maximum compatibility and minimum friction over the long term. Having
these as part of our API surface feels like it runs counter to that
principle.

In the spirit of keeping things "core", remove first(), filter(),
map(), pipe(), and associated documentation.

They should be published as a separate library where the optimal
implementation (if there is one) can be discovered.
  • Loading branch information
cowboyd committed Dec 13, 2023
1 parent 4c8168c commit eea309c
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 684 deletions.
9 changes: 7 additions & 2 deletions lib/events.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// deno-lint-ignore-file no-explicit-any ban-types
import { createSignal } from "./signal.ts";
import { resource } from "./instructions.ts";
import { first } from "./mod.ts";
import type { Operation, Stream, Subscription } from "./types.ts";

type FN = (...any: any[]) => any;
Expand Down Expand Up @@ -32,7 +31,13 @@ export function once<
T extends EventTarget,
K extends EventList<T> | (string & {}),
>(target: T, name: K): Operation<EventTypeFromEventTarget<T, K>> {
return first(on(target, name));
return {
*[Symbol.iterator]() {
let subscription = yield* on(target, name).subscribe();
let next = yield* subscription.next();
return next.value;
},
};
}

/**
Expand Down
33 changes: 0 additions & 33 deletions lib/filter.ts

This file was deleted.

13 changes: 0 additions & 13 deletions lib/first.ts

This file was deleted.

27 changes: 0 additions & 27 deletions lib/map.ts

This file was deleted.

4 changes: 0 additions & 4 deletions lib/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ export * from "./instructions.ts";
export * from "./call.ts";
export * from "./run.ts";
export * from "./sleep.ts";
export * from "./first.ts";
export * from "./async.ts";
export * from "./abort-signal.ts";
export * from "./result.ts";
export * from "./map.ts";
export * from "./filter.ts";
export * from "./pipe.ts";
export * from "./lift.ts";
export * from "./events.ts";
export * from "./main.ts";
Expand Down
273 changes: 0 additions & 273 deletions lib/pipe.ts

This file was deleted.

Loading

0 comments on commit eea309c

Please sign in to comment.