DOCSAPI reference

CLASS

Component

Defined in: packages/core/src/component/index.ts:47

Base class for every AStack component.

A component has a default in and out port. Call run() to use it on its own, or add it to a Pipeline, which calls _transform() for reactive execution.

Extends

  • default

Constructors

Constructor

new Component(opts): Component;

Defined in: packages/core/src/component/index.ts:55

Parameters

Parameter Type
opts unknown

Returns

Component

Overrides

TransformNode.constructor

Properties

Property Modifier Type Default value Description Inherited from Defined in
flow public Flow | null undefined - TransformNode.flow node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:24
I public (name) => Port undefined - TransformNode.I node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:26
id public string undefined - TransformNode.id node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:18
identity public Symbol undefined - TransformNode.identity node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:25
inPort protected readonly Port undefined The default in input port. - packages/core/src/component/index.ts:51
isRunning public boolean undefined - TransformNode.isRunning node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:23
O public (name) => Port undefined - TransformNode.O node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:27
opts public object undefined - TransformNode.opts node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:19
outPort protected readonly Port undefined The default out output port. A pipeline uses it to infer the endpoint. - packages/core/src/component/index.ts:53
portMap public PortMap undefined - TransformNode.portMap node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:22
type public Symbol undefined - TransformNode.type node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:17
Port static typeof Port HlangPort Port factory from the HLang runtime. Component.Port.I(name) and Component.Port.O(name) create input and output ports; call .attach(this) in the constructor. - packages/core/src/component/index.ts:49

Methods

_transform()

_transform($i, $o): void;

Defined in: packages/core/src/component/index.ts:110

Run component in pipeline

Override this method in subclasses to implement custom data processing logic

Parameters

Parameter Type Description
$i Port Input port accessor. Call $i('portName').receive(callback) to read data.
$o Port Output port accessor. Call $o('portName').send(value) to emit data.

Returns

void

Examples

Basic component with single input and output

import type { Port } from '@astack-tech/core';

_transform($i: Port, $o: Port) {
  $i('in').receive((data: { text: string }) => {
    const result = { processed: data.text.toUpperCase() };
    $o('out').send(result);
  });
}

Multi-port component with conditional routing

import type { Port } from '@astack-tech/core';

_transform($i: Port, $o: Port) {
  $i('in').receive((data: { value: number }) => {
    if (data.value % 2 === 0) {
      $o('even').send({ result: data.value * 2 });
    } else {
      $o('odd').send({ result: data.value * 3 });
    }
  });
}

Overrides

TransformNode._transform


attach()

attach(flow): void;

Defined in: node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:31

Parameters

Parameter Type
flow any

Returns

void

Inherited from

TransformNode.attach


attachPort()

attachPort(port): void;

Defined in: node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:32

Parameters

Parameter Type
port any

Returns

void

Inherited from

TransformNode.attachPort


E()

E(): Port;

Defined in: node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:30

Returns

Port

Inherited from

TransformNode.E


executeOnce()

executeOnce(type, ...args): void;

Defined in: node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/node.d.ts:29

Parameters

Parameter Type
type any
...args any[]

Returns

void

Inherited from

TransformNode.executeOnce


run()

run(data): unknown;

Defined in: packages/core/src/component/index.ts:69

Processes one input outside a pipeline. The default implementation returns the input.

Parameters

Parameter Type
data unknown

Returns

unknown


throw()

throw(error): void;

Defined in: node_modules/.pnpm/@hlang-org+runtime@1.0.5/node_modules/@hlang-org/runtime/lib/node/transform.d.ts:4

Parameters

Parameter Type
error any

Returns

void

Inherited from

TransformNode.throw