@openhps/core
Version:
Open Hybrid Positioning System - Core component
68 lines • 2.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Node = void 0;
const tslib_1 = require("tslib");
const GraphNode_1 = require("./graph/_internal/GraphNode");
const data_1 = require("./data");
/**
* The graph node has an input and output {@link DataFrame}
*
* ## Usage
*
* ### Creating a Node
* Default nodes require you to specify the input and output data frame type. In general, nodes have the ability
* to process an input data frame and output a different (processed) data frame.
* ```typescript
* import { DataFrame, Node } from '@openhps/core';
*
* export class CustomNode<In extends DataFrame, Out extends DataFrame> extends Node<In, Out> {
* // ...
* }
* ```
* Abstract implementations such as a {@link SourceNode} and {@link SinkNode} only take one input or output
* data frame type as they do not process or change the frame.
* @category Node
*/
let Node = class Node extends GraphNode_1.GraphNode {
constructor(options) {
super();
this.setOptions(options || {});
// Set the uid of the node if manually set
this.uid = this.options.uid || this.uid;
}
/**
* Set the node options
* @param {NodeOptions} options Node options to set
* @returns {Node} Node instance
*/
setOptions(options) {
this.options = Object.assign(Object.assign({}, options), (this.options || []));
// Set the display name of the node to the type name
this.name = this.options.name || this.constructor.name;
return this;
}
/**
* Get the node options
* @returns {NodeOptions} Node options
*/
getOptions() {
return this.options;
}
/**
* Graph this model is part of
* @returns {Model} Positioning model
*/
get model() {
return this.graph;
}
};
exports.Node = Node;
tslib_1.__decorate([
(0, data_1.SerializableMember)(),
tslib_1.__metadata("design:type", Object)
], Node.prototype, "options", void 0);
exports.Node = Node = tslib_1.__decorate([
(0, data_1.SerializableObject)(),
tslib_1.__metadata("design:paramtypes", [Object])
], Node);
//# sourceMappingURL=Node.js.map