Compute Object

Object representing a computation.

A compute object simply represent an equation or some sort of calculation, such as a discount price or a method to calculate a threshold.

Usually, the value is computed lazily, when a method such as amount() or compute() is called.

// Represent the amount of credits to pay for a transaction
export class CreditsToPay {
  constructor(private readonly duration: Duration) {}

  amount() {
    return this.duration.asHours() * 2;
  }
}

Last updated