@seasketch/geoprocessing
Version:
Geoprocessing and reporting framework for SeaSketch 2.0
27 lines • 1.2 kB
JavaScript
import { precalcConfig } from "../../../src/precalc/config.js";
import { readMetrics, writeMetrics, createOrUpdateMetrics } from "./metrics.js";
// Extends metrics datasource
/**
* Reads metrics from disk, validates them
* If metrics file not exist then start a new one and ensure directory exists
*/
export function readPrecalcMetrics(filePath) {
// Optional override
const finalFilePath = filePath && filePath.length > 0 ? filePath : precalcConfig.defaultSrcPath;
return readMetrics(finalFilePath);
}
/**
* Writes metrics to disk, sorted and rekeyed for consistent ordering
*/
export function writePrecalcMetrics(metrics, filePath) {
const finalFilePath = filePath && filePath.length > 0 ? filePath : precalcConfig.defaultSrcPath;
return writeMetrics(metrics, finalFilePath);
}
/** Creates or updates metrics on disk */
export async function createOrUpdatePrecalcMetrics(metrics, options = {}) {
// Optional override
const { matcher, filePath } = options;
const finalFilePath = filePath && filePath.length > 0 ? filePath : precalcConfig.defaultSrcPath;
return createOrUpdateMetrics(metrics, matcher, finalFilePath);
}
//# sourceMappingURL=precalc.js.map