UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

30 lines 702 B
import { SourceNode } from '../SourceNode'; /** * This source node is initialized with an array of data. This data * is popped when pulling from this node. * @category Source node */ export class ListSourceNode extends SourceNode { constructor(inputData, options) { super(options); this._inputData = []; this._inputData = inputData; } get inputData() { return this._inputData; } set inputData(inputData) { this._inputData = inputData; } get size() { return this._inputData.length; } onPull() { return new Promise(resolve => { if (this._inputData.length !== 0) { resolve(this._inputData.shift()); } resolve(null); }); } }