UNPKG

@csvw-rdf-convertor/core

Version:

This library was generated with [Nx](https://nx.dev).

50 lines (49 loc) 1.43 kB
/** * Helps track the location in a file being processed. */ import { _ as _extends } from "@swc/helpers/_/_extends"; export class LocationTracker { /** * The location in the file being processed. */ get value() { return _extends({}, this._loc); } set value(value) { this._loc = value; } /** * Returns true if the location is not empty. */ get hasLocation() { return Object.keys(this._loc).length > 0; } /** * Updates the location in the file being processed. If only partial location is provided, * less specific layers will be kept from the original location and more specific layers will be removed. * @param newLoc The new location to be set. */ update(newLoc) { let keep = true; for (const layer of this.scopeLayers){ if (layer in newLoc) { this._loc[layer] = newLoc[layer]; keep = false; } else if (!keep) { delete this._loc[layer]; } } } constructor(scopeLayers){ this.scopeLayers = scopeLayers; this._loc = {}; } } /** * CsvLocationTracker is a specialized LocationTracker for CSV files. */ export class CsvLocationTracker extends LocationTracker { constructor(){ super([ 'table', 'row', 'column' ]); } } //# sourceMappingURL=code-location.js.map