UNPKG

@flexvertex/flexvertex-driver

Version:

The official FlexVertex Node.js driver

49 lines (39 loc) 1.21 kB
import { JSONParse, JSONStringify } from 'json-with-bigint'; import { FlexSegment } from '../journey/FlexSegment.js'; import { FlexResult } from '../schema/FlexResult.js'; /** * Represents the journey returned from a FlexVertex exploration. * A FlexJourney holds a collection of {@link FlexSegment} objects. * @hideconstructor */ export class FlexJourney extends FlexResult { #count = 0; #segmentArray = new Array(); constructor(schema, responseData) { super(schema, responseData); if(!(responseData === undefined)) { if(!(responseData.Count === undefined)) this.#count = responseData.Count; if(!(responseData.Segments === undefined)) { for(const s of responseData.Segments) { // console.log("-- s = " + JSONStringify(s)); let segment = new FlexSegment(schema, s); this.#segmentArray.push(segment); } } } } /** * @property {number} count - The number of FlexSegments returned in the journey */ get count() { return this.#count; } /** * @property {FlexSegment[]} segments - An array of FlexSegments returned in the journey */ get segments() { return this.#segmentArray; } }