Skip to content

Commit

Permalink
feat(dsp): add refG()/refP() wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 27, 2023
1 parent 314e9b2 commit 99f4535
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/dsp/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export * from "./pipe.js";
export * from "./power.js";
export * from "./product.js";
export * from "./reciprocal.js";
export * from "./ref.js";
export * from "./serial.js";
export * from "./sincos.js";
export * from "./sum.js";
Expand Down
27 changes: 27 additions & 0 deletions packages/dsp/src/ref.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { AGen } from "./agen.js";
import type { IGen, IProc } from "./api.js";
import { AProc } from "./aproc.js";

export const refG = <T>(src: IGen<T>) => new RefG(src);

export class RefG<T> extends AGen<T> {
constructor(protected _src: IGen<T>) {
super(_src.deref());
}

next() {
return this._src.deref();
}
}

export const refP = <A, B>(src: IProc<A, B>) => new RefP(src);

export class RefP<A, B> extends AProc<A, B> {
constructor(protected _src: IProc<A, B>) {
super(_src.deref());
}

next() {
return this._src.deref();
}
}

0 comments on commit 99f4535

Please sign in to comment.