Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "resources"

Index

Type aliases

Consumable

Consumable: Supply | Pipe

Consumer

Consumer: "consumer"

FlowNode

FlowNode: NodeBase & T extends Consumable ? { supplies: (amount: number, multiplier?: number) => To<T>; suppliesAsMuchAsNecessary: () => To<T>; suppliesAsMuchAsPossible: () => To<T>; } : {} & T extends Supplyable ? { consumes: (amount: number, multiplier?: number) => From<T>; consumesAsMuchAsNecessary: () => From<T>; consumesAsMuchAsPossible: () => From<T>; } : {}

From

From: object

Type declaration

NodeBase

NodeBase: object

Type declaration

NodeType

NodeType: Supply | Consumer | Pipe

Pipe

Pipe: "pipe"

Supply

Supply: "supply"

Supplyable

Supplyable: Consumer | Pipe

To

To: object

Type declaration

Variables

Const allNodes

allNodes: FlowNode[] = []

All nodes that are part of the network.

Const balances

balances: Map<FlowNode, Variable> = new Map()

Maps each Node to its balance.

Const constraints

constraints: function[] = []

Array of functions that setup constraints on the solver. Due to the nature of some of these constraints, they can't be applied until all the nodes exist, which is why they have to be batched up in functions.

Const consumers

consumers: Map<FlowNode<Consumable>, Set<FlowNode<Supplyable>>> = new Map()

Maps each Node to the Set of its consumers.

Let solver

solver: Solver = new Solver()

Constraint solver that does all the heavy lifting.

Const suppliers

suppliers: Map<FlowNode<Supplyable>, Set<FlowNode<Consumable>>> = new Map()

Maps each Node to the Set of its suppliers.

Const transfers

transfers: TwoKeyMap<FlowNode, Variable> = new TwoKeyMap()

Maps a pair of Nodes to the amount transferred between them.

Functions

Const consumableMixin

  • consumableMixin<T>(node: T): T extends NodeBase ? FlowNode<Consumable> : NodeBase & { supplies: (amount: number, multiplier?: number) => To<"pipe">; suppliesAsMuchAsNecessary: () => To<"pipe">; suppliesAsMuchAsPossible: () => To<...>; } & { ...; }
  • Turns a node into a consumable. The given node is modified in place and returned.

    Type parameters

    Parameters

    • node: T

    Returns T extends NodeBase ? FlowNode<Consumable> : NodeBase & { supplies: (amount: number, multiplier?: number) => To<"pipe">; suppliesAsMuchAsNecessary: () => To<"pipe">; suppliesAsMuchAsPossible: () => To<...>; } & { ...; }

consumer

pipe

Const registerBalance

  • registerBalance(node: FlowNode): Variable
  • Registers and returns a balance for the given node.

    Parameters

    Returns Variable

Const registerSuppliersAndConsumers

  • registerSuppliersAndConsumers(node: FlowNode): void
  • Registers sets for the suppliers and consumers of the given node.

    Parameters

    Returns void

Const registerTransfers

  • Registering a transfer between a consumable and a supplyable requires also registering the inverse transfer. This is tedious, so this function takes care of it.

    Parameters

    Returns object

    • consumableToSupplyable: Variable
    • supplyableToConsumable: Variable

Const reset

  • reset(): void
  • Clears all nodes, relationships, and constraints, and resets the kiwi.js solver.

    Returns void

solve

  • solve(): object
  • Resolves the balances and tranfers of the network.

    Returns object

    • allNodes: (object | object & object | object & object | object & object & object | object & object & object | object & object | object & object | object & object & object | object & object & object)[]
    • balances: Map<object | object & object | object & object | object & object & object | object & object & object | object & object | object & object | object & object & object | object & object & object, number>
    • transfers: TwoKeyMap<object | object & object | object & object | object & object & object | object & object & object | object & object | object & object | object & object & object | object & object & object, number>

sumOfConsumption

  • Returns an Expression that represents the total value consumed by the given node's consumers.

    Parameters

    Returns Expression

sumOfSupply

  • Returns an Expression that represents the total value supplied by the given node's suppliers.

    Parameters

    Returns Expression

supply

  • supply(name: string, capacity: number, multiplier?: number): FlowNode<Supply>
  • Creates a supply node.

    Parameters

    • name: string
    • capacity: number
    • Default value multiplier: number = 1

    Returns FlowNode<Supply>

Const supplyableMixin

  • supplyableMixin<T>(node: T): T extends NodeBase ? NodeBase & { consumes: (amount: number, multiplier?: number) => From<"consumer">; consumesAsMuchAsNecessary: () => From<"consumer">; consumesAsMuchAsPossible: () => From<"consumer">; } : NodeBase & ... 1 more ... & { ...; }
  • Turns a node into a supplyable. The given node is modified in place and returned.

    Type parameters

    Parameters

    • node: T

    Returns T extends NodeBase ? NodeBase & { consumes: (amount: number, multiplier?: number) => From<"consumer">; consumesAsMuchAsNecessary: () => From<"consumer">; consumesAsMuchAsPossible: () => From<"consumer">; } : NodeBase & ... 1 more ... & { ...; }

Generated using TypeDoc