TypeScript
Static function exports

by Benny Neugebauer

import fs from 'fs-extra';
import {CurrencyPairConfig} from '@lambot/exchange';
import {TradingStopConfig} from '../strategy';

type SerializedTradingConfig = CurrencyPairConfig & TradingStopConfig;

class ConfigSaver {
  static load(path: string): SerializedTradingConfig {
    return fs.readJsonSync(path);
  }

  static save(path: string, config: SerializedTradingConfig) {
    return fs.writeJsonSync(path, config, {
      spaces: 2,
    });
  }
}

export {ConfigSaver, SerializedTradingConfig};

import fs from 'fs-extra';
import {CurrencyPairConfig} from '@lambot/exchange';
import {TradingStopConfig} from '../strategy';

type SerializedTradingConfig = CurrencyPairConfig & TradingStopConfig;

const load = (path: string): SerializedTradingConfig => fs.readJsonSync(path);

const save = (path: string, config: SerializedTradingConfig) =>
  fs.writeJsonSync(path, config, {
    spaces: 2,
  });

export {load, save, SerializedTradingConfig};