Skip to content

Commit

Permalink
style: sort code
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhayon committed May 27, 2024
1 parent 3ce5bbc commit 4ed9a46
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/Cause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import * as $Type from './Type'
import { Variant } from './Type'
import { FiberId } from './fiber/FiberId'

export type Cause<E> = Fail<E> | Die | Interrupt
export type Cause<E> = Die | Fail<E> | Interrupt

type _Cause<T extends string> = Variant<typeof uri, T>

export interface Fail<E> extends _Cause<'Fail'> {
readonly error: E
export interface Die extends _Cause<'Die'> {
readonly error: unknown
readonly fiberId: FiberId
}

export interface Die extends _Cause<'Die'> {
readonly error: unknown
export interface Fail<E> extends _Cause<'Fail'> {
readonly error: E
readonly fiberId: FiberId
}

Expand All @@ -24,14 +24,14 @@ export interface Interrupt extends _Cause<'Interrupt'> {
const uri = Symbol('Cause')
const _cause = $Type.variant(uri)

export function fail<E>(error: E, fiberId: FiberId): Cause<E> {
return { ..._cause('Fail'), error, fiberId }
}

export function die(error: unknown, fiberId: FiberId): Cause<never> {
return { ..._cause('Die'), error, fiberId }
}

export function fail<E>(error: E, fiberId: FiberId): Cause<E> {
return { ..._cause('Fail'), error, fiberId }
}

export function interrupt(fiberId: FiberId): Cause<never> {
return { ..._cause('Interrupt'), fiberId }
}
Expand All @@ -40,14 +40,14 @@ export function is(u: unknown): u is Cause<unknown> {
return $Struct.is(u) && $Struct.has(u, $Type.uri) && u[$Type.uri] === uri
}

export function isFail<E>(cause: Cause<E>): cause is Fail<E> {
return cause[$Type.tag] === 'Fail'
}

export function isDie(cause: Cause<any>): cause is Die {
return cause[$Type.tag] === 'Die'
}

export function isFail<E>(cause: Cause<E>): cause is Fail<E> {
return cause[$Type.tag] === 'Fail'
}

export function isInterrupt(cause: Cause<any>): cause is Interrupt {
return cause[$Type.tag] === 'Interrupt'
}

0 comments on commit 4ed9a46

Please sign in to comment.