Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
chore: log util cleanup (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrysolovay committed Feb 16, 2023
1 parent 167c6c5 commit 8b66380
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
14 changes: 6 additions & 8 deletions fluent/ExtrinsicStatusRune.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { known } from "../rpc/mod.ts"
import { MetaRune, Rune, ValueRune } from "../rune/mod.ts"
import { MetaRune, Rune, RunicArgs, ValueRune } from "../rune/mod.ts"
import { BlockRune } from "./BlockRune.ts"
import { Chain } from "./ClientRune.ts"
import { SignedExtrinsicRune } from "./SignedExtrinsicRune.ts"
Expand All @@ -14,13 +14,11 @@ export class ExtrinsicStatusRune<out U1, out U2, out C extends Chain = Chain>
super(_prime)
}

logStatus(...prefix: unknown[]): ExtrinsicStatusRune<U1, U2, C> {
return this.into(ValueRune).map((rune) =>
rune.into(ValueRune).map((value) => {
console.log(...prefix, value)
return value
})
).into(ExtrinsicStatusRune, this.extrinsic)
logStatus<X>(...prefix: RunicArgs<X, unknown[]>): ExtrinsicStatusRune<U1, U2, C> {
return this
.into(ValueRune)
.map((rune) => rune.into(ValueRune).log(...prefix))
.into(ExtrinsicStatusRune, this.extrinsic)
}

terminalTransactionStatuses() {
Expand Down
23 changes: 17 additions & 6 deletions rune/ValueRune.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PromiseOr } from "../util/types.ts"
import { Batch, Run, Rune, Unhandled } from "./Rune.ts"
import { Batch, Run, Rune, RunicArgs, Unhandled } from "./Rune.ts"
import { Receipt } from "./Timeline.ts"

type NonIndexSignatureKeys<T> = T extends T ? keyof {
Expand Down Expand Up @@ -115,11 +115,22 @@ export class ValueRune<out T, out U = never> extends Rune<T, U> {
return ValueRune.new(RunSingular, this)
}

dbg(...prefix: unknown[]) {
return this.map((value) => {
console.log(...prefix, value)
return value
})
dbg<X>(...prefix: RunicArgs<X, unknown[]>) {
return Rune
.tuple([this, Rune.tuple(prefix).lazy()])
.map(([value, prefix]) => {
console.log(...prefix, value)
return value
})
}

log<X>(...prefix: RunicArgs<X, unknown[]>) {
return Rune
.tuple([this, Rune.tuple(prefix).lazy()])
.map(([value, prefix]) => {
console.log(...prefix, value)
return value
})
}

chain<T2, U2>(fn: (result: ValueRune<T, never>) => Rune<T2, U2>): ValueRune<T2, U | U2> {
Expand Down

0 comments on commit 8b66380

Please sign in to comment.